public void Exit()
 {
     SetupGameRef.Exit();
     MainMenuRef.gameObject.SetActive(true);
     gameObject.SetActive(false);
     DarkOverlay.GetReference().SetDarkness(0f);
 }
 public static DarkOverlay GetReference()
 {
     if (reference == null)
     {
         reference = GameObject.Find("DarkOverlay").GetComponent <DarkOverlay>();
     }
     return(reference);
 }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (Started)
        {
            Tank   currentPlayer = GetCurrentPlayer();
            string message       = currentPlayer.TankName + "'s Turn. Health: " + currentPlayer.Health.ToString("0.00");
            message += " Fuel: " + currentPlayer.Fuel.ToString("0.00");
            message += " Munition: " + BulletPrefabs[currentPlayer.BulletType].name;
            DebugText.SetText(message);

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (Paused)
                {
                    Paused = false;
                    PauseMenuRef.Unpause();
                }
                else
                {
                    Paused = true;
                    PauseMenuRef.gameObject.SetActive(true);
                }
            }

            if (WaitingToNextPlayer)
            {
                NextPlayerTimer -= Time.deltaTime;
                if (NextPlayerTimer <= 0f)
                {
                    WaitingToNextPlayer = false;

                    CurrentPlayer++;
                    if (CurrentPlayer >= PlayerTanks.Count)
                    {
                        CurrentPlayer = 0;
                        NextTurn();
                    }

                    Winner = CheckWinner();
                    if (Winner == -1)
                    {
                        GetCurrentPlayer().StartTurn();
                    }
                    else
                    {
                        WaitingToEndGame = true;
                        EndGameTimer     = 8f;
                    }

                    if (!OnlineGame || PhotonNetwork.IsMasterClient)
                    {
                        if (Random.Range(0, 10) > 6)
                        {
                            BonusBoxRef.Spawn(Terrain.GetReference().HighestPoint + 2f);
                        }
                    }
                }
            }

            if (WaitingToEndGame)
            {
                EndGameTimer -= Time.deltaTime;
                if (EndGameTimer <= 3f)
                {
                    DarkOverlay.GetReference().SetDarkness(1f);
                }
                if (EndGameTimer <= 0f)
                {
                    DarkOverlay.GetReference().SetDarkness(0f);
                    WaitingToEndGame = false;

                    GameOverRef.gameObject.SetActive(true);
                    GameOverText.text = "Game Over\n\nThe winner is " + PlayerTanks[Winner].TankName;
                    EndGame();
                }
            }
        }
    }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     MyAudio       = GetComponent <AudioSource>();
     darkness      = DarkOverlay.GetReference();
     cameraEffects = CameraEffects.GetReference();
 }