diff --git a/Assets/Prefabs/Capsule.prefab b/Assets/Prefabs/Capsule.prefab index 518bf18..d31fda7 100644 Binary files a/Assets/Prefabs/Capsule.prefab and b/Assets/Prefabs/Capsule.prefab differ diff --git a/Assets/Prefabs/Cube.prefab b/Assets/Prefabs/Cube.prefab index e9836f5..ae9dbcd 100644 Binary files a/Assets/Prefabs/Cube.prefab and b/Assets/Prefabs/Cube.prefab differ diff --git a/Assets/Prefabs/Cube.prefab.meta b/Assets/Prefabs/Cube.prefab.meta index 4749716..6ff34c1 100644 --- a/Assets/Prefabs/Cube.prefab.meta +++ b/Assets/Prefabs/Cube.prefab.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 guid: 00e22d1ed21d14248801d764a0f6a057 -timeCreated: 1478187146 +timeCreated: 1504664152 licenseType: Free NativeFormatImporter: + mainObjectFileID: 100100000 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Prefabs/Cylinder.prefab b/Assets/Prefabs/Cylinder.prefab index 6b436a1..93b9cb5 100644 Binary files a/Assets/Prefabs/Cylinder.prefab and b/Assets/Prefabs/Cylinder.prefab differ diff --git a/Assets/Prefabs/Sphere.prefab b/Assets/Prefabs/Sphere.prefab index 09d67ea..ae04524 100644 Binary files a/Assets/Prefabs/Sphere.prefab and b/Assets/Prefabs/Sphere.prefab differ diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index de0ce7a..c66b8c8 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 f437b62..c5628c7 100644 --- a/Assets/Scripts/ExperienceBar.cs +++ b/Assets/Scripts/ExperienceBar.cs @@ -81,7 +81,7 @@ public class ExperienceBar : MonoBehaviour { previousExpRequired = currentRequirement; currentExp -= previousExpRequired; currentRequirement = Mathf.Pow(currentRequirement, 1.05f); - GameObject.FindGameObjectWithTag("Player").GetComponent().RaiseRotationSpeed(); + GameObject.Find("Main Panel").GetComponent().RaiseRotationSpeed(); notify = "Level " + currentLevel + "!"; eventSystem.GetComponent().RewardPopup(currentLevel, 2); diff --git a/Assets/Scripts/SpinningCube.cs b/Assets/Scripts/SpinningCube.cs index f16aea7..5189b8c 100644 --- a/Assets/Scripts/SpinningCube.cs +++ b/Assets/Scripts/SpinningCube.cs @@ -11,27 +11,27 @@ public class SpinningCube : MonoBehaviour public float rotationPerSec = 0.0f; - 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; + public string RotationDirection = "Up"; + public Vector3 m_RotationDirection = Vector3.up; + public Vector3 rotationOrigin; + public Vector3 stopRotation = Vector3.zero; + public Vector3 tempRotation; + public float angle2 = 0; + public float angledif, angle1; + public float angleSum = 0; [SerializeField] - private float secPerRotation = 0.0f; + public float secPerRotation = 0.0f; [SerializeField] - private float lastRPS = 0.0f; + public float lastRPS = 0.0f; [SerializeField] - private float secondsPassed = 0.0f; + public float secondsPassed = 0.0f; [SerializeField] - private int rotations; + public int rotations; public void Start() { @@ -44,98 +44,6 @@ public class SpinningCube : MonoBehaviour } */ } - - public void ToggleRotationDirection() - { - - if (m_RotationDirection == Vector3.up) - { - m_RotationDirection = Vector3.down; - RotationDirection = "Down"; - } - else - { - m_RotationDirection = Vector3.up; - RotationDirection = "Up"; - } - Debug.Log("Toggled rotation direction: " + RotationDirection); - - } - - public void ToggleRotation() - { - Debug.Log("Stopping Rotation. Last known rotation direction: " + RotationDirection); - stopRotation = Vector3.zero; - - if (m_RotationDirection == stopRotation) - { - m_RotationDirection = tempRotation; - } - else { - tempRotation = m_RotationDirection; - m_RotationDirection = stopRotation; - } - } - - public void RaiseRotationSpeed() - { - currentSpeed = currentSpeed + currentIncrement; - Debug.Log("Rotation Speed: " + currentSpeed); - } - - public void LowerRotationSpeed() - { - currentSpeed = currentSpeed - currentIncrement; - Debug.Log("Rotation Speed: " + currentSpeed); - } - - public void ResetRotationSpeed() - { - currentSpeed = 20.0f; - Debug.Log("Rotation Speed Reset"); - } - - public void ChangeColorWhite() - { - GameObject.FindGameObjectsWithTag("Player"); - gameObject.GetComponent().material.color = Color.white; - } - - public void ChangeColorBlue() - { - gameObject.GetComponent().material.color = Color.blue; - } - - public void ChangeColorBlack() - { - gameObject.GetComponent().material.color = Color.black; - } - - public void ChangeColorGreen() - { - gameObject.GetComponent().material.color = Color.green; - } - - public void ChangeColorRed() - { - gameObject.GetComponent().material.color = Color.red; - } - - public void ChangeColorMagenta() - { - gameObject.GetComponent().material.color = Color.magenta; - } - - public void ChangeColorYellow() - { - gameObject.GetComponent().material.color = Color.yellow; - } - - public void ChangeColorCyan() - { - gameObject.GetComponent().material.color = Color.cyan; - } - void FixedUpdate() { //Set angle1 = eulerAngle of axis being rotated prior to applying rotation diff --git a/Assets/Scripts/ToggleMenus.cs b/Assets/Scripts/ToggleMenus.cs index 34f291c..7247d22 100644 --- a/Assets/Scripts/ToggleMenus.cs +++ b/Assets/Scripts/ToggleMenus.cs @@ -16,29 +16,31 @@ public class ToggleMenus : MonoBehaviour //Shapes - Prefabs public GameObject player; - public GameObject Square; + public GameObject Cube; public GameObject Sphere; public GameObject Cylinder; public GameObject Capsule; public GameObject Temp; public GameObject mySpawn; - private string Spawn = "Spawn"; - private string Active = "Cube"; - //Use with lighting menu //private GameObject lighting = GameObject.FindGameObjectWithTag("Lighting"); public float lightRotX, lightRotY, lightRotZ; + private string Spawn = "Spawn"; + private string Active = "Cube"; + + // Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); + mySpawn = GameObject.Find("PlayerSpawn"); InitializeButtonArrays(); - Temp = Square; + Temp = Cube; lightRotX = 0; lightRotY = 0; lightRotZ = 0; @@ -159,41 +161,56 @@ public class ToggleMenus : MonoBehaviour expMenu.gameObject.SetActive(false); } - public void ChangeShapeSquare() + public void ChangeShape(string shape) { - Instantiate(Square, mySpawn.transform.position, mySpawn.transform.rotation); - Debug.Log("Destroy " + Active); - Destroy(GameObject.Find(Active)); - Active = "Cube(Clone)"; - Debug.Log(Active); + switch (shape) + { + case "Cube": + Instantiate(Cube, mySpawn.transform.position, mySpawn.transform.rotation); + Debug.Log("Destroy " + Active); + Destroy(GameObject.Find(Active)); + Active = "Cube(Clone)"; + player = GameObject.FindGameObjectWithTag("Player"); + Debug.Log(Active); + + break; + + case "Sphere": + Instantiate(Sphere, mySpawn.transform.position, mySpawn.transform.rotation); + Debug.Log("Destroy " + Active); + Destroy(GameObject.Find(Active)); + Active = "Sphere(Clone)"; + player = GameObject.FindGameObjectWithTag("Player"); + Debug.Log(Active); + + break; + + case "Capsule": + Instantiate(Capsule, mySpawn.transform.position, mySpawn.transform.rotation); + Debug.Log("Destroy " + Active); + Destroy(GameObject.Find(Active)); + Active = "Capsule(Clone)"; + player = GameObject.FindGameObjectWithTag("Player"); + Debug.Log(Active); + + break; + + case "Cylinder": + Instantiate(Cylinder, mySpawn.transform.position, mySpawn.transform.rotation); + Debug.Log("Destroy " + Active); + Destroy(GameObject.Find(Active)); + Active = "Cylinder(Clone)"; + player = GameObject.FindGameObjectWithTag("Player"); + Debug.Log(Active); + + break; + + default: + Debug.Log("Error - Not a valid shape : " + shape); + break; + } } - public void ChangeShapeSphere() - { - Instantiate(Sphere, mySpawn.transform.position, mySpawn.transform.rotation); - Debug.Log("Destroy " + Active); - Destroy(GameObject.Find(Active)); - Active = "Sphere(Clone)"; - Debug.Log(Active); - } - - public void ChangeShapeCapsule() - { - Instantiate(Capsule, mySpawn.transform.position, mySpawn.transform.rotation); - Debug.Log("Destroy " + Active); - Destroy(GameObject.Find(Active)); - Active = "Capsule(Clone)"; - Debug.Log(Active); - } - - public void ChangeShapeCylinder() - { - Instantiate(Cylinder, mySpawn.transform.position, mySpawn.transform.rotation); - Debug.Log("Destroy " + Active); - Destroy(GameObject.Find(Active)); - Active = "Cylinder(Clone)"; - Debug.Log(Active); - } /* public void EditLightingRotation() { @@ -310,25 +327,25 @@ public class ToggleMenus : MonoBehaviour mainButtons[3].onClick.AddListener(() => { ToggleLightingMenu(); }); mainButtons[4].onClick.AddListener(() => { ToggleExpMenu(); }); - rotationButtons[0].onClick.AddListener(() => { player.GetComponent().RaiseRotationSpeed(); }); - rotationButtons[1].onClick.AddListener(() => { player.GetComponent().LowerRotationSpeed(); }); - rotationButtons[2].onClick.AddListener(() => { player.GetComponent().ToggleRotation(); }); - rotationButtons[3].onClick.AddListener(() => { player.GetComponent().ToggleRotationDirection(); }); - rotationButtons[4].onClick.AddListener(() => { player.GetComponent().ResetRotationSpeed(); }); + rotationButtons[0].onClick.AddListener(() => { RaiseRotationSpeed(); }); + rotationButtons[1].onClick.AddListener(() => { LowerRotationSpeed(); }); + rotationButtons[2].onClick.AddListener(() => { ToggleRotation(); }); + rotationButtons[3].onClick.AddListener(() => { ToggleRotationDirection(); }); + rotationButtons[4].onClick.AddListener(() => { ResetRotationSpeed(); }); - colorButtons[0].onClick.AddListener(() => { player.GetComponent().ChangeColorBlack(); }); - colorButtons[1].onClick.AddListener(() => { player.GetComponent().ChangeColorWhite(); }); - colorButtons[2].onClick.AddListener(() => { player.GetComponent().ChangeColorRed(); }); - colorButtons[3].onClick.AddListener(() => { player.GetComponent().ChangeColorGreen(); }); - colorButtons[4].onClick.AddListener(() => { player.GetComponent().ChangeColorBlue(); }); - colorButtons[5].onClick.AddListener(() => { player.GetComponent().ChangeColorYellow(); }); - colorButtons[6].onClick.AddListener(() => { player.GetComponent().ChangeColorCyan(); }); - colorButtons[7].onClick.AddListener(() => { player.GetComponent().ChangeColorMagenta(); }); + colorButtons[0].onClick.AddListener(() => { ChangeColor("Black"); }); + colorButtons[1].onClick.AddListener(() => { ChangeColor("White"); }); + colorButtons[2].onClick.AddListener(() => { ChangeColor("Red"); }); + colorButtons[3].onClick.AddListener(() => { ChangeColor("Green"); }); + colorButtons[4].onClick.AddListener(() => { ChangeColor("Blue"); }); + colorButtons[5].onClick.AddListener(() => { ChangeColor("Yellow"); }); + colorButtons[6].onClick.AddListener(() => { ChangeColor("Cyan"); }); + colorButtons[7].onClick.AddListener(() => { ChangeColor("Magenta"); }); - shapesButtons[0].onClick.AddListener(() => { ChangeShapeCylinder(); }); - shapesButtons[1].onClick.AddListener(() => { ChangeShapeCapsule(); }); - shapesButtons[2].onClick.AddListener(() => { ChangeShapeSquare(); }); - shapesButtons[3].onClick.AddListener(() => { ChangeShapeSphere(); }); + shapesButtons[0].onClick.AddListener(() => { ChangeShape("Cylinder"); }); + shapesButtons[1].onClick.AddListener(() => { ChangeShape("Capsule"); }); + shapesButtons[2].onClick.AddListener(() => { ChangeShape("Cube"); }); + shapesButtons[3].onClick.AddListener(() => { ChangeShape("Sphere"); }); //Temporary save/load hidden in lighting for debug lightingButtons[0].onClick.AddListener(() => { GameObject.Find("EventSystem").GetComponent().Save(); }); @@ -340,4 +357,101 @@ public class ToggleMenus : MonoBehaviour expButtons[2].onClick.AddListener(() => { GameObject.Find("Gained Image").GetComponent().ResetExp(); }); } + + public void ToggleRotationDirection() + { + + if (GameObject.FindGameObjectWithTag("Player").GetComponent().m_RotationDirection == Vector3.up) + { + GameObject.FindGameObjectWithTag("Player").GetComponent().m_RotationDirection = Vector3.down; + GameObject.FindGameObjectWithTag("Player").GetComponent().RotationDirection = "Down"; + } + else + { + GameObject.FindGameObjectWithTag("Player").GetComponent().m_RotationDirection = Vector3.up; + GameObject.FindGameObjectWithTag("Player").GetComponent().RotationDirection = "Up"; + } + Debug.Log("Toggled rotation direction: " + GameObject.FindGameObjectWithTag("Player").GetComponent().RotationDirection); + + } + + public void ToggleRotation() + { + Debug.Log("Stopping Rotation. Last known rotation direction: " + GameObject.FindGameObjectWithTag("Player").GetComponent().RotationDirection); + GameObject.FindGameObjectWithTag("Player").GetComponent().stopRotation = Vector3.zero; + + if (GameObject.FindGameObjectWithTag("Player").GetComponent().m_RotationDirection == GameObject.FindGameObjectWithTag("Player").GetComponent().stopRotation) + { + GameObject.FindGameObjectWithTag("Player").GetComponent().m_RotationDirection = GameObject.FindGameObjectWithTag("Player").GetComponent().tempRotation; + } + else + { + GameObject.FindGameObjectWithTag("Player").GetComponent().tempRotation = GameObject.FindGameObjectWithTag("Player").GetComponent().m_RotationDirection; + GameObject.FindGameObjectWithTag("Player").GetComponent().m_RotationDirection = GameObject.FindGameObjectWithTag("Player").GetComponent().stopRotation; + } + } + + public void RaiseRotationSpeed() + { + GameObject.FindGameObjectWithTag("Player").GetComponent().currentSpeed = GameObject.FindGameObjectWithTag("Player").GetComponent().currentSpeed + GameObject.FindGameObjectWithTag("Player").GetComponent().currentIncrement; + Debug.Log("Rotation Speed: " + GameObject.FindGameObjectWithTag("Player").GetComponent().currentSpeed); + } + + public void LowerRotationSpeed() + { + GameObject.FindGameObjectWithTag("Player").GetComponent().currentSpeed = GameObject.FindGameObjectWithTag("Player").GetComponent().currentSpeed - GameObject.FindGameObjectWithTag("Player").GetComponent().currentIncrement; + Debug.Log("Rotation Speed: " + GameObject.FindGameObjectWithTag("Player").GetComponent().currentSpeed); + } + + public void ResetRotationSpeed() + { + GameObject.FindGameObjectWithTag("Player").GetComponent().currentSpeed = 20.0f; + Debug.Log("Rotation Speed Reset"); + } + + public void ChangeColor(string color) + { + switch (color) + { + + case "White": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.white; + break; + + case "Blue": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.blue; + break; + + case "Black": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.black; + break; + + case "Green": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.green; + break; + + case "Red": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.red; + break; + + case "Magenta": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.magenta; + break; + + case "Yellow": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.yellow; + break; + + case "Cyan": + GameObject.FindGameObjectWithTag("Player").GetComponent().material.color = Color.cyan; + break; + + + default: + Debug.Log("Error - no color named :" + color); + break; + + + } + } }