diff --git a/Assets/Prefabs/Cube.prefab b/Assets/Prefabs/Cube.prefab index 0d60c46..e9836f5 100644 Binary files a/Assets/Prefabs/Cube.prefab and b/Assets/Prefabs/Cube.prefab differ diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 0f8e8c1..534f596 100644 Binary files a/Assets/Scenes/Main.unity and b/Assets/Scenes/Main.unity differ diff --git a/Assets/Scripts/ExperienceBar.cs b/Assets/Scripts/ExperienceBar.cs index a35c851..768a1b2 100644 --- a/Assets/Scripts/ExperienceBar.cs +++ b/Assets/Scripts/ExperienceBar.cs @@ -67,6 +67,7 @@ public class ExperienceBar : MonoBehaviour { previousExpRequired = expRequired; expObtained = 0; expRequired = Mathf.Pow(expRequired, 1.05f); + GameObject.FindGameObjectWithTag("Player").GetComponent().RaiseRotationSpeed(); } public void ResetExp() diff --git a/Assets/Scripts/SpinningCube.cs b/Assets/Scripts/SpinningCube.cs index 339efb4..ce4f7be 100644 --- a/Assets/Scripts/SpinningCube.cs +++ b/Assets/Scripts/SpinningCube.cs @@ -8,12 +8,18 @@ public class SpinningCube : MonoBehaviour private string RotationDirection = "Up"; - private Vector3 m_RotationDirection = Vector3.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() + public void ToggleRotationDirection() { if (m_RotationDirection == Vector3.up) @@ -105,12 +111,33 @@ public class SpinningCube : MonoBehaviour gameObject.GetComponent().material.color = Color.cyan; } - void Update() - { - transform.Rotate(m_RotationDirection * Time.deltaTime * m_Speed); - } + public void Start() + { + 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().ExpMore(); + } + } } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 797d604..8d1360a 100644 Binary files a/ProjectSettings/TagManager.asset and b/ProjectSettings/TagManager.asset differ