Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- using PlayerInfo;
- using EnemyInfo;
- namespace Management
- {
- public class GameManager : MonoBehaviour
- {
- public static int PlayerScore;
- public static int EnemyScore;
- public Text ScoreText;
- public Text GameText;
- public float StartDelay = 3f;
- public float EndDelay = 3f;
- public GameManager[] Tanks;
- PlayerManager PManage;
- EnemyManager EManage;
- WaitForSeconds StartWait;
- WaitForSeconds EndWait;
- GameManager RoundWinner;
- GameManager GameWinner;
- int RoundNumber;
- int Wins;
- void Awake ()
- {
- PlayerScore = 0;
- EnemyScore = 0;
- }
- public void Start ()
- {
- StartWait = new WaitForSeconds (StartDelay);
- EndWait = new WaitForSeconds (EndDelay);
- SpawnTanks ();
- StartCoroutine (GameLoop ());
- }
- void Update ()
- {
- ScoreText.text = "Round Wins: " + PlayerScore + " - " + EnemyScore;
- }
- public void SpawnTanks ()
- {
- PManage.PSpawn ();
- PManage.PSetup ();
- EManage.ESpawn ();
- EManage.ESetup ();
- }
- public IEnumerator GameLoop ()
- {
- yield return StartCoroutine (RoundStarting ());
- yield return StartCoroutine (RoundPlaying ());
- yield return StartCoroutine (RoundEnding ());
- }
- IEnumerator RoundStarting ()
- {
- ResetAllTanks ();
- DisableTankControl ();
- RoundNumber++;
- GameText.text = "ROUND: " + RoundNumber;
- yield return StartWait;
- }
- IEnumerator RoundPlaying ()
- {
- EnableTankControl ();
- GameText.text = string.Empty;
- while (!OneTankLeft ())
- {
- yield return null;
- }
- }
- IEnumerator RoundEnding ()
- {
- DisableTankControl ();
- RoundWinner = null;
- RoundWinner = GetRoundWinner ();
- if (RoundWinner != null)
- RoundWinner.Wins++;
- GameWinner = GetGameWinner ();
- yield return EndWait;
- }
- bool OneTankLeft ()
- {
- int numTanksLeft = 0;
- for (int i = 0; i < Tanks.Length; i++)
- {
- if (Tanks [i].Instance.activeSelf)
- numTanksLeft++;
- }
- }
- GameManager GetRoundWinner ()
- {
- }
- GameManager GetGameWinner ()
- {
- }
- void ResetAllTanks ()
- {
- }
- void EnableTankControl ()
- {
- }
- void DisableTankControl ()
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment