using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChargeCounter : MonoBehaviour { bool levelComplete = false; GameObject[] chargePoints; List chargedPoints = new List(); void Start() { if (chargePoints == null) chargePoints = GameObject.FindGameObjectsWithTag("Charge Point"); } public void AddChargedPoint(GameObject chargePoint) { chargedPoints.Add(chargePoint); DisplayCharges(); } public void RemoveChargedPoint(GameObject chargePoint) { chargedPoints.Remove(chargePoint); DisplayCharges(); } public bool IsLevelWon() { return levelComplete; } void DisplayCharges() { Debug.Log("Total Points Charged:" + chargedPoints.Count); if (chargedPoints.Count >= chargePoints.Length) { levelComplete = true; Debug.Log("Level Win!"); } } }