void UpdateUI(int _blueLeft, int _redLeft, bool complete) { remainingBlues.text = _blueLeft.ToString(); remainingReds.text = _redLeft.ToString(); if (complete) { redCount = 0; blueCount = 0; OnObjectiveComplete.Invoke(); objImages[currObjectiveIndex].color = Color.green; if (currObjectiveIndex == playerObjectives.Length - 1) { panelAnim.SetBool("GameOver", true); playerNameText.text = playerName; Debug.Log(playerName + " wins!"); OnEndGame.Invoke(); } else { currObjectiveIndex++; Ojbective tempObjective = playerObjectives [currObjectiveIndex]; remainingBlues.text = tempObjective.blueCount.ToString(); remainingReds.text = tempObjective.redCount.ToString(); } } }
// Use this for initialization void Start() { collider = GetComponent <BoxCollider2D> (); for (int i = 0; i < playerObjectives.Length; i++) { playerObjectives [i] = objectivesCollection.getRandom(); } Ojbective tempObjective = playerObjectives [currObjectiveIndex]; UpdateUI(tempObjective.blueCount, tempObjective.redCount, false); }