From 90948610cddd666ddb130155599f7a2c862264c6 Mon Sep 17 00:00:00 2001 From: Shaun M Reed Date: Sun, 3 Sep 2017 19:47:23 -0400 Subject: [PATCH] Fixed Formatting Removed unused variables Added Save() to OnDestroy() within all scripts related to PlayerData --- Assets/Scenes/Main.unity | Bin 114152 -> 114160 bytes Assets/Scripts/ExperienceBar.cs | 13 ++- Assets/Scripts/GameManager.cs | 16 +-- Assets/Scripts/SpinningCube.cs | 178 ++++++++++++++++---------------- Assets/Scripts/ToggleMenus.cs | 74 ++++++++++++- 5 files changed, 173 insertions(+), 108 deletions(-) diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 87f67444f2081ed9418315424a783f90f47aa36a..35e8a899664b6ab1aa48bf71eb4e0e3ca669e9bb 100644 GIT binary patch delta 1287 zcmYL|T}YE*6vxjbWYGs(16v^JOko#N)2M`csVHWP8mlKG zvcM?Aiy&>N^CNX?Ftt!qOzq3h*p0Ee620mF%rl;M91idAJkM|EJn#DkH={$F(R!kp zD$;!jwdqqkVm1;F1+4|v4S!M~IqC3yYa$W7C9g3rJxaW5jur2H<(6Au+YtK^^3vf~ zgZu!o6A>qLse8rMF6+KV+{u**2zkksKZ)GUqW8@)G2f->uibPybBbK&z2@#Zo%dDG z6;o0@7RpU)V+V8PCPzC_Epja453`W4jGHuj2T=*=c0`CPKCrX6m(BI`mgON4brMCa zz05qK6oxb(T8`RkyN@gOZX$z@Xcsp2Gt2BDvf_R>;;FAaY;_Ai4EkOW&>e_pTxkM} zSR0wO_9^RgW&^@FVbX&AMAg_WXCACS;y@zDfU*uTBR^3x`ZAzC%*-aTVaOaLx(6x^ zfze0Tkthfj>1%|UduXc%BkH5fJfaN--!PF2G!AjRIjabXY#-IBonSTq_8K)gt;WnD zbdx5nJfP+~$(6e!>eTX_F8Qda6|4eT_Ud3}6Bl6!jN(6ezI?8%k12y$J5?$T@t=qi zWk!_c=Z2YGyo6yEmB`E$Tq*gCzW51OGINisUaOdS#9tVE6GT!dyR%d~Zy=FvQdtw2 z1;DJ_>j7pVar%o%GfxrSVS`v(4I7%kBB%D4nSENlBMrB1=QlbNIKd*nBpkzJT`rnt!EEG{U>aSH!jjIhlmb{gt* Hvnl@p6b2tF delta 1266 zcmYk5T}YE*6vxjiA&Wkk%u>PHEH4&Fs8B(%S`cDUu&BU0R~Nd>$}iX~1nq+sXpm2t zMTLS3FN$VEojGlqmCe9UmPo~B8N0DobP;&d|CwhzZ5$5o@0|TO&vV|zS5jjusXC%? zEonos9$jJI<}B@Kcjw+)87GXLnQfJxKeu*7ieIyz+c z^2E+E*=_G7x`v#M_`xg&R)Xg(h@Z@?eMD7wUW2FqVmT0o^W5O9_wk-ML$ z3wa%4h*`cLlc%gsKg`T3I$^L45}DDt5z+4NO&DBY$yx6+qX6n`eZZ_;{DPr-m`JY? zZ9w%QSNyM(b);pN10{-pH6Y7bN155h!6}>~NR$VI9+fe!m`9c2U8waON@N4Oi7XA{ z%p&4846fI!Go+ys;);7r877!{!RpXsMC|jFUO*zVh{E81qi)T@75iIQ`PTL`s~T6Q zJ;1C{6inkD-V@csC#Q4N)X9aBIizmwEVCe3KA*ONSzI*1kokcq7r!zgoE2r&NMr>| zp4r803M{#cdS(tW4TEb^O?R0q?kRN-riPkYY4w6hy__|NnOWq_7%ahQbn|rExe}XE zhSue!gh4;6-Vwp9T~xzhom21HU9Q-|YOXeB_K(V1bShJ>h1_BU2GhLSMKM>#!P0pb zhnYndl=TR+xJaADO@30-HT^#6l0> zF1f*y8+I|%MgQ9cvkuV%gLhFGBECln!#r4Wn^9(tuWGJEW_qE`88(@|tMh&1O1^K$ e-1!voEUfdjg?IM~Z}iZ;j%F>rKd)IEEBFV>K^n0D diff --git a/Assets/Scripts/ExperienceBar.cs b/Assets/Scripts/ExperienceBar.cs index 6d57e9e..b3a69cd 100644 --- a/Assets/Scripts/ExperienceBar.cs +++ b/Assets/Scripts/ExperienceBar.cs @@ -4,16 +4,14 @@ using UnityEngine.UI; public class ExperienceBar : MonoBehaviour { - // Eventually.. public RectTransform gainedExp - //Array used as expRequired[leveldesired] - - //playerdata - needs saved + //Playerdata -- Needs saved public int currentLevel = 1; public float currentExp = 0; public float currentRequirement = 100; - public GameObject currentLevelText; + [SerializeField] + private GameObject currentLevelText; [SerializeField] private float fillAmount; [SerializeField] @@ -34,6 +32,11 @@ public class ExperienceBar : MonoBehaviour { fillAmount = currentExp / currentRequirement; } + public void OnDestroy() + { + GameObject.FindGameObjectWithTag("GameController").GetComponent().Save(); + } + // Update is called once per frame void Update () { fillAmount = currentExp / currentRequirement; diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 7209a28..b1192c2 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -20,17 +20,17 @@ public class GameManager : MonoBehaviour { public float increment; } + // Update is called once per frame + void Update () { + + } + // Use this for initialization void Start () { Load(); } - // Update is called once per frame - void Update () { - - } - void OnEnable() { Load(); @@ -67,7 +67,6 @@ public class GameManager : MonoBehaviour { bf.Serialize(file, data); file.Close(); Debug.Log("Saved"); - } public void Load() @@ -85,11 +84,6 @@ public class GameManager : MonoBehaviour { GameObject.FindGameObjectWithTag("ExpGained").GetComponent().currentExp = data.experience; GameObject.FindGameObjectWithTag("ExpGained").GetComponent().currentRequirement = data.requirement; Debug.Log("Loaded"); - - - } - } - } diff --git a/Assets/Scripts/SpinningCube.cs b/Assets/Scripts/SpinningCube.cs index 9c7c0d6..13a45a5 100644 --- a/Assets/Scripts/SpinningCube.cs +++ b/Assets/Scripts/SpinningCube.cs @@ -5,113 +5,117 @@ public class SpinningCube : MonoBehaviour { //Playerdata -- Needs saved - public float currentSpeed = 20f; - public float currentIncrement = 10f; + public float currentSpeed = 20f; + public float currentIncrement = 10f; - 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; + 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; + private int rotations; + + public void OnDestroy() + { + GameObject.FindGameObjectWithTag("GameController").GetComponent().Save(); + } 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() + if (m_RotationDirection == Vector3.up) { - Debug.Log("Stopping Rotation. Last known rotation direction: " + RotationDirection); - stopRotation = Vector3.zero; + 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() + if (m_RotationDirection == stopRotation) { - currentSpeed = currentSpeed + currentIncrement; - - Debug.Log("Rotation Speed: " + currentSpeed); + m_RotationDirection = tempRotation; } - - public void LowerRotationSpeed() - { - currentSpeed = currentSpeed - currentIncrement; - - Debug.Log("Rotation Speed: " + currentSpeed); + else { + tempRotation = m_RotationDirection; + m_RotationDirection = stopRotation; } + } - public void ResetRotationSpeed() - { - currentSpeed = 20.0f; - Debug.Log("Rotation Speed Reset"); - } + public void RaiseRotationSpeed() + { + currentSpeed = currentSpeed + currentIncrement; + Debug.Log("Rotation Speed: " + currentSpeed); + } - public void ChangeColorWhite() - { - GameObject.FindGameObjectsWithTag("Player"); - gameObject.GetComponent().material.color = Color.white; - } + public void LowerRotationSpeed() + { + currentSpeed = currentSpeed - currentIncrement; + Debug.Log("Rotation Speed: " + currentSpeed); + } - public void ChangeColorBlue() - { - gameObject.GetComponent().material.color = Color.blue; - } + public void ResetRotationSpeed() + { + currentSpeed = 20.0f; + Debug.Log("Rotation Speed Reset"); + } - public void ChangeColorBlack() - { - gameObject.GetComponent().material.color = Color.black; - } + public void ChangeColorWhite() + { + GameObject.FindGameObjectsWithTag("Player"); + gameObject.GetComponent().material.color = Color.white; + } - public void ChangeColorGreen() - { - gameObject.GetComponent().material.color = Color.green; - } + public void ChangeColorBlue() + { + gameObject.GetComponent().material.color = Color.blue; + } - public void ChangeColorRed() - { - gameObject.GetComponent().material.color = Color.red; - } + public void ChangeColorBlack() + { + gameObject.GetComponent().material.color = Color.black; + } - public void ChangeColorMagenta() - { - gameObject.GetComponent().material.color = Color.magenta; - } + public void ChangeColorGreen() + { + gameObject.GetComponent().material.color = Color.green; + } - public void ChangeColorYellow() - { - gameObject.GetComponent().material.color = Color.yellow; - } + public void ChangeColorRed() + { + gameObject.GetComponent().material.color = Color.red; + } - public void ChangeColorCyan() - { - gameObject.GetComponent().material.color = Color.cyan; - } + 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() { @@ -126,7 +130,7 @@ public class SpinningCube : MonoBehaviour //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 + //If object has rotated 20 degrees (currentSpeed = 20), when angle1 = 350, && angle2 = 10 //angle2(10)-angle1(350) = -340 //Object has rotated past 360 if ((currentSpeed > 0) && (angledif < 0)) diff --git a/Assets/Scripts/ToggleMenus.cs b/Assets/Scripts/ToggleMenus.cs index 7ed839c..168a21a 100644 --- a/Assets/Scripts/ToggleMenus.cs +++ b/Assets/Scripts/ToggleMenus.cs @@ -1,15 +1,19 @@ using UnityEngine; +using UnityEngine.UI; using System.Collections; public class ToggleMenus : MonoBehaviour { - + //Menus public GameObject RotMenu; public GameObject ColorMenu; public GameObject ShapesMenu; public GameObject LightingMenu; public GameObject ExpMenu; + private bool ActiveMenu = false; + + //Shapes - Prefabs public GameObject Square; public GameObject Sphere; public GameObject Cylinder; @@ -17,16 +21,30 @@ public class ToggleMenus : MonoBehaviour public GameObject Temp; public GameObject mySpawn; - private string Spawn = "Spawn"; private string Active = "Cube"; - private bool ActiveMenu = false; + + //Use with lighting menu + //private GameObject lighting = GameObject.FindGameObjectWithTag("Lighting"); + + public float lightRotX, lightRotY, lightRotZ; + public GameObject[] buttons; + // Use this for initialization void Start() { Temp = Square; + lightRotX = 0; + lightRotY = 0; + lightRotZ = 0; + EditLightingRotation(); + //EditLightingLocation(); + } + public void Update() + { + GameObject.FindGameObjectWithTag("Lighting").transform.Rotate(lightRotX, lightRotY, lightRotZ); } public void ToggleRotationMenu() @@ -133,7 +151,6 @@ public class ToggleMenus : MonoBehaviour ColorMenu.gameObject.SetActive(false); LightingMenu.gameObject.SetActive(false); ExpMenu.gameObject.SetActive(false); - } public void ChangeShapeSquare() @@ -172,4 +189,51 @@ public class ToggleMenus : MonoBehaviour Debug.Log(Active); } -} \ No newline at end of file + public void EditLightingRotation() + { + buttons = GameObject.FindGameObjectsWithTag("RotationMenuButtons"); + foreach (Object button in buttons) + { + gameObject.GetComponent