示例#1
0
    /// <summary>
    /// プレイヤーの入力を受け取る
    /// </summary>
    private void UpdateInput()
    {
        if (!this.isTitleScene)
        {
            this.inputVelocity = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        }
        else
        {
            this.inputVelocity = new Vector2(Input.GetAxis("Horizontal"), 0f);
        }

        if (this.inputVelocity.magnitude > 1f)
        {
            this.inputVelocity = this.inputVelocity.normalized;
        }

        if (this.currentState == E_State.Standing && this.inputVelocity != Vector2.zero)
        {
            this.currentState = E_State.Running;
        }
        switch (this.currentState)
        {
        case E_State.Standing:
        case E_State.Running:
            if (Input.GetButtonDown("Jump"))
            {
                this.waitingAction = E_ActionFlag.NormalJump;
            }
            else if (Input.GetButtonDown("SpinJump"))
            {
                this.waitingAction = E_ActionFlag.SpinJump;
            }
            else if (Input.GetButtonDown("BackFlip"))
            {
                this.waitingAction = E_ActionFlag.BackFlip;
            }
            break;

        case E_State.StickingWall:
            if (Input.GetButtonDown("Jump"))
            {
                this.waitingAction = E_ActionFlag.WallKick;
            }
            else if (Input.GetButtonDown("HipDrop"))
            {
                this.waitingAction = E_ActionFlag.HipDrop;
            }
            break;

        case E_State.JumpToTop:
        case E_State.TopOfJump:
            if (!this._isGrounded && Input.GetButtonDown("HipDrop"))
            {
                this.waitingAction        = E_ActionFlag.HipDrop;
                this.checkPressJumpButton = false;
                //this.pressJumpButtonFrame = 0;
                this.countFrameOfGroundFromHipDrop = 0;
                this.IsHipDropping  = true;
                this.countJumpTime  = 0f;
                this.countJumpLevel = 0;
            }
            else if (this.checkPressJumpButton)
            {
                if (Input.GetButton("Jump"))
                {
                    this.countJumpTime += Time.deltaTime;
                    if (this.countJumpTime > 0.03f && this.countJumpLevel == 0)
                    {
                        this._velocity.y += this.jumpSecondVerticalSpeed;
                        this.countJumpLevel++;
                    }
                    if (this.countJumpTime > 0.06f && this.countJumpLevel == 1)
                    {
                        this._velocity.y += this.jumpThirdVerticalSpeed;
                        this.countJumpLevel++;
                    }

                    /*this.pressJumpButtonFrame++;
                     * if (this.pressJumpButtonFrame == 4) this._velocity.y += this.jumpSecondVerticalSpeed;
                     * if (this.pressJumpButtonFrame == 7) this._velocity.y += this.jumpThirdVerticalSpeed;*/
                }
                else
                {
                    this.checkPressJumpButton = false;
                    this.countJumpTime        = 0f;
                    this.countJumpLevel       = 0;
                    //this.pressJumpButtonFrame = 0;
                }
            }
            break;

        case E_State.SpinJumping:
            if (Input.GetButtonDown("HipDrop"))
            {
                this.waitingAction = E_ActionFlag.HipDrop;
            }
            else if (this.checkPressJumpButton)
            {
                if (Input.GetButton("SpinJump"))
                {
                    this.countJumpTime += Time.deltaTime;
                    if (this.countJumpTime > 0.03f && this.countJumpLevel == 0)
                    {
                        this._velocity.y += this.jumpSecondVerticalSpeed;
                        this.countJumpLevel++;
                    }
                    if (this.countJumpTime > 0.06f && this.countJumpLevel == 1)
                    {
                        this._velocity.y += this.jumpThirdVerticalSpeed;
                        this.countJumpLevel++;
                    }

                    /*this.pressJumpButtonFrame++;
                     * if (this.pressJumpButtonFrame == 4) this._velocity.y += this.jumpSecondVerticalSpeed;
                     * if (this.pressJumpButtonFrame == 7) this._velocity.y += this.jumpThirdVerticalSpeed;*/
                }
                else
                {
                    this.checkPressJumpButton = false;
                    this.countJumpTime        = 0f;
                    this.countJumpLevel       = 0;
                    //this.pressJumpButtonFrame = 0;
                }
            }
            break;

        case E_State.Falling:
        case E_State.BackFliping:
            if (Input.GetButtonDown("HipDrop"))
            {
                this.waitingAction = E_ActionFlag.HipDrop;
            }
            break;
        }

        if (this.currentState == E_State.Standing)
        {
            this.noInputCountTime += Time.deltaTime;
        }
        else
        {
            this.noInputCountTime = 0f;
        }

        if (this.noInputCountTime > 10f)
        {
            if (SceneManager.GetActiveScene().name != "Title")
            {
                this.PlayIdleVoice();
            }
            this.noInputCountTime = 0f;
        }
    }
示例#2
0
 /// <summary>
 /// 毎フレームUpdateで最初に呼ばれる初期化処理
 /// </summary>
 private void FirstUpdateInit()
 {
     this.waitingAction = E_ActionFlag.None;
 }