Fixed changing shapes
- Changing shapes no longer breaks menu functions - Moved all Change...() functions related to Player in SpinningCube.cs to ToggleMenus.cs script -- Add saving needed data --Color, shape (Speed between shapes, etc..) -Created two new functions to replace 10+ small functions with switch case -ChangeShape(string shape) & ChangeColor(string color)
This commit is contained in:
parent
22c303d686
commit
20ff747b7b
Binary file not shown.
Binary file not shown.
|
@ -1,8 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 00e22d1ed21d14248801d764a0f6a057
|
||||
timeCreated: 1478187146
|
||||
timeCreated: 1504664152
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 100100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -81,7 +81,7 @@ public class ExperienceBar : MonoBehaviour {
|
|||
previousExpRequired = currentRequirement;
|
||||
currentExp -= previousExpRequired;
|
||||
currentRequirement = Mathf.Pow(currentRequirement, 1.05f);
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().RaiseRotationSpeed();
|
||||
GameObject.Find("Main Panel").GetComponent<ToggleMenus>().RaiseRotationSpeed();
|
||||
notify = "Level " + currentLevel + "!";
|
||||
eventSystem.GetComponent<GameManager>().RewardPopup(currentLevel, 2);
|
||||
|
||||
|
|
|
@ -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<Renderer>().material.color = Color.white;
|
||||
}
|
||||
|
||||
public void ChangeColorBlue()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.blue;
|
||||
}
|
||||
|
||||
public void ChangeColorBlack()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.black;
|
||||
}
|
||||
|
||||
public void ChangeColorGreen()
|
||||
{
|
||||
gameObject.GetComponent<Renderer>().material.color = Color.green;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
//Set angle1 = eulerAngle of axis being rotated prior to applying rotation
|
||||
|
|
|
@ -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<SpinningCube>().RaiseRotationSpeed(); });
|
||||
rotationButtons[1].onClick.AddListener(() => { player.GetComponent<SpinningCube>().LowerRotationSpeed(); });
|
||||
rotationButtons[2].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ToggleRotation(); });
|
||||
rotationButtons[3].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ToggleRotationDirection(); });
|
||||
rotationButtons[4].onClick.AddListener(() => { player.GetComponent<SpinningCube>().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<SpinningCube>().ChangeColorBlack(); });
|
||||
colorButtons[1].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ChangeColorWhite(); });
|
||||
colorButtons[2].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ChangeColorRed(); });
|
||||
colorButtons[3].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ChangeColorGreen(); });
|
||||
colorButtons[4].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ChangeColorBlue(); });
|
||||
colorButtons[5].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ChangeColorYellow(); });
|
||||
colorButtons[6].onClick.AddListener(() => { player.GetComponent<SpinningCube>().ChangeColorCyan(); });
|
||||
colorButtons[7].onClick.AddListener(() => { player.GetComponent<SpinningCube>().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<GameManager>().Save(); });
|
||||
|
@ -340,4 +357,101 @@ public class ToggleMenus : MonoBehaviour
|
|||
expButtons[2].onClick.AddListener(() => { GameObject.Find("Gained Image").GetComponent<ExperienceBar>().ResetExp(); });
|
||||
|
||||
}
|
||||
|
||||
public void ToggleRotationDirection()
|
||||
{
|
||||
|
||||
if (GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().m_RotationDirection == Vector3.up)
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().m_RotationDirection = Vector3.down;
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().RotationDirection = "Down";
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().m_RotationDirection = Vector3.up;
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().RotationDirection = "Up";
|
||||
}
|
||||
Debug.Log("Toggled rotation direction: " + GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().RotationDirection);
|
||||
|
||||
}
|
||||
|
||||
public void ToggleRotation()
|
||||
{
|
||||
Debug.Log("Stopping Rotation. Last known rotation direction: " + GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().RotationDirection);
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().stopRotation = Vector3.zero;
|
||||
|
||||
if (GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().m_RotationDirection == GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().stopRotation)
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().m_RotationDirection = GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().tempRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().tempRotation = GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().m_RotationDirection;
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().m_RotationDirection = GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().stopRotation;
|
||||
}
|
||||
}
|
||||
|
||||
public void RaiseRotationSpeed()
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed = GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed + GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentIncrement;
|
||||
Debug.Log("Rotation Speed: " + GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed);
|
||||
}
|
||||
|
||||
public void LowerRotationSpeed()
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed = GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed - GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentIncrement;
|
||||
Debug.Log("Rotation Speed: " + GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed);
|
||||
}
|
||||
|
||||
public void ResetRotationSpeed()
|
||||
{
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed = 20.0f;
|
||||
Debug.Log("Rotation Speed Reset");
|
||||
}
|
||||
|
||||
public void ChangeColor(string color)
|
||||
{
|
||||
switch (color)
|
||||
{
|
||||
|
||||
case "White":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.white;
|
||||
break;
|
||||
|
||||
case "Blue":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.blue;
|
||||
break;
|
||||
|
||||
case "Black":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.black;
|
||||
break;
|
||||
|
||||
case "Green":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.green;
|
||||
break;
|
||||
|
||||
case "Red":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.red;
|
||||
break;
|
||||
|
||||
case "Magenta":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.magenta;
|
||||
break;
|
||||
|
||||
case "Yellow":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.yellow;
|
||||
break;
|
||||
|
||||
case "Cyan":
|
||||
GameObject.FindGameObjectWithTag("Player").GetComponent<Renderer>().material.color = Color.cyan;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Debug.Log("Error - no color named :" + color);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue