コード例 #1
0
    public void RestartLevel()
    {
        Timer.Cancel(timer);
        Timer.Cancel(frightTimer);

        if (player_dead && !gameOverActive)
        {
            if (lifeManager.LifesLeft > 0)
            {
                lifeManager.RemoveLife();
            }
            else
            {
                GameOverPanel.SetActive(true);
                gameOverActive = true;

                return;
            }
        }

        if (gameOverActive)
        {
            GameOverPanel.SetActive(false);
            gameOverActive = false;

            Pacman.score = 0;

            lifeManager.AddLife();
            lifeManager.AddLife();
            lifeManager.AddLife();
        }

        Pacman.Reset();
        Pacman.paused = true;
        player_dead   = false;
        waveState     = State.Idle;
        wave          = 0;

        for (int i = 0; i < Ghosts.Count; i++)
        {
            Ghosts[i].Reset();
        }

        timer = Timer.Register(3f, WaveUpdate);
        tilemap.SetTilesBlock(tilemap.cellBounds, startingTilemapState);
    }
コード例 #2
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        Transform t = transform;

        Destroy(gameObject);

        Instantiate(hitEffectPrefab, t.position, t.rotation);

        LifeManager lm = collision.gameObject.GetComponent <LifeManager>();

        if (lm != null)
        {
            lm.AddLife(-dano);
        }
    }