Fixed Formatting
Removed unused variables Added Save() to OnDestroy() within all scripts related to PlayerData
This commit is contained in:
parent
a339149a71
commit
90948610cd
Binary file not shown.
|
@ -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;
|
||||||
|
|
|
@ -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");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,113 +5,117 @@ public class SpinningCube : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
//Playerdata -- Needs saved
|
//Playerdata -- Needs saved
|
||||||
public float currentSpeed = 20f;
|
public float currentSpeed = 20f;
|
||||||
public float currentIncrement = 10f;
|
public float currentIncrement = 10f;
|
||||||
|
|
||||||
|
|
||||||
private string RotationDirection = "Up";
|
private string RotationDirection = "Up";
|
||||||
private Vector3 m_RotationDirection = Vector3.up;
|
private Vector3 m_RotationDirection = Vector3.up;
|
||||||
private Vector3 rotationOrigin;
|
private Vector3 rotationOrigin;
|
||||||
private Vector3 stopRotation = Vector3.zero;
|
private Vector3 stopRotation = Vector3.zero;
|
||||||
private Vector3 tempRotation;
|
private Vector3 tempRotation;
|
||||||
private float angle2 = 0;
|
private float angle2 = 0;
|
||||||
private float angledif, angle1;
|
private float angledif, angle1;
|
||||||
private float angleSum = 0;
|
private float angleSum = 0;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int rotations;
|
private int rotations;
|
||||||
|
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
GameObject.FindGameObjectWithTag("GameController").GetComponent<GameManager>().Save();
|
||||||
|
}
|
||||||
|
|
||||||
public void ToggleRotationDirection()
|
public void ToggleRotationDirection()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_RotationDirection == Vector3.up)
|
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);
|
m_RotationDirection = Vector3.down;
|
||||||
stopRotation = Vector3.zero;
|
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)
|
if (m_RotationDirection == stopRotation)
|
||||||
{
|
|
||||||
m_RotationDirection = tempRotation;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tempRotation = m_RotationDirection;
|
|
||||||
m_RotationDirection = stopRotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RaiseRotationSpeed()
|
|
||||||
{
|
{
|
||||||
currentSpeed = currentSpeed + currentIncrement;
|
m_RotationDirection = tempRotation;
|
||||||
|
|
||||||
Debug.Log("Rotation Speed: " + currentSpeed);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
public void LowerRotationSpeed()
|
tempRotation = m_RotationDirection;
|
||||||
{
|
m_RotationDirection = stopRotation;
|
||||||
currentSpeed = currentSpeed - currentIncrement;
|
|
||||||
|
|
||||||
Debug.Log("Rotation Speed: " + currentSpeed);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ResetRotationSpeed()
|
public void RaiseRotationSpeed()
|
||||||
{
|
{
|
||||||
currentSpeed = 20.0f;
|
currentSpeed = currentSpeed + currentIncrement;
|
||||||
Debug.Log("Rotation Speed Reset");
|
Debug.Log("Rotation Speed: " + currentSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeColorWhite()
|
public void LowerRotationSpeed()
|
||||||
{
|
{
|
||||||
GameObject.FindGameObjectsWithTag("Player");
|
currentSpeed = currentSpeed - currentIncrement;
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.white;
|
Debug.Log("Rotation Speed: " + currentSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeColorBlue()
|
public void ResetRotationSpeed()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.blue;
|
currentSpeed = 20.0f;
|
||||||
}
|
Debug.Log("Rotation Speed Reset");
|
||||||
|
}
|
||||||
|
|
||||||
public void ChangeColorBlack()
|
public void ChangeColorWhite()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.black;
|
GameObject.FindGameObjectsWithTag("Player");
|
||||||
}
|
gameObject.GetComponent<Renderer>().material.color = Color.white;
|
||||||
|
}
|
||||||
|
|
||||||
public void ChangeColorGreen()
|
public void ChangeColorBlue()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.green;
|
gameObject.GetComponent<Renderer>().material.color = Color.blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeColorRed()
|
public void ChangeColorBlack()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.red;
|
gameObject.GetComponent<Renderer>().material.color = Color.black;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeColorMagenta()
|
public void ChangeColorGreen()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.magenta;
|
gameObject.GetComponent<Renderer>().material.color = Color.green;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeColorYellow()
|
public void ChangeColorRed()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.yellow;
|
gameObject.GetComponent<Renderer>().material.color = Color.red;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeColorCyan()
|
public void ChangeColorMagenta()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Renderer>().material.color = Color.cyan;
|
gameObject.GetComponent<Renderer>().material.color = Color.magenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeColorYellow()
|
||||||
|
{
|
||||||
|
gameObject.GetComponent<Renderer>().material.color = Color.yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeColorCyan()
|
||||||
|
{
|
||||||
|
gameObject.GetComponent<Renderer>().material.color = Color.cyan;
|
||||||
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
@ -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))
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue