Пример #1
0
    // Update is called once per frame
    void Update()
    {
        currentState = anim.GetCurrentAnimatorStateInfo(0);
        anim.SetFloat(yVeloID, rb.velocity.y);

        // rotate based on position relative to opponent
        if (facingRight && transform.eulerAngles != Vector3.zero)
        {
            transform.eulerAngles = Vector3.zero;
        }
        else if (!facingRight && transform.eulerAngles != new Vector3(0, 180, 0))
        {
            transform.eulerAngles = new Vector3(0, 180, 0);
        }

        if (transform.position.x < -9.935f && !Actions.grabbed)
        {
            transform.position = new Vector3(-9.935f, transform.position.y, transform.position.z);
        }
        else if (transform.position.x > 9.935f && !Actions.grabbed)
        {
            transform.position = new Vector3(9.935f, transform.position.y, transform.position.z);
        }

        if (Actions.acceptMove && Actions.standing)
        {
            if (opponent.transform.position.x < transform.position.x - .1f)
            {
                facingRight = false;
            }
            else if (opponent.transform.position.x > transform.position.x + .1f)
            {
                facingRight = true;
            }
        }

        if (anim.GetBool(KOID) || RoundManager.lockInputs)
        {
            anim.SetBool(crouchID, false);
            anim.SetBool(walkFID, false);
            anim.SetBool(walkBID, false);
            anim.SetBool(runID, false);
        }

        if (!Actions.airborne)
        {
            pushBox.offset = pushCenter;
            pushBox.size   = pushSize;
        }
        else if (currentState.IsName("WallStick"))
        {
            pushBox.offset = pushCenter;
            pushBox.size   = pushSize;
        }
        else
        {
            anim.SetBool(crouchID, false);
            anim.SetBool(runID, false);

            pushBox.offset = airPushCenter;
            pushBox.size   = airPushSize;

            if (rb.velocity.y < 0)
            {
                pushBox.offset = pushCenter;
                pushBox.size   = pushSize;
            }

            if (jumps == 0)
            {
                jumps = 1;
            }
        }

        pushTrigger.offset = new Vector2(pushBox.offset.x, pushBox.offset.y);
        pushTrigger.size   = new Vector2(pushBox.size.x, pushBox.size.y + .3f);

        if (transform.position.x < -9.935f)
        {
            transform.position = new Vector3(-9.935f, transform.position.y, transform.position.z);
        }
        else if (transform.position.x > 9.935f)
        {
            transform.position = new Vector3(9.935f, transform.position.y, transform.position.z);
        }

        if (transform.position.y < minPosY)
        {
            transform.position = new Vector3(transform.position.x, minPosY, transform.position.z);
            Actions.airborne   = false;
        }
        else if (transform.position.y > 1.2f)
        {
            Actions.airborne = true;
        }

        if (RoundManager.gameActive && !RoundManager.lockInputs && !HitDetect.pauseScreen.isPaused)
        {
            if (HitDetect.hitStop <= 0)
            {
                if ((MaxInput.GetAxis(Vertical) < 0 && Actions.acceptMove && Actions.standing) || (anim.GetBool(crouchID) && !Actions.acceptMove && Actions.standing))
                {
                    anim.SetBool(crouchID, true);
                }
                else
                {
                    anim.SetBool(crouchID, false);
                }

                if (Actions.acceptMove && Actions.standing && !anim.GetBool(crouchID) && ((MaxInput.GetAxis(Horizontal) > 0 && facingRight) || (MaxInput.GetAxis(Horizontal) < 0 && !facingRight)) && !Actions.airborne && !anim.GetBool(runID))
                {
                    anim.SetBool(walkFID, true);
                }
                else
                {
                    anim.SetBool(walkFID, false);
                }

                if (Actions.acceptMove && Actions.standing && !anim.GetBool(crouchID) && ((MaxInput.GetAxis(Horizontal) < 0 && facingRight) || (MaxInput.GetAxis(Horizontal) > 0 && !facingRight)) && !Actions.airborne && !backDash)
                {
                    if ((GameObject.Find("PracticeModeManager").GetComponent <PracticeMode>().dummyState == "StandGuard" ||
                         GameObject.Find("PracticeModeManager").GetComponent <PracticeMode>().dummyState == "GuardAll") && transform.parent.name == "Player2")
                    {
                        anim.SetBool(walkBID, false);
                    }
                    else
                    {
                        anim.SetBool(walkBID, true);
                    }
                }
                else
                {
                    anim.SetBool(walkBID, false);
                }

                DoubleTapActions();

                if ((Actions.acceptMove && jumps == 0 && MaxInput.GetAxis(Vertical) > 0 && Actions.standing) ||
                    (Actions.jumpCancel && jumps < maxJumps && MaxInput.GetAxis(Vertical) > 0 && !vertAxisInUse))
                {
                    if (jumps > 0)
                    {
                        sigil.GetComponent <Sigil>().colorChange = 0;
                        sigil.GetComponent <Sigil>().scaleChange = 0;
                        sigil.transform.position    = new Vector3(transform.position.x, transform.position.y + .5f * pushBox.offset.y - .5f * pushBox.size.y, transform.position.z);
                        sigil.transform.eulerAngles = new Vector3(75, 0, 0);
                    }

                    Actions.DisableAll();
                    pushBox.isTrigger = true;
                    jumps++;
                    jumping            = .3f;
                    Actions.recovering = true;


                    if (MaxInput.GetAxis(Horizontal) > 0 && !anim.GetBool(runID))
                    {
                        jumpRight = true;
                        sigil.transform.eulerAngles = new Vector3(60, -40, 0);
                    }
                    else if (MaxInput.GetAxis(Horizontal) < 0 && !anim.GetBool(runID))
                    {
                        jumpLeft = true;
                        sigil.transform.eulerAngles = new Vector3(60, 40, 0);
                    }


                    vertAxisInUse = true;
                }
            }
        }
        else
        {
            Actions.DisableAll();
            Actions.DisableBlitz();
        }

        if (currentState.IsName("GroundBounce") || Actions.airborne)
        {
            anim.ResetTrigger(KDID);
        }
        if (MaxInput.GetAxisRaw(Vertical) == 0)
        {
            vertAxisInUse = false;
        }
        if (MaxInput.GetAxisRaw(Horizontal) == 0)
        {
            horiAxisInUse   = false;
            justDefenseTime = 5;
        }

        if ((opponent.position.x > transform.position.x && MaxInput.GetAxis(Horizontal) < 0) || (opponent.position.x < transform.position.x && MaxInput.GetAxis(Horizontal) > 0))
        {
            justDefenseTime--;
        }

        Blocking();
        WallStick();
    }