コード例 #1
0
ファイル: PlayerController.cs プロジェクト: Alarack/BlazerV2
    private void Update()
    {
        if (!isClimbing)
        {
            currentSpeed = Input.GetAxisRaw("Horizontal") * maxSpeed;
            if (currentSpeed != 0f && !owner.MyAnimator.GetBool("Walking"))
            {
                owner.MyAnimator.SetBool("Walking", true);
            }
            else if (currentSpeed == 0f && owner.MyAnimator.GetBool("Walking"))
            {
                owner.MyAnimator.SetBool("Walking", false);
            }

            if (Platformed && Input.GetAxisRaw("Vertical") < 0)
            {
                isFallingThrough = true;
            }
            if (canClimb && Input.GetAxisRaw("Vertical") > 0 && climbPoint.position.y <= (myLadder.ladderTop - 0.01f))
            {
                myLadder.GrabLadder(gameObject);
            }
            if (canClimb && Input.GetAxisRaw("Vertical") < 0 && climbPoint.position.y >= (myLadder.ladderBot + 0.01f))
            {
                myLadder.GrabLadder(gameObject);
            }
        }
        if (isClimbing)
        {
            if (Input.GetAxisRaw("Vertical") > 0)
            {
                if (climbPoint.position.y > (myLadder.ladderTop - 0.01f))
                {
                    myLadder.LetGoLadder(gameObject);
                }
                else
                {
                    Debug.Log("Climbing Up");
                    myLadder.ClimbUp(myClimber);
                    myBody.position = new Vector2(myLadder.transform.position.x, myBody.position.y);
                    myBody.velocity = new Vector2(0f, ascendSpeed);
                }
            }
            if (Input.GetAxisRaw("Vertical") < 0)
            {
                if (climbPoint.position.y < (myLadder.ladderBot + 0.01f))
                {
                    myLadder.LetGoLadder(gameObject);
                }
                else
                {
                    Debug.Log("Climbing Down");
                    myLadder.ClimbDown(myClimber);
                    myBody.position = new Vector2(myLadder.transform.position.x, myBody.position.y);
                    myBody.velocity = new Vector2(0f, -descendSpeed);
                }
            }
            if (Input.GetAxisRaw("Vertical") == 0)
            {
                //Debug.Log("Clinging On");
                myLadder.ClimbHold(myClimber);
                myBody.position = new Vector2(myLadder.transform.position.x, myBody.position.y);
                myBody.velocity = Vector2.zero;
            }
        }


        CheckFacing();
        TryJump();
        Fallthrough(isFallingThrough);
        fallthroughTimer.UpdateClock();

        if (!Grounded && !Platformed)
        {
            owner.MyAnimator.SetBool("InAir", true);
        }
        if (Grounded || Platformed)
        {
            owner.MyAnimator.SetBool("InAir", false);
        }

        //Debug.Log(Grounded + " is the status of Grounded");
        //Debug.Log(Platformed + " is the status of platformed");
        FindNearestLevelObject();

        /*--Use Level Object--*/

        //Debug.Log("What");
        if (Input.GetKeyDown(KeyCode.F) && currLvlObj != null && currLvlObj.UseRestrictionsMet())
        {
            currLvlObj.ActivationFunction();
        }
        if (Input.GetKeyDown(KeyCode.O))
        {
            Debug.Log("5 Keys Added and 20 Dollars Added");
            GetComponent <Entity>().stats.ApplyUntrackedMod(Constants.BaseStatType.Keys, 5, GetComponent <Entity>());
            GetComponent <Entity>().stats.ApplyUntrackedMod(Constants.BaseStatType.Money, 20, GetComponent <Entity>());
        }
    }