void JumpToNext(GameInput.PlayerAction action) //Когда в эфире PlayerInputAction что-то "прозвучит", запускается JumpToNext
    {
        if (LerpCoroutine == null)
        {
            this.hitObject    = GameInput.Instance.HitObject;
            this.hitJumpPoint = hitObject != null?hitObject.GetComponent <JumpPoint>() : null;

            if (!isPlayerFall && onPlatformAfterFall)
            {
                if (hitObject && hitJumpPoint)// && LevelGenerator.Instance.IsRunLevel)//если есть объект на который нажали мышкой
                {
                    lastPusher = hitObject;
                    if (hitJumpPoint.Line - 1 == idLine)
                    {
                        if (action == hitJumpPoint.Action)
                        {
                            speedPusher   = LevelGenerator.Instance.SpeedPusher;
                            LerpCoroutine = StartCoroutine("Lerp");
                            animController.SetJump(action);
                        }
                        else if (hitJumpPoint.Action == GameInput.PlayerAction.question)
                        {
                            GameInput.PlayerAction questionPusherAction = GetQuestionPusherType(hitJumpPoint);
                            if (questionPusherAction == action)
                            {
                                speedPusher   = LevelGenerator.Instance.SpeedPusher;
                                LerpCoroutine = StartCoroutine("Lerp");
                                animController.SetJump(action);
                            }
                            else
                            {
                                PlayerFall();
                            }
                        }
                        else
                        {
                            PlayerFall();
                        }
                    }
                    else
                    {
                        PlayerFall();
                    }
                }
            }
            else if (action == GameInput.PlayerAction.climbAfterFall)
            {
                GrabAfterFall();
            }
        }

        JumpPoint jumpPoint = GameInput.Instance.HitObject != null?hitObject.GetComponent <JumpPoint>() : null;

        if (!jumpPoint)
        {
            PlayerFall();
        }
    }
示例#2
0
 public void SetJump(GameInput.PlayerAction action)
 {
     if (action == GameInput.PlayerAction.climb)
     {
         playerAnimator.SetTrigger("Jump");
     }
     else if (action == GameInput.PlayerAction.jump)
     {
         playerAnimator.SetTrigger("Jump");
     }
     else
     {
         playerAnimator.SetTrigger("DoubleJump");
     }
 }
    public GameInput.PlayerAction GetQuestionPusherType(JumpPoint pusher)
    {
        var diffV = Mathf.Abs(pusher.Collumn - idCollumn);
        var diffH = Mathf.Abs(pusher.Line - idLine);

        GameInput.PlayerAction pusherType = GameInput.PlayerAction.climb;

        if (diffV == 0 && diffH == 1)
        { //подтягивание
            pusherType = GameInput.PlayerAction.climb;
        }
        else if ((diffV == 1 && diffH == 1) || (diffV == 1 && diffH == 0))
        { //прыжок
            pusherType = pusher.Action = GameInput.PlayerAction.jump;
        }
        else if (diffV == 2 || diffH == 2)
        { //двойной прыжок
            pusherType = pusher.Action = GameInput.PlayerAction.doubleJump;
        }

        return(pusherType);
    }