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 {
|
||||
// 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<GameManager>().Save();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
fillAmount = currentExp / currentRequirement;
|
||||
|
|
|
@ -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<ExperienceBar>().currentExp = data.experience;
|
||||
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentRequirement = data.requirement;
|
||||
Debug.Log("Loaded");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<GameManager>().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;
|
||||
|
||||
if (m_RotationDirection == stopRotation)
|
||||
{
|
||||
m_RotationDirection = tempRotation;
|
||||
}
|
||||
else {
|
||||
tempRotation = m_RotationDirection;
|
||||
m_RotationDirection = stopRotation;
|
||||
}
|
||||
m_RotationDirection = Vector3.down;
|
||||
RotationDirection = "Down";
|
||||
}
|
||||
|
||||
public void RaiseRotationSpeed()
|
||||
else
|
||||
{
|
||||
currentSpeed = currentSpeed + currentIncrement;
|
||||
|
||||
Debug.Log("Rotation Speed: " + currentSpeed);
|
||||
m_RotationDirection = Vector3.up;
|
||||
RotationDirection = "Up";
|
||||
}
|
||||
Debug.Log("Toggled rotation direction: " + RotationDirection);
|
||||
|
||||
public void LowerRotationSpeed()
|
||||
}
|
||||
|
||||
public void ToggleRotation()
|
||||
{
|
||||
Debug.Log("Stopping Rotation. Last known rotation direction: " + RotationDirection);
|
||||
stopRotation = Vector3.zero;
|
||||
|
||||
if (m_RotationDirection == stopRotation)
|
||||
{
|
||||
currentSpeed = currentSpeed - currentIncrement;
|
||||
|
||||
Debug.Log("Rotation Speed: " + currentSpeed);
|
||||
m_RotationDirection = tempRotation;
|
||||
}
|
||||
|
||||
public void ResetRotationSpeed()
|
||||
{
|
||||
currentSpeed = 20.0f;
|
||||
Debug.Log("Rotation Speed Reset");
|
||||
else {
|
||||
tempRotation = m_RotationDirection;
|
||||
m_RotationDirection = stopRotation;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeColorWhite()
|
||||
{
|
||||
GameObject.FindGameObjectsWithTag("Player");
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.white;
|
||||
}
|
||||
public void RaiseRotationSpeed()
|
||||
{
|
||||
currentSpeed = currentSpeed + currentIncrement;
|
||||
Debug.Log("Rotation Speed: " + currentSpeed);
|
||||
}
|
||||
|
||||
public void ChangeColorBlue()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.blue;
|
||||
}
|
||||
public void LowerRotationSpeed()
|
||||
{
|
||||
currentSpeed = currentSpeed - currentIncrement;
|
||||
Debug.Log("Rotation Speed: " + currentSpeed);
|
||||
}
|
||||
|
||||
public void ChangeColorBlack()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.black;
|
||||
}
|
||||
public void ResetRotationSpeed()
|
||||
{
|
||||
currentSpeed = 20.0f;
|
||||
Debug.Log("Rotation Speed Reset");
|
||||
}
|
||||
|
||||
public void ChangeColorGreen()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.green;
|
||||
}
|
||||
public void ChangeColorWhite()
|
||||
{
|
||||
GameObject.FindGameObjectsWithTag("Player");
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.white;
|
||||
}
|
||||
|
||||
public void ChangeColorRed()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.red;
|
||||
}
|
||||
public void ChangeColorBlue()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.blue;
|
||||
}
|
||||
|
||||
public void ChangeColorMagenta()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.magenta;
|
||||
}
|
||||
public void ChangeColorBlack()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.black;
|
||||
}
|
||||
|
||||
public void ChangeColorYellow()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.yellow;
|
||||
}
|
||||
public void ChangeColorGreen()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.green;
|
||||
}
|
||||
|
||||
public void ChangeColorCyan()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.cyan;
|
||||
}
|
||||
public void ChangeColorRed()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.red;
|
||||
}
|
||||
|
||||
public void ChangeColorMagenta()
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
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