Added rotation count
Added rotation count to SpinningCube.cs -Change increment to change amount of speed added per level
This commit is contained in:
parent
12775c8ef7
commit
f20d8340bb
Binary file not shown.
Binary file not shown.
|
@ -67,6 +67,7 @@ public class ExperienceBar : MonoBehaviour {
|
|||
previousExpRequired = expRequired;
|
||||
expObtained = 0;
|
||||
expRequired = Mathf.Pow(expRequired, 1.05f);
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().RaiseRotationSpeed();
|
||||
}
|
||||
|
||||
public void ResetExp()
|
||||
|
|
|
@ -9,9 +9,15 @@ public class SpinningCube : MonoBehaviour
|
|||
|
||||
private string RotationDirection = "Up";
|
||||
private Vector3 m_RotationDirection = Vector3.up;
|
||||
private Vector3 rotationOrigin;
|
||||
private Vector3 stopRotation = Vector3.zero;
|
||||
private Vector3 tempRotation;
|
||||
private float angle2 = 0;
|
||||
private float angledif, angle1;
|
||||
private float angleSum = 0;
|
||||
|
||||
[SerializeField]
|
||||
private int rotations;
|
||||
|
||||
public void ToggleRotationDirection()
|
||||
{
|
||||
|
@ -105,12 +111,33 @@ public class SpinningCube : MonoBehaviour
|
|||
gameObject.GetComponent<Renderer>().material.color = Color.cyan;
|
||||
}
|
||||
|
||||
void Update()
|
||||
public void Start()
|
||||
{
|
||||
transform.Rotate(m_RotationDirection * Time.deltaTime * m_Speed);
|
||||
Vector3 rotationOrigin = GameObject.FindGameObjectWithTag("Player").transform.rotation.eulerAngles;
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
//Set angle1 = eulerAngle of axis being rotated prior to applying rotation
|
||||
angle1 = this.gameObject.transform.rotation.eulerAngles.y;
|
||||
transform.Rotate(m_RotationDirection * Time.deltaTime * m_Speed);
|
||||
//angle2 = eulerAngle of axis after rotation applied
|
||||
angle2 = this.gameObject.transform.rotation.eulerAngles.y;
|
||||
//Difference between angle2 and angle1, how much the object rotated between frames
|
||||
angledif = angle2 - angle1;
|
||||
|
||||
//rotations += (int)(m_Speed / 360);
|
||||
|
||||
//if object is rotating, and angle difference is less than 0
|
||||
//If object has rotated 20 degrees (m_speed = 20), when angle1 = 350, && angle2 = 10
|
||||
//angle2(10)-angle1(350) = -340
|
||||
//Object has rotated past 360
|
||||
if ((m_Speed > 0) && (angledif < 0))
|
||||
{
|
||||
++rotations;
|
||||
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().ExpMore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue