void Update()
    {
        currentState = anim.GetCurrentAnimatorStateInfo(0);
        anim.ResetTrigger(IDRec);

        if (Move.HitDetect.hitStun > 0)
        {
            anim.ResetTrigger(ID5L);
            anim.ResetTrigger(ID2L);
            anim.ResetTrigger(ID5M);
            anim.ResetTrigger(ID2M);
            anim.ResetTrigger(ID5H);
            anim.ResetTrigger(ID2H);
            anim.ResetTrigger(ID5B);
            anim.ResetTrigger(ID2B);
            anim.ResetTrigger(IDThrow);

            /*anim.ResetTrigger(IDBloodBrave);
             * anim.ResetTrigger(IDPatissiere);
             * anim.ResetTrigger(IDHeadRush);
             * anim.ResetTrigger(IDToaster);*/
        }

        if (lightButton > 0)
        {
            lightButton -= Time.deltaTime;
        }
        else
        {
            lightButton = 0;
            anim.ResetTrigger(ID5L);
            anim.ResetTrigger(ID2L);
        }

        if (mediumButton > 0)
        {
            mediumButton -= Time.deltaTime;
        }
        else
        {
            mediumButton = 0;
            anim.ResetTrigger(ID5M);
            anim.ResetTrigger(ID2M);
        }

        if (heavyButton > 0)
        {
            heavyButton -= Time.deltaTime;
        }
        else
        {
            heavyButton = 0;
            anim.ResetTrigger(ID5H);
            anim.ResetTrigger(ID2H);
        }

        if (breakButton > 0)
        {
            breakButton -= Time.deltaTime;
        }
        else
        {
            breakButton = 0;
            anim.ResetTrigger(ID5B);
            anim.ResetTrigger(ID2B);
            anim.ResetTrigger(ID3B);
        }

        if (dir1 > 0)
        {
            dir1 -= Time.deltaTime;
        }
        if (dir2 > 0)
        {
            dir2 -= Time.deltaTime;
        }
        if (dir3 > 0)
        {
            dir3 -= Time.deltaTime;
        }
        if (dir4 > 0)
        {
            dir4 -= Time.deltaTime;
        }
        if (dir6 > 0)
        {
            dir6 -= Time.deltaTime;
        }
        if (QCF > 0)
        {
            QCF -= Time.deltaTime;
        }
        if (QCB > 0)
        {
            QCB -= Time.deltaTime;
        }
        if (HCB > 0)
        {
            HCB -= Time.deltaTime;
        }
        if (DP > 0)
        {
            DP -= Time.deltaTime;
        }


        //record buttons pressed
        if (MaxInput.GetButtonDown(Light) && !anim.GetCurrentAnimatorStateInfo(0).IsName("ForsythiaAim"))
        {
            lightButton = bufferTime;
        }
        if (MaxInput.GetButtonDown(Medium))
        {
            mediumButton = bufferTime;
        }
        if (MaxInput.GetButtonDown(Heavy))
        {
            heavyButton = bufferTime;
        }
        if (MaxInput.GetButtonDown(Break) && !anim.GetCurrentAnimatorStateInfo(0).IsName("ForsythiaAim"))
        {
            breakButton = bufferTime;
        }
        if (MaxInput.GetButtonDown(LM))
        {
            lightButton  = bufferTime;
            mediumButton = bufferTime;
        }
        if (MaxInput.GetButtonDown(HB))
        {
            heavyButton = bufferTime;
            breakButton = bufferTime;
        }
        if (MaxInput.GetButtonDown(LB))
        {
            lightButton = bufferTime;
            breakButton = bufferTime;
        }
        if (MaxInput.GetButtonDown(MH))
        {
            mediumButton = bufferTime;
            heavyButton  = bufferTime;
        }
        QCFCheck();
        QCBCheck();
        HCBCheck();
        DPCheck();

        //record directional input
        //float dir# corresponds to numpad notation for character facing to the right
        //special moves' directional input for DHA will never use 7 8 or 9, and 5 is the neutral position so no variables for those directions is necessary,

        /*           up
         *           ^
         |
         |         7 8 9
         | left <--- 4 5 6 ---> right
         |         1 2 3
         |
         |           v
         |          down
         */
        // pressing left on the d pad or stick, considered backward if facing right, considered forward if facing left
        if (MaxInput.GetAxis(Horizontal) < 0 && MaxInput.GetAxis(Vertical) < 0)
        {
            if (Move.transform.position.x < Move.opponent.position.x)
            {
                // 1 : pressing down-back
                dir1 = directionBufferTime;
            }
            else if (Move.transform.position.x > Move.opponent.position.x)// 3 : pressing down-forward
            {
                dir3 = directionBufferTime;
            }
        }
        else if (MaxInput.GetAxis(Horizontal) > 0 && MaxInput.GetAxis(Vertical) < 0)
        {
            if (Move.transform.position.x < Move.opponent.position.x)
            {
                // pressing down-forward
                dir3 = directionBufferTime;
            }
            else if (Move.transform.position.x > Move.opponent.position.x)
            {
                // pressing down-back
                dir1 = directionBufferTime;
            }
        }
        else if (MaxInput.GetAxis(Horizontal) < 0)
        {
            if (Move.transform.position.x < Move.opponent.position.x)
            {
                // pressing back if facing right
                dir4 = directionBufferTime;
            }
            else if (Move.transform.position.x > Move.opponent.position.x)
            {
                // pressing forward if facing left
                dir6 = directionBufferTime;
            }
        }
        // pressing right on the d pad/stick, considered forward if facing right, considered backward if facing left
        else if (MaxInput.GetAxis(Horizontal) > 0)
        {
            if (Move.transform.position.x < Move.opponent.position.x)
            {
                //forward if facing right
                dir6 = directionBufferTime;
            }
            else if (Move.transform.position.x > Move.opponent.position.x)
            {
                //back if facing left
                dir4 = directionBufferTime;
            }
        }
        else if (MaxInput.GetAxis(Vertical) < 0)
        {
            //only pressing down
            dir2 = directionBufferTime;
        }

        if (Actions.acceptMove || currentState.IsName("StandUp") || currentState.IsName("Jump"))
        {
            //refresh possible moves when in certain states
            RefreshMoveList();
        }

        //dizzy state, mash buttons to get out of it faster
        if ((dizzyTime == 0 && anim.GetBool(dizzyID)) || anim.GetBool(KOID))
        {
            dizzyTime = 300;
        }
        else if (!anim.GetBool(dizzyID) || CharProp.currentHealth == CharProp.maxHealth)
        {
            dizzyTime = 0;
        }

        if (dizzyTime > 0)
        {
            anim.SetBool(dizzyID, true);
            dizzyTime--;
            if (MaxInput.GetButtonDown(Light))
            {
                dizzyTime -= 5;
            }
            if (MaxInput.GetButtonDown(Medium))
            {
                dizzyTime -= 5;
            }
            if (MaxInput.GetButtonDown(Heavy))
            {
                dizzyTime -= 5;
            }
            if (MaxInput.GetButtonDown(Break))
            {
                dizzyTime -= 5;
            }
        }

        if (dizzyTime <= 0 && anim.GetBool(dizzyID))
        {
            anim.SetBool(dizzyID, false);
            CharProp.refill     = true;
            CharProp.comboTimer = 0;
        }

        //aerial recovery, press a button after hitstun ends
        if ((currentState.IsName("HitAir") || currentState.IsName("FallForward") || currentState.IsName("SweepHit") || currentState.IsName("LaunchTransition") ||
             currentState.IsName("LaunchFall") || currentState.IsName("Unstick")) && Move.HitDetect.hitStun <= 0 &&
            Move.transform.position.y > 1.1f && (lightButton > 0 || mediumButton > 0 || heavyButton > 0 || breakButton > 0))
        {
            anim.SetTrigger(IDRec);
        }

        if (currentState.IsName("AirRecovery"))
        {
            lightButton  = 0;
            mediumButton = 0;
            heavyButton  = 0;
            breakButton  = 0;
        }


        if (blitzActive > 0 && Hitboxes.HitDetect.OpponentDetector.Actions.blitzed <= 0)
        {
            Hitboxes.BlitzCancel();
            blitzActive -= Time.deltaTime;
        }
        else if (Hitboxes.HitDetect.OpponentDetector.Actions.blitzed > 0)
        {
            blitzActive = 0;
        }

        //blitz cancel mechanic, return to neutral position to extend combos, cancel recovery, make character safe, etc. at the cost of one hit of armor
        if ((Actions.blitzCancel && Move.HitDetect.hitStun <= 0 && Move.HitDetect.blockStun <= 0 && CharProp.armor >= 1) &&
            Move.HitDetect.hitStop <= 0 && heavyButton > 0 && mediumButton > 0 && Mathf.Abs(heavyButton - mediumButton) <= .1f)
        {
            RefreshMoveList();
            BlitzWave.SetTrigger(IDBlitz);
            Hitboxes.BlitzCancel();
            Actions.landingLag = 0;

            ForsythiaReticle.SetActive(false);
            anim.SetBool(runID, false);
            BlitzImage.sprite = anim.gameObject.GetComponent <SpriteRenderer>().sprite;
            BlitzImage.color  = new Color(BlitzImage.color.r, BlitzImage.color.g, BlitzImage.color.b, .75f);
            BlitzEffect.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
            BlitzEffect.transform.rotation = transform.rotation;

            anim.SetTrigger(IDBlitz);
            if (Actions.airborne && MaxInput.GetAxis(Vertical) < 0)
            {
                Move.rb.velocity = Vector2.zero;
                Move.rb.AddForce(new Vector2(0, -4), ForceMode2D.Impulse);
            }
            else if (Actions.airborne && MaxInput.GetAxis(Horizontal) < 0)
            {
                if (Move.rb.velocity.y < 0)
                {
                    Move.rb.velocity = Vector2.zero;
                }
                else
                {
                    Move.rb.velocity = new Vector2(0, Move.rb.velocity.y);
                }
                Move.rb.AddForce(new Vector2(-2.7f, 0), ForceMode2D.Impulse);
            }
            else if (Actions.airborne && MaxInput.GetAxis(Horizontal) > 0)
            {
                if (Move.rb.velocity.y < 0)
                {
                    Move.rb.velocity = Vector2.zero;
                }
                else
                {
                    Move.rb.velocity = new Vector2(0, Move.rb.velocity.y);
                }
                Move.rb.AddForce(new Vector2(2.7f, 0), ForceMode2D.Impulse);
            }

            if (Move.HitDetect.comboCount > 0)
            {
                Move.HitDetect.specialProration *= .85f;
            }

            //cost for executing blitz cancel
            CharProp.armor--;
            CharProp.durability            = 70;
            blitzActive                    = 5f / 60f;
            CharProp.durabilityRefillTimer = 0;
            heavyButton                    = 0;
            mediumButton                   = 0;
        }
        // basic throw performed by pressing both light and break attack
        else if (Actions.acceptMove && lightButton > 0 && breakButton > 0 && Move.HitDetect.hitStop <= 0)
        {
            Hitboxes.ClearHitBox();
            if (Actions.standing)
            {
                anim.SetTrigger(IDThrow);
                if (dir4 == directionBufferTime)
                {
                    Actions.backThrow = true;
                }
                else
                {
                    Actions.backThrow = false;
                }

                Actions.throwTech = true;
            }
        }
        else if (Actions.acceptSuper && lightButton > 0 && mediumButton > 0 && Move.HitDetect.hitStop <= 0 && QCF > 0 && CharProp.armor >= 2 && Actions.standing)
        {
            Move.jumping = 0;
            Hitboxes.ClearHitBox();
            // Forsythia Marduk super attack, executed by doing a QCF and pressing L and M together
            anim.SetTrigger(IDForsythia);
            CharProp.armor                -= 2;
            CharProp.durability            = 70;
            CharProp.durabilityRefillTimer = 0;
            lightButton  = 0;
            mediumButton = 0;
            QCF          = 0;
        }
        else if (Actions.acceptSpecial && (heavyButton > 0 || breakButton > 0) && Move.HitDetect.hitStop <= 0 && DP > 0)
        {
            Move.jumping = 0;
            Hitboxes.ClearHitBox();
            // Heaven Climber special attack, executed by doing a DP and pressing H or B
            if (Actions.airborne || heavyButton > 0)
            {
                anim.SetTrigger(IDHeavenClimberH);
            }
            else
            {
                anim.SetTrigger(IDHeavenClimberB);
            }
            Actions.TurnAroundCheck();
            heavyButton = 0;
            breakButton = 0;
            DP          = 0;
        }
        else if (Actions.acceptSpecial && breakButton > 0 && Move.HitDetect.hitStop <= 0 && QCB > 0 && Actions.airborne && Hitboxes.HitDetect.Actions.Move.transform.position.y > 1.5f)
        {
            Move.jumping = 0;
            Hitboxes.ClearHitBox();
            // Starfall special attack, executed by doing a QCB and pressing B
            anim.SetTrigger(IDStarfall);
            Actions.TurnAroundCheck();
            breakButton = 0;
            QCB         = 0;
        }
        else if (Actions.acceptSpecial && mediumButton > 0 && Move.HitDetect.hitStop <= 0 && QCF > 0 && !Actions.airborne)
        {
            Move.jumping = 0;
            Hitboxes.ClearHitBox();
            // Level Hell special attack, executed by doing a QCF and pressing M
            anim.SetTrigger(IDLevelHell);
            Actions.TurnAroundCheck();
            mediumButton = 0;
            QCF          = 0;
        }
        else if (Actions.acceptBreak && breakButton > 0 && Move.HitDetect.hitStop <= 0)
        {
            //break attacks
            if (Actions.standing)
            {
                if (MaxInput.GetAxis(Vertical) < 0)
                {
                    if (CrouchB)
                    {
                        anim.SetTrigger(ID2B);
                        CrouchB = false;
                        Actions.TurnAroundCheck();
                        Hitboxes.ClearHitBox();
                    }
                }
                else if (dir3 == directionBufferTime)
                {
                    if (DFB)
                    {
                        anim.SetTrigger(ID3B);
                        DFB = false;
                        anim.SetBool(runID, false);
                        Hitboxes.ClearHitBox();
                    }
                }
                else
                {
                    if (StandB)
                    {
                        anim.SetTrigger(ID5B);
                        StandB = false;
                        Actions.TurnAroundCheck();
                        Hitboxes.ClearHitBox();
                    }
                }
            }
            else
            {
                if (JumpB)
                {
                    anim.SetTrigger(ID5B);
                    JumpB = false;
                    Hitboxes.ClearHitBox();
                }
            }
            Hitboxes.ClearHitBox();
            breakButton = 0;
        }
        else if (Actions.acceptHeavy && heavyButton > 0 && Move.HitDetect.hitStop <= 0)
        {
            //heavy attacks
            if (Actions.standing)
            {
                if (MaxInput.GetAxis(Vertical) < 0)
                {
                    if (CrouchH)
                    {
                        anim.SetTrigger(ID2H);
                        CrouchH = false;
                    }
                }
                else
                {
                    if (StandH)
                    {
                        anim.SetTrigger(ID5H);
                        StandH = false;
                    }
                }
            }
            else
            {
                if (JumpH)
                {
                    anim.SetTrigger(ID5H);
                    JumpH = false;
                }
            }
            Hitboxes.ClearHitBox();
            heavyButton = 0;
        }
        else if (Actions.acceptMedium && mediumButton > 0 && Move.HitDetect.hitStop <= 0)
        {
            //medium attacks
            if (Actions.standing)
            {
                if (MaxInput.GetAxis(Vertical) < 0)
                {
                    if (CrouchM)
                    {
                        anim.SetTrigger(ID2M);
                        CrouchM = false;
                    }
                }
                else
                {
                    if (StandM)
                    {
                        anim.SetTrigger(ID5M);
                        StandM = false;
                    }
                }
            }
            else
            {
                if (JumpM)
                {
                    anim.SetTrigger(ID5M);
                    JumpM = false;
                }
            }
            Hitboxes.ClearHitBox();
            mediumButton = 0;
        }
        else if (Actions.acceptLight && lightButton > 0 && Move.HitDetect.hitStop <= 0)
        {
            //light attacks
            if (Actions.standing)
            {
                if (MaxInput.GetAxis(Vertical) < 0)
                {
                    if (CrouchL > 0)
                    {
                        anim.SetTrigger(ID2L);
                        CrouchL--;
                    }
                }
                else
                {
                    if (StandL)
                    {
                        if (CrouchL < 3)
                        {
                            CrouchL = 0;
                        }
                        anim.SetTrigger(ID5L);
                        StandL = false;
                    }
                }
            }
            else
            {
                if (JumpL > 0)
                {
                    anim.SetTrigger(ID5L);
                    JumpL--;
                }
            }
            Hitboxes.ClearHitBox();
            lightButton = 0;
        }

        // ACH character specific, can charge or delay certain special attacks
        if (MaxInput.GetButton(Break))
        {
            anim.SetBool(BreakCharge, true);

            if (currentState.IsName("StarfallDelay"))
            {
                Hitboxes.HitDetect.rb.gravityScale = .35f * Hitboxes.HitDetect.Actions.originalGravity;
            }
        }
        else
        {
            anim.SetBool(BreakCharge, false);
        }
    }
