Level (debug) Win Condition

This commit is contained in:
Ava Gaiety Wroten 2020-06-14 11:00:39 -05:00
parent 6335383d45
commit fc128cb53f
2 changed files with 16 additions and 1 deletions

View file

@ -4,6 +4,7 @@ using UnityEngine;
public class ChargeCounter : MonoBehaviour public class ChargeCounter : MonoBehaviour
{ {
bool levelComplete = false;
GameObject[] chargePoints; GameObject[] chargePoints;
List<GameObject> chargedPoints = new List<GameObject>(); List<GameObject> chargedPoints = new List<GameObject>();
@ -24,8 +25,18 @@ public class ChargeCounter : MonoBehaviour
DisplayCharges(); DisplayCharges();
} }
public bool IsLevelWon()
{
return levelComplete;
}
void DisplayCharges() void DisplayCharges()
{ {
Debug.Log("Total Points:" + chargedPoints.Count); Debug.Log("Total Points Charged:" + chargedPoints.Count);
if (chargedPoints.Count >= chargePoints.Length)
{
levelComplete = true;
Debug.Log("Level Win!");
}
} }
} }

View file

@ -10,11 +10,13 @@ public class Turret : MonoBehaviour
float startX; float startX;
float startY; float startY;
ChargeCounter chargeCounter;
void Start() void Start()
{ {
startX = transform.position.x; startX = transform.position.x;
startY = transform.position.y; startY = transform.position.y;
chargeCounter = GameObject.FindWithTag("Charge Counter").GetComponent<ChargeCounter>();
} }
void Update() void Update()
@ -40,6 +42,8 @@ public class Turret : MonoBehaviour
Vector3 getMovementVector() Vector3 getMovementVector()
{ {
if (chargeCounter.IsLevelWon()) return Vector3.zero;
float x = isHorizontal ? Input.GetAxis("Horizontal") : 0; float x = isHorizontal ? Input.GetAxis("Horizontal") : 0;
float y = isHorizontal ? 0 : Input.GetAxis("Vertical"); float y = isHorizontal ? 0 : Input.GetAxis("Vertical");