コード例 #1
0
    public void PlayerDeath()
    {
        numOfLives--;
        Debug.Log("life lost");

        // If life lost reduce num of lifes and spawn player
        // If num of lives is equal to 0 the game is over
        if (numOfLives == 0)
        {
            UpdateHighScore();

            GameOver();
        }
        else
        {
            StartCoroutine(SpawnPlayer());
            stopped        = true;
            Time.timeScale = 0f;
        }

        // Turn off life game object in game UI if life is lost
        if (numOfLives == 2)
        {
            Life3.SetActive(false);
        }
        else if (numOfLives == 1)
        {
            Life2.SetActive(false);
        }
        else if (numOfLives == 0)
        {
            Life1.SetActive(false);
        }
    }
コード例 #2
0
ファイル: GameBoard.cs プロジェクト: HigherHunter/Pac-Man-3D
    public void Restart()
    {
        if (pacManLives == 2)
        {
            Life3.SetActive(false);
        }
        else if (pacManLives == 1)
        {
            Life2.SetActive(false);
        }

        PacmanMovement.instance.Restart();

        GameObject[] o = GameObject.FindGameObjectsWithTag("Ghost");

        foreach (GameObject ghost in o)
        {
            ghost.transform.GetComponent <Ghost>().Restart();
        }

        readyText.SetActive(true);

        foreach (GameObject ghost in ghosts)
        {
            ghost.transform.GetComponent <Ghost>().canMove = false;
        }
        PacmanMovement.instance.canMove = false;

        StartCoroutine(StartGameAfter(2));
    }
コード例 #3
0
ファイル: GameBoard.cs プロジェクト: HigherHunter/Pac-Man-3D
    public void StartGame()
    {
        foreach (GameObject ghost in ghosts)
        {
            ghost.transform.GetComponent <Ghost>().canMove = false;
        }

        PacmanMovement.instance.canMove = false;

        if (currentLevel == 1)
        {
            audioSource.PlayOneShot(gameStart);
        }

        if (pacManLives == 2)
        {
            Life3.SetActive(false);
        }
        else if (pacManLives == 1)
        {
            Life3.SetActive(false);
            Life2.SetActive(false);
        }

        SpawnDisplayItem();

        StartCoroutine(StartGameAfter(4.2f));
    }
コード例 #4
0
ファイル: WordManagerTutorial.cs プロジェクト: Shahari93/Poof
 void Life(GameObject setactive)
 {
     Life1.SetActive(true);
     Life2.SetActive(true);
     Life3.SetActive(true);
     Life4.SetActive(true);
     Life5.SetActive(true);
 }
コード例 #5
0
    private void setValues()
    {
        //Set all game Lifes
        Life1.SetActive(true);
        Life2.SetActive(true);
        Life3.SetActive(true);

        // Set all flasks
        Clues1.SetActive(true);
        Clues2.SetActive(true);
        Clues3.SetActive(true);
    }
コード例 #6
0
ファイル: Knight.cs プロジェクト: Shahari93/Poof
    void Life(int lifeLeft)
    {
        switch (lifeLeft)
        {
        case 5:
            Life1.SetActive(true);
            Life2.SetActive(true);
            Life3.SetActive(true);
            Life4.SetActive(true);
            Life5.SetActive(true);
            break;

        case 4:
            Life1.SetActive(true);
            Life2.SetActive(true);
            Life3.SetActive(true);
            Life4.SetActive(true);
            Life5.SetActive(false);
            break;

        case 3:
            Life1.SetActive(true);
            Life2.SetActive(true);
            Life3.SetActive(true);
            Life4.SetActive(false);
            Life5.SetActive(false);
            break;

        case 2:
            Life1.SetActive(true);
            Life2.SetActive(true);
            Life3.SetActive(false);
            Life4.SetActive(false);
            Life5.SetActive(false);
            break;

        case 1:
            Life1.SetActive(true);
            Life2.SetActive(false);
            Life3.SetActive(false);
            Life4.SetActive(false);
            Life5.SetActive(false);
            break;

        case 0:
            Life1.SetActive(false);
            Life2.SetActive(false);
            Life3.SetActive(false);
            Life4.SetActive(false);
            Life5.SetActive(false);
            break;
        }
    }
コード例 #7
0
    void Start()
    {
        Life3.SetActive(true);
        Life2.SetActive(true);
        Life1.SetActive(true);

        LifeMessage1.SetActive(false);
        LifeMessage2.SetActive(false);

        ProgressMessage1.SetActive(false);
        ProgressMessage2.SetActive(false);
        ProgressMessage3.SetActive(false);
    }
コード例 #8
0
 void LifeMessages()
 {
     if (player.life == 2)
     {
         Life3.SetActive(false);
         LifeMessage1.SetActive(true);
         StartCoroutine(LifeWait());
     }
     if (player.life == 1)
     {
         Life2.SetActive(false);
         LifeMessage1.SetActive(false);
         LifeMessage2.SetActive(true);
         StartCoroutine(LifeWait());
     }
     if (player.life < 1)
     {
         Life1.SetActive(false);
         SceneManager.LoadScene("GameOver");
     }
 }
コード例 #9
0
    private void LifeSet()
    {
        //If it is the incorrect key, we have to reduce a life and check if we have a gameover
        // Reduce the amount of Lifes in the game
        incorrectPlaySoundMusicSource.Play();
        --currentLife;
        //Update the Lifes and check if there was a gameover
        switch (currentLife)
        {
        case 2:
            Life3.SetActive(false);
            break;

        case 1:
            Life2.SetActive(false);
            break;

        case 0:
            Life1.SetActive(false);
            SceneManager.LoadScene(LOSSSCREEN);
            break;
        }
    }
コード例 #10
0
    void LifeMessages()
    {
        if (player.life == 2 && seenC == false)
        {
            Life3.SetActive(false);
            MessageCaution.SetActive(true);
            StartCoroutine(Contador(1));            //Chama o contador com um código
            seenC = true;
        }

        if (player.life == 1 && seenW == false)
        {
            Life2.SetActive(false);
            MessageCaution.SetActive(false);
            MessageWarning.SetActive(true);
            StartCoroutine(Contador(2));            //Chama o contador com um código
            seenW = true;
        }

        if (player.life == 0)
        {
            SceneManager.LoadScene("GameOver");
        }
    }