Beispiel #2
0
    void FixedUpdate()
    {
        //walking
        if (anim.GetBool(walkFID) && !anim.GetBool(crouchID))
        {
            if (facingRight)
            {
                rb.velocity = new Vector2(walkSpeed, rb.velocity.y);
            }
            else
            {
                rb.velocity = new Vector2(-walkSpeed, rb.velocity.y);
            }
        }
        else if (anim.GetBool(walkBID) && !anim.GetBool(crouchID))
        {
            if (facingRight)
            {
                rb.velocity = new Vector2(-walkBackSpeed, rb.velocity.y);
            }
            else
            {
                rb.velocity = new Vector2(walkBackSpeed, rb.velocity.y);
            }
        }

        if (backDash)
        {
            if (facingRight && rb.velocity.x > -walkBackSpeed)
            {
                rb.velocity = new Vector2(-walkBackSpeed, rb.velocity.y);
            }
            else if (!facingRight && rb.velocity.x < walkBackSpeed)
            {
                rb.velocity = new Vector2(walkBackSpeed, rb.velocity.y);
            }

            if (facingRight)
            {
                rb.AddForce(new Vector2(-backDashForce, .6f * backDashForce), ForceMode2D.Impulse);
            }
            else
            {
                rb.AddForce(new Vector2(backDashForce, .6f * backDashForce), ForceMode2D.Impulse);
            }
            backDash = false;
        }

        //Jump logic
        if (jumping > 0 && anim.GetFloat("AnimSpeed") > 0 && HitDetect.hitStun == 0 && HitDetect.blockStun == 0)
        {
            anim.SetTrigger(jumpID);
            Actions.TurnAroundCheck();
            if (Actions.airborne)
            {
                rb.velocity = new Vector2(0, 0);
            }
            else
            {
                rb.velocity = new Vector2(.5f * rb.velocity.x, 0);
            }
            Actions.airborne = true;
            Actions.standing = false;

            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);
            }

            if (!anim.GetBool(runID))
            {
                rb.velocity = new Vector2(0, rb.velocity.y);
            }

            if (jumpRight)
            {
                rb.velocity = new Vector2(0, rb.velocity.y);
                rb.AddForce(new Vector2(.3f * jumpPower, 0), ForceMode2D.Impulse);
            }
            else if (jumpLeft)
            {
                rb.velocity = new Vector2(0, rb.velocity.y);
                rb.AddForce(new Vector2(-.3f * jumpPower, 0), ForceMode2D.Impulse);
            }

            rb.AddForce(new Vector2(0, jumpPower), ForceMode2D.Impulse);

            jumping   = 0;
            jumpRight = false;
            jumpLeft  = false;
            Actions.EnableAll();
            Actions.airborne = true;
        }
        else
        {
            if (HitDetect.hitStun > 0 && HitDetect.blockStun > 0)
            {
                jumping   = 0;
                jumpRight = false;
                jumpLeft  = false;
            }
            else
            {
                jumping -= Time.fixedDeltaTime;
            }
        }

        //Run acceleration
        if (anim.GetBool(runID) && ((MaxInput.GetAxis(Horizontal) > 0 && facingRight) || (MaxInput.GetAxis(Horizontal) < 0 && !facingRight)) && !anim.GetBool(crouchID))
        {
            if (facingRight && rb.velocity.x < walkSpeed)
            {
                rb.velocity = new Vector2(walkSpeed, rb.velocity.y);
            }
            else if (!facingRight && rb.velocity.x > -walkSpeed)
            {
                rb.velocity = new Vector2(-walkSpeed, rb.velocity.y);
            }

            if (Actions.blitzed > 0)
            {
                if (facingRight)
                {
                    rb.AddForce(new Vector2(runAcceleration, 0), ForceMode2D.Impulse);
                }
                else
                {
                    rb.AddForce(new Vector2(-runAcceleration, 0), ForceMode2D.Impulse);
                }
            }
            else
            {
                if (facingRight)
                {
                    rb.AddForce(new Vector2(runAcceleration, 0), ForceMode2D.Impulse);
                }
                else
                {
                    rb.AddForce(new Vector2(-runAcceleration, 0), ForceMode2D.Impulse);
                }
            }
        }
        else
        {
            anim.SetBool(runID, false);
        }

        Brake();
    }