Commit 44e618a8 authored by astatham's avatar astatham
Browse files

Still no joy with needle

parent 6c8c4d26
......@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
public class Needle : MonoBehaviour {
public static float angleChangeSpeed = 20;
public static float angleChangeSpeed = 50;
public static float maxAngle = 90f;
public static float minAngle = 0;
public static float currentAngle = 0;
......@@ -12,40 +12,50 @@ public class Needle : MonoBehaviour {
void Update()
{
if (currentAngle >= minAngle && currentAngle < maxAngle && currentAngle > previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle += (angleChangeSpeed * Time.deltaTime);
} else if (currentAngle <= maxAngle && currentAngle > minAngle && currentAngle < previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle -= (angleChangeSpeed * Time.deltaTime);
} else if (currentAngle > previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle -= (angleChangeSpeed * Time.deltaTime);
} else if (currentAngle < previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle += (angleChangeSpeed * Time.deltaTime);
}
if (Input.GetKeyDown("space")){
finalAngle = currentAngle;
angleChangeSpeed = 0;
PowerBar.previousPos = -9f;
if (!FindObjectOfType<Pie>())
{
if (currentAngle >= minAngle && currentAngle < maxAngle && currentAngle > previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle += (angleChangeSpeed * Time.deltaTime);
}
else if (currentAngle <= maxAngle && currentAngle > minAngle && currentAngle < previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle -= (angleChangeSpeed * Time.deltaTime);
}
else if (currentAngle > previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle -= (angleChangeSpeed * Time.deltaTime);
}
else if (currentAngle < previousAngle)
{
gameObject.transform.rotation = Quaternion.Euler(0, 0, currentAngle);
previousAngle = currentAngle;
currentAngle += (angleChangeSpeed * Time.deltaTime);
}
if (Input.GetKeyDown("space"))
{
finalAngle = currentAngle;
angleChangeSpeed = 0;
PowerBar.previousPos = -9f;
}
}
}
public static void ResetAngles()
{
angleChangeSpeed = 20;
angleChangeSpeed = 50;
//currentAngle = 0;
previousAngle = -1f;
//finalAngle = -1f;
}
}
......@@ -12,7 +12,6 @@ public class Pie : MonoBehaviour {
private void OnTriggerEnter2D(Collider2D collision)
{
print("Blah");
PieManager.pieInScene = false;
PieManager.start = false;
Destroy(gameObject);
......
......@@ -10,9 +10,8 @@ public class PieManager : MonoBehaviour {
private void Update()
{
if (pieCount > 0 && !pieInScene && !start){
print("Bleh");
/*if (pieCount > 0 && !pieInScene && !start){
Needle.ResetAngles();
}
}*/
}
}
......@@ -44,6 +44,8 @@ public class PowerBar : MonoBehaviour {
finalPos = currentPos;
previousPos = currentPos;
Instantiate(piePrefab);
PieManager.pieInScene = true;
PieManager.pieCount--;
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment