// Update is called once per frame
 void Update()
 {
     if (count >= 3)
     {
         Scorekeeper.instance.AddScore(20);
         Scorekeeper.instance.FinalScore();
         GameOverUI.SetActive(true);
         Destroy(BossRef);
         this.enabled = false;
     }
 }
예제 #2
0
 void Start()
 {
     PauseMenuUI.SetActive(false);
     CountdownUI.SetActive(true);
     ControlsUI.SetActive(false);
     MenuCheckUI.SetActive(false);
     GameOverUI.SetActive(false);
     StartCoroutine(GameCountDown());
     GameIsPaused = false;
     gameStarted  = false;
 }
예제 #3
0
 void Start()
 {
     SetGameOverVisible(true);
     updater             = GameObject.FindGameObjectWithTag("Updater");
     score               = 0;
     currentrestDelay    = resetDelay;
     levelCompleteUIFade = levelCompleteUI.transform.Find("Panel").gameObject.GetComponent <Image>();
     SceneTransition     = sceneTransUI.transform.Find("Panel").gameObject.GetComponent <Image>();
     controller          = GameObject.FindGameObjectWithTag("GunParent").GetComponent <GunController>();
     main.Play();
     GameOverUI.SetActive(false);
 }
예제 #4
0
    IEnumerator gameOveranims()
    {
        yield return(new WaitForSeconds(2));

        GameOverUI.SetActive(true);
        yield return(new WaitForSeconds(1.5f));

        soundManager.instance.playSound(gameOverSounds);
        youScored.text = "You scored <color=red> " + Player.instance.score + "</color>";
        yield return(new WaitForSeconds(2));

        buttons.SetActive(true);
    }
예제 #5
0
 /// <summary>
 /// Restart button click event listener. Starts game
 /// </summary>
 public void Restart()
 {
     ControlsUI.SetActive(false);
     WinnerUI.SetActive(false);
     PlayerObject.GetComponent <Player>().Restart();
     Spawner.GetComponent <EnemySpawner>().Restart();
     BackgroundUI.GetComponent <Image>().sprite = LevelOptions.Background;
     StartGameBtn.SetActive(false);
     if (_playerDead)
     {
         GameOverUI.SetActive(false);
         _playerDead = false;
     }
     OnHealthsUpdate(PlayerObject.GetComponent <Player>().hPoints);
 }
예제 #6
0
    IEnumerator HPDown()                                        //if HPDown is selected:
    {
        if (twranched == true)                                  //check see if twranched
        {
            GameOverUI.SetActive(true);
            CharacterControl.gameOver = true;
        }
        else if (twranched == false)                    //if not twranched, twranch and changes state
        {
            player.transform.localScale += new Vector3(0, -.2f);
            yield return(new WaitForSeconds(.5f));             //bug: probability of killing enemy before twranch can change to true

            twranched = true;
        }
        yield return(new WaitForFixedUpdate());
    }
예제 #7
0
    /// <summary>
    /// Initialize component
    /// </summary>
    private void Start()
    {
        if (!PlayerPrefs.HasKey("soundOff"))
        {
            PlayerPrefs.SetInt("soundOff", 1);
            PlayerPrefs.Save();
        }

        audioSource = gameObject.GetComponent <AudioSource>();

        if (PlayerObject != null)
        {
            Player.OnPlayerDead += GameOver;
            Player.OnScoreSet   += OnScoreUpdate;
            Player.OnHealthsSet += OnHealthsUpdate;
            Player.OnBuyBonus   += OnBuyBonus;
            PlayerObject.SetActive(false);
        }

        if (Spawner != null)
        {
            Spawner.GetComponent <EnemySpawner>().SetLevelSettings(LevelOptions);
            Spawner.SetActive(false);
        }

        if (GameOverUI != null)
        {
            GameOverUI.SetActive(false);
        }

        if (WinnerUI != null)
        {
            WinnerUI.SetActive(false);
        }

        if (MusicToggleUI != null)
        {
            musicToggleUI.GetComponent <Toggle>().isOn = PlayerPrefs.GetInt("soundOff") == 1;
            if (!musicToggleUI.GetComponent <Toggle>().isOn)
            {
                var clip = Soundtrack.ElementAt(0);
                audioSource.clip = clip;
                audioSource.loop = true;
                audioSource.Play();
            }
        }
    }
예제 #8
0
    void HealthDrop(float amt)
    {
        t         = 0f;
        newHealth = currHealth + amt;
        if (newHealth <= 0f)
        {
            //show game over stuff
            //check if highscore, overwrite if so.
            GameObject.FindObjectOfType <HighScore>().SubmitNewScore(score);
            //show game over screen
            GameOverUI.SetActive(true);
            GameOverUI.transform.Find("HS").GetComponent <Text>().text = "Your Score: " + score + "\nHigh Score: " + PlayerPrefs.GetInt("highestScore");

            paused = true;
            //StartCoroutine (RestartGame ());
        }
    }
예제 #9
0
    /// <summary>
    /// OnPlayerDead event listener
    /// </summary>
    private void GameOver()
    {
        if (!_playerDead)
        {
            _playerDead = true;
            if (StartGameBtn != null && !StartGameBtn.activeSelf)
            {
                StartGameBtn.SetActive(true);
            }

            if (GameOverUI != null)
            {
                GameOverUI.SetActive(true);
            }

            if (ControlsUI != null)
            {
                ControlsUI.SetActive(true);
            }
        }
    }
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("StartButton") && gameStarted == true)
        {
            if (GameIsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }

        if (Input.GetButtonDown("Cancel"))
        {
            ControlsUI.SetActive(false);
            MenuCheckUI.SetActive(false);
            myInputField.Select();
        }

        if ((P1Slider.value == MaxPoints || P2Slider.value == MaxPoints || P3Slider.value == MaxPoints || P4Slider.value == MaxPoints))
        {
            GameIsPaused = true;
            checkWinner();
            GameOverUI.SetActive(true);
            GameOverText.GetComponent <Text>().text = "Game Over\n\nThe " + role + " has been promoted";
            StartCoroutine(gameOver());
        }

        switch (PowerUp.pointPowerUp) //If a player collects a point power up
        {
        case 1:                       //Player 1
            P1Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;

        case 2:     //Player 2
            P2Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;

        case 3:     //Player 3
            P3Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;

        case 4:     //Player 4
            P4Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;
        }

        switch (TripWires.playerNum)
        {
        case 1:
            P1Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;

        case 2:
            P2Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;

        case 3:
            P3Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;

        case 4:
            P4Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;
        }

        switch (Dynamite.dynaPlayerNum)
        {
        case 1:
            P1Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;

        case 2:
            P2Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;

        case 3:
            P3Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;

        case 4:
            P4Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;
        }
    }
예제 #11
0
    IEnumerator ExecuteAfterTimePanel(float time, string objectName)
    {
        GameObject.Find(objectName).GetComponent <Animator>().SetBool("Pressed", true);
        yield return(new WaitForSeconds(time));

        GameObject.Find(objectName).GetComponent <Animator>().SetBool("Normal", true);
        switch (objectName)
        {
        case "ExitButton":
            GameExitUI.SetActive(true);
            gameExit = true;
            break;

        case "PauseButton":
            GamePauseUI.SetActive(true);
            gamePause = true;
            break;

        case "ExitButtonGO":
            GameExitUI.SetActive(true);
            gameExit = true;
            GameOverUI.SetActive(false);
            break;

        case "ExitButtonFULL":
            if (GameObject.Find("Head") != null)
            {
                isenabled = false;
                GameObject.Find("Head").GetComponent <HeadTracking>().enabled = false;
            }
            SceneManager.LoadScene("Home");
            break;

        case "RestartButton":
            if (GameObject.Find("Head") != null)
            {
                isenabled = false;
                GameObject.Find("Head").GetComponent <HeadTracking>().enabled = false;
            }
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            break;

        case "RestartButtonGO":
            if (GameObject.Find("Head") != null)
            {
                isenabled = false;
                GameObject.Find("Head").GetComponent <HeadTracking>().enabled = false;
            }
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            break;

        case "BackButton":
            if (gameOver)
            {
                GameExitUI.SetActive(false);
                gameExit = false;
                GameOverUI.SetActive(true);
            }
            else
            {
                GameExitUI.SetActive(false);
                gameExit = false;
            }
            break;

        case "HeadTracking":
            if (isenabled)
            {
                if (GameObject.Find("Head") != null)
                {
                    isenabled = false;
                    GameObject.Find("Main Camera (1)").transform.position = new Vector3(0, 10, 40);
                    GameObject.Find("Main Camera (1)").transform.rotation = Quaternion.Euler(20, 180, 0);;
                }
                GameObject.Find("IconEnable").GetComponent <Image>().color = Color.white;
                isenabled = false;
            }
            else
            {
                if (GameObject.Find("Head") != null)
                {
                    GameObject.Find("Head").GetComponent <HeadTracking>().enabled = true;
                    GameObject.Find("IconEnable").GetComponent <Image>().color    = new Color32(255, 255, 255, 0);
                    isenabled = true;
                }
            }

            break;
        }
    }
예제 #12
0
 // Start is called before the first frame update
 public void EndGame()
 {
     GameOverUI.SetActive(true);
     gameOver = true;
 }
예제 #13
0
 IEnumerator InstaDeath()
 {
     GameOverUI.SetActive(true);
     CharacterControl.gameOver = true;
     yield return(new WaitForFixedUpdate());
 }
예제 #14
0
 private void ShowGameOver()
 {
     GameOverUI.SetActive(true);
     updater.SetActive(false);
 }
예제 #15
0
 private void SetGameOverVisible(bool to)
 {
     GameOverUI.SetActive(to);
 }