Beispiel #1
0
    public void ReturnToGame()                                                                                              // Will return to the game by chekcing if player is alive or not
    {
        if (PlayerTankmanager.GetPlayer() && PlayerTankmanager.GetPlayer().GetComponent <RTCTankController>().CheckAlive()) // checking if player is alive
        {
            if (!gameWon)
            {
                Cursor.visible   = false;
                Cursor.lockState = CursorLockMode.Locked;
            }
            else
            {
                Cursor.visible   = true;
                Cursor.lockState = CursorLockMode.None;
            }
        }
        else
        {
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
        }
        // Returinng to the game by disabling the Pause Menu's components
        GetComponent <Canvas>().enabled = false;
        EventManager.TriggerEvent("GameUnPaused"); // Triggering the event that will resume the game
        loadingOverlay.SetActive(false);

        Time.timeScale = 1;
        winScreen.GetComponent <Canvas>().enabled  = false;
        gameObject.GetComponent <Canvas>().enabled = false;

        if (GameObject.Find("AudioSource"))
        {
            GameObject.Find("AudioSource").GetComponent <AudioSource>().volume = 1f; // changing the volume
        }
        uiComponents.SetActive(true);
    }
Beispiel #2
0
    IEnumerator ObjectiveComplete() // Coroutine to check if the objective has been complete and based on that assign a winning team, switching of the UI elements
    {
        EventManager.TriggerEvent("DeathCam");
        PlayerTankmanager.GetPlayer().GetComponent <RTCTankController>().gasInput   = 0;
        PlayerTankmanager.GetPlayer().GetComponent <RTCTankController>().steerInput = 0;

        // Chekcing if the current game mode is arcade and the based on that get all the details and info required for this mode, from scores to all the stats
        if (APP.PlayerTankManager.isArcade)
        {
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = false;
            ArcadeController.instance.arcadeRetryScreen.GetComponent <Canvas>().enabled = true;
            ArcadeController.instance.yesButton.gameObject.SetActive(false);
            ArcadeController.instance.noButton.gameObject.SetActive(false);
            ArcadeController.instance.info.enabled       = false;
            ArcadeController.instance._Overlay.enabled   = false;
            ArcadeController.instance.reviveText.enabled = false;
            statsPanel.transform.GetChild(2).gameObject.SetActive(false);
            win.transform.GetChild(6).gameObject.SetActive(false);
            win.GetComponent <Canvas>().enabled = true;
            ArcadeController.instance.towerHealth.gameObject.SetActive(false);
            if (GameObject.Find("ArcadeLives"))
            {
                GameObject.Find("ArcadeLives").SetActive(false);
            }
            if (GameObject.Find("ScoreName"))
            {
                GameObject.Find("ScoreName").SetActive(false);
            }
            ArcadeController.instance.waveText.SetActive(false);
            win.transform.GetChild(4).GetComponent <Text>().text = "Round Complete";
            statsPanel.SetActive(true);
            statsPanel.GetComponent <StatsDisplayController>().PopulateStats();
            hasWon = true;
            if (APP.PlayerTankManager._ArcadeMode == arcadeMode.SearchAndDestroy)
            {
                foreach (GameObject tank in EnemyWaveController.instance.spawnedTanks)
                {
                    tank.GetComponent <RTCTankController>().targetToAttack = null;
                    tank.GetComponent <RTCTankController>().aiState        = aiStates.idle;
                }
                ArcadeController.instance.labels.SetActive(false);
                ArcadeController.instance.playerPanel_RED.SetActive(false);
                ArcadeController.instance.playerPanel_BLUE.SetActive(false);
                ArcadeController.instance.UpdateRounds();
                if (APP.PlayerTankManager.REDTeamTotalScoresVal == 2)
                {
                    win.transform.GetChild(4).GetComponent <Text>().text = "Red Team Wins";
                    ArcadeController.instance.arcadeButton.gameObject.SetActive(true);
                    ArcadeController.instance.retryButton.gameObject.SetActive(true);
                }
            }
        }

        else
        {
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
            win.GetComponent <Canvas>().enabled = true;
            LevelEndAwardController awardController = FindObjectOfType <LevelEndAwardController>();
            if (awardController != null)
            {
                if (awardController.awardTankAtEndOfLevel)
                {
                    statsPanel.SetActive(false);
                    tankAwardBadge.SetActive(true);
                    tankAwardBadge.GetComponent <TankAwardBadge>().SetBadgeImage(awardController.tankToAward);
                    yield return(new WaitUntil(() => claimReward));
                }
            }
            tankAwardBadge.SetActive(false);
            statsPanel.SetActive(true);
            statsPanel.GetComponent <StatsDisplayController>().PopulateStats();
        }
    }