public void Push(Vector2 direction, float force, float duration)
 {
     if (stateManager.GetState() == PlayerState.INVINCIBLE)
     {
         return;
     }
     rb.AddForce(direction.normalized * force, ForceMode2D.Impulse);
     stateManager.ChangeStateTemporaly(PlayerState.PUSHED, duration);
 }
Пример #2
0
    private void Update()
    {
        playerStateManager.Update();
        Do_AnyState();
#if UNITY_EDITOR
        if (playerStateManager.GetState() == null)
        {
            return;
        }
        // 現在のステートをInspecter上に表示
        stateName = playerStateManager.GetState().ToString();
#endif
    }
Пример #3
0
    void Update()
    {
        //if the player's height is below the minimum, bring up menu

        if (character.position.y < GAME_OVER_HEIGHT)
        {
            //pause
            menuManager.ToggleMenu();
            SetGameInfoText();
            SetHighScore();
            RestartGame();
        }

        /*if(RollingCharacterController.state.Equals("dead")){
         *      menuManager.ToggleMenu();
         *      SetGameInfoText();
         *      SetHighScore();
         *      RestartGame();
         *
         *      RollingCharacterController.state = "active";
         * }*/

        if (PlayerStateManager.GetState().Equals("dead"))
        {
            menuManager.ToggleMenu();
            SetGameInfoText();
            SetHighScore();
            RestartGame();

            PlayerStateManager.SetState("active");
            //RollingCharacterController.state = "active";
        }
    }
Пример #4
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        var penguin = collision.gameObject.GetComponent <PenguinMovement>();

        if (penguin != null)
        {
            var tags    = collision.gameObject.GetComponent <Tags>();
            var isBonus = tags != null && tags.Contains("bonus");
            if (stateManager.GetState() == PlayerState.INVINCIBLE && !isBonus)
            {
                Destroy(penguin.gameObject);
                onPenguinKilled?.Invoke();
            }
            else
            {
                onCollide?.Invoke();
            }
        }
    }