Fixed Formatting

Removed unused variables
Added Save() to OnDestroy() within all scripts related to PlayerData
This commit is contained in:
Shaun Reed 2017-09-03 19:47:23 -04:00
parent a339149a71
commit 90948610cd
5 changed files with 173 additions and 108 deletions

Binary file not shown.

View File

@ -4,16 +4,14 @@ using UnityEngine.UI;
public class ExperienceBar : MonoBehaviour { public class ExperienceBar : MonoBehaviour {
// Eventually.. public RectTransform gainedExp
//Array used as expRequired[leveldesired]
//Playerdata -- Needs saved
//playerdata - needs saved
public int currentLevel = 1; public int currentLevel = 1;
public float currentExp = 0; public float currentExp = 0;
public float currentRequirement = 100; public float currentRequirement = 100;
public GameObject currentLevelText;
[SerializeField]
private GameObject currentLevelText;
[SerializeField] [SerializeField]
private float fillAmount; private float fillAmount;
[SerializeField] [SerializeField]
@ -34,6 +32,11 @@ public class ExperienceBar : MonoBehaviour {
fillAmount = currentExp / currentRequirement; fillAmount = currentExp / currentRequirement;
} }
public void OnDestroy()
{
GameObject.FindGameObjectWithTag("GameController").GetComponent<GameManager>().Save();
}
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
fillAmount = currentExp / currentRequirement; fillAmount = currentExp / currentRequirement;

View File

@ -20,17 +20,17 @@ public class GameManager : MonoBehaviour {
public float increment; public float increment;
} }
// Update is called once per frame
void Update () {
}
// Use this for initialization // Use this for initialization
void Start () { void Start () {
Load(); Load();
} }
// Update is called once per frame
void Update () {
}
void OnEnable() void OnEnable()
{ {
Load(); Load();
@ -67,7 +67,6 @@ public class GameManager : MonoBehaviour {
bf.Serialize(file, data); bf.Serialize(file, data);
file.Close(); file.Close();
Debug.Log("Saved"); Debug.Log("Saved");
} }
public void Load() public void Load()
@ -85,11 +84,6 @@ public class GameManager : MonoBehaviour {
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentExp = data.experience; GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentExp = data.experience;
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentRequirement = data.requirement; GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentRequirement = data.requirement;
Debug.Log("Loaded"); Debug.Log("Loaded");
} }
} }
} }

View File

@ -21,6 +21,11 @@ public class SpinningCube : MonoBehaviour
[SerializeField] [SerializeField]
private int rotations; private int rotations;
public void OnDestroy()
{
GameObject.FindGameObjectWithTag("GameController").GetComponent<GameManager>().Save();
}
public void ToggleRotationDirection() public void ToggleRotationDirection()
{ {
@ -35,6 +40,7 @@ public class SpinningCube : MonoBehaviour
RotationDirection = "Up"; RotationDirection = "Up";
} }
Debug.Log("Toggled rotation direction: " + RotationDirection); Debug.Log("Toggled rotation direction: " + RotationDirection);
} }
public void ToggleRotation() public void ToggleRotation()
@ -55,14 +61,12 @@ public class SpinningCube : MonoBehaviour
public void RaiseRotationSpeed() public void RaiseRotationSpeed()
{ {
currentSpeed = currentSpeed + currentIncrement; currentSpeed = currentSpeed + currentIncrement;
Debug.Log("Rotation Speed: " + currentSpeed); Debug.Log("Rotation Speed: " + currentSpeed);
} }
public void LowerRotationSpeed() public void LowerRotationSpeed()
{ {
currentSpeed = currentSpeed - currentIncrement; currentSpeed = currentSpeed - currentIncrement;
Debug.Log("Rotation Speed: " + currentSpeed); Debug.Log("Rotation Speed: " + currentSpeed);
} }
@ -126,7 +130,7 @@ public class SpinningCube : MonoBehaviour
//rotations += (int)(m_Speed / 360); //rotations += (int)(m_Speed / 360);
//if object is rotating, and angle difference is less than 0 //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 //angle2(10)-angle1(350) = -340
//Object has rotated past 360 //Object has rotated past 360
if ((currentSpeed > 0) && (angledif < 0)) if ((currentSpeed > 0) && (angledif < 0))

View File

@ -1,15 +1,19 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using System.Collections; using System.Collections;
public class ToggleMenus : MonoBehaviour public class ToggleMenus : MonoBehaviour
{ {
//Menus
public GameObject RotMenu; public GameObject RotMenu;
public GameObject ColorMenu; public GameObject ColorMenu;
public GameObject ShapesMenu; public GameObject ShapesMenu;
public GameObject LightingMenu; public GameObject LightingMenu;
public GameObject ExpMenu; public GameObject ExpMenu;
private bool ActiveMenu = false;
//Shapes - Prefabs
public GameObject Square; public GameObject Square;
public GameObject Sphere; public GameObject Sphere;
public GameObject Cylinder; public GameObject Cylinder;
@ -17,16 +21,30 @@ public class ToggleMenus : MonoBehaviour
public GameObject Temp; public GameObject Temp;
public GameObject mySpawn; public GameObject mySpawn;
private string Spawn = "Spawn"; private string Spawn = "Spawn";
private string Active = "Cube"; 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 // Use this for initialization
void Start() void Start()
{ {
Temp = Square; Temp = Square;
lightRotX = 0;
lightRotY = 0;
lightRotZ = 0;
EditLightingRotation();
//EditLightingLocation();
}
public void Update()
{
GameObject.FindGameObjectWithTag("Lighting").transform.Rotate(lightRotX, lightRotY, lightRotZ);
} }
public void ToggleRotationMenu() public void ToggleRotationMenu()
@ -133,7 +151,6 @@ public class ToggleMenus : MonoBehaviour
ColorMenu.gameObject.SetActive(false); ColorMenu.gameObject.SetActive(false);
LightingMenu.gameObject.SetActive(false); LightingMenu.gameObject.SetActive(false);
ExpMenu.gameObject.SetActive(false); ExpMenu.gameObject.SetActive(false);
} }
public void ChangeShapeSquare() public void ChangeShapeSquare()
@ -172,4 +189,51 @@ public class ToggleMenus : MonoBehaviour
Debug.Log(Active); Debug.Log(Active);
} }
public void EditLightingRotation()
{
buttons = GameObject.FindGameObjectsWithTag("RotationMenuButtons");
foreach (Object button in buttons)
{
gameObject.GetComponent<Button>().onClick.RemoveAllListeners();
}
GameObject.Find("X Button").GetComponent<Button>().onClick.AddListener(() => { EditLightingRotationX(); });
GameObject.Find("Y Button").GetComponent<Button>().onClick.AddListener(() => { EditLightingRotationY(); });
GameObject.Find("Z Button").GetComponent<Button>().onClick.AddListener(() => { EditLightingRotationZ(); });
}
public void EditLightingLocation()
{
buttons = GameObject.FindGameObjectsWithTag("RotationMenuButtons");
foreach (Object button in buttons)
{
gameObject.GetComponent<Button>().onClick.RemoveAllListeners();
}
//
//CHANGE THESE TO LOCATION NOT ROTATION
//
GameObject.Find("X Button").GetComponent<Button>().onClick.AddListener(() => { EditLightingRotationX(); });
GameObject.Find("Y Button").GetComponent<Button>().onClick.AddListener(() => { EditLightingRotationY(); });
GameObject.Find("Z Button").GetComponent<Button>().onClick.AddListener(() => { EditLightingRotationZ(); });
}
public void EditLightingLocationX()
{
//lightRotX = 20 * Time.deltaTime;
}
public void EditLightingRotationX()
{
lightRotX = 20 * Time.deltaTime;
}
public void EditLightingRotationY()
{
lightRotY = 20 * Time.deltaTime;
}
public void EditLightingRotationZ()
{
lightRotZ = 20 * Time.deltaTime;
}
} }