private void CheckState()
        {
            switch (_gameState)
            {
            case GameState.START:
                Time.timeScale = 0;
                ResetPlayer();
                _uiManger.OpenPanel(_uiManger.MainMenuPanel);
                _playerManger.FirstPersonController.mouseLook.SetCursorLock(false);
                _playerManger.PlayerController.SetCanPause(true);
                _soundManger.StopSound("mainMusic", SoundManger.SoundType.MUSIC);
                _gameState = GameState.NONE;
                break;

            case GameState.INGAME:
                Time.timeScale = 1;
                _uiManger.OpenPanel(_uiManger.InGamePanel);
                _playerManger.FirstPersonController.mouseLook.SetCursorLock(true);
                _soundManger.PlaySound("mainMusic", SoundManger.SoundType.MUSIC);
                _gameState = GameState.NONE;
                break;

            case GameState.PAUSED:
                Time.timeScale = 0;
                _uiManger.OpenPanel(_uiManger.PausedPanel);
                _playerManger.PlayerController.CanShoot(false);
                _playerManger.FirstPersonController.mouseLook.SetCursorLock(false);
                _soundManger.StopSound("mainMusic", SoundManger.SoundType.MUSIC);
                _gameState = GameState.NONE;
                break;

            case GameState.COMPLETELEVEL:
                _onFinish.HasPlayerFinished = false;
                _hasCompletedLevel          = true;
                OnComplete();
                Time.timeScale = 0;
                _uiManger.OpenPanel(_uiManger.VictoryPanel);
                _playerManger.PlayerController.CanShoot(false);
                _playerManger.PlayerController.SetCanPause(false);
                _playerManger.PlayerController.DestoryBullet();
                _playerManger.FirstPersonController.mouseLook.SetCursorLock(false);
                _soundManger.StopSound("mainMusic", SoundManger.SoundType.MUSIC);
                _gameState = GameState.NONE;
                break;

            case GameState.NONE:
                break;

            default:
                LogMessage("game state not set!");
                break;
            }
        }
Пример #2
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag.Equals("FlamingSkull"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(10);
        }
        if (col.gameObject.tag.Equals("Goblin"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(20);
        }
        if (col.gameObject.tag.Equals("Spikes"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(100);
        }
        if (col.gameObject.tag.Equals("Boss"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(25);
        }

        if (currentHealth <= 0)
        {
            Instantiate(blood, transform.position, Quaternion.identity);
            animator.SetTrigger("dead");
            gameOverText.SetActive(true);
            restartButton.SetActive(true);
        }
    }