Exemple #1
0
    void InHitStun(Character attacker, Character receiver, Animator anim, Animator attAnim, Vector3 sparkPlace, Rigidbody2D receiverRigid, Rigidbody2D attackerRigid)
    {
        if (attacker.gameObject.tag == "Player1")
        {
            if (anim.GetBool("isInHitStun"))
            {
                comboCounter.GetComboCountP1++;
                comboCounter.GetStartTimerP1 = false;
                comboCounter.ResetComboFinishedTimerP1();
            }
        }
        else if (attacker.gameObject.tag == "Player2")
        {
            if (anim.GetBool("isInHitStun"))
            {
                comboCounter.GetComboCountP2++;
                comboCounter.GetStartTimerP2 = false;
                comboCounter.ResetComboFinishedTimerP2();
            }
        }
        float hitStunTimer = attacker.GetEnforceHitStun() * 0.2f;

        receiver.SetDamage(attacker.GetDamage());
        anim.SetBool("isInHitStun", true);
        if (attacker.GetHitType() != Character.HitType.normal && attacker.GetHitType() != Character.HitType.hurricaneKick && attacker.GetHitType() != Character.HitType.rekka)
        {
            OtherHitStunProperties(attacker, receiver, anim, attAnim, sparkPlace, receiverRigid);
        }
        else
        {
            if (anim.GetBool("isAirborne") == true)
            {
                if (receiver.GetHealth() <= 0f)
                {
                    if (attacker.GetComponent <FeiLong>() != null)
                    {
                        SuperKO(attacker.GetComponent <FeiLong>().GetRekkaShinkenActive);
                    }
                    else if (attacker.GetComponent <Balrog>() != null)
                    {
                        SuperKO(attacker.GetComponent <Balrog>().GetGigatonPunchActive);
                    }
                    else if (attacker.GetComponent <MBison>() != null)
                    {
                        SuperKO(attacker.GetComponent <MBison>().GetKneePressNightmareActive);
                    }
                    GotKOed(receiver, anim, receiverRigid);
                }
                else
                {
                    anim.Play("MidAirHit", 0, 0f);
                    TimeControl.slowDownTimer = normalHitSlowDown;
                    hitStunTimer = 3f;
                    if (distance > 0)
                    {
                        receiver.side = Character.Side.P2;
                        receiver.SideSwitch();
                        receiverRigid.velocity = new Vector2(attacker.GetEnforcePushBack() * 0.15f, 2f);
                    }
                    else
                    {
                        receiver.side = Character.Side.P1;
                        receiver.SideSwitch();
                        receiverRigid.velocity = new Vector2(-attacker.GetEnforcePushBack() * 0.15f, 2f);
                    }
                    TimeControl.slowDownTimer = normalHitSlowDown;
                }
            }
            else
            {
                if (receiver.GetHealth() <= 0f)
                {
                    if (attacker.GetComponent <FeiLong>() != null)
                    {
                        SuperKO(attacker.GetComponent <FeiLong>().GetRekkaShinkenActive);
                    }
                    else if (attacker.GetComponent <Balrog>() != null)
                    {
                        SuperKO(attacker.GetComponent <Balrog>().GetGigatonPunchActive);
                    }
                    else if (attacker.GetComponent <MBison>() != null)
                    {
                        SuperKO(attacker.GetComponent <MBison>().GetKneePressNightmareActive);
                    }
                    GotKOed(receiver, anim, receiverRigid);
                }
                else
                {
                    if (anim.GetBool("isCrouching") == true)
                    {
                        anim.Play("CrouchHit", 0, 0f);
                        TimeControl.slowDownTimer = normalHitSlowDown;
                    }
                    else
                    {
                        if (attacker.GetMoveType() == Character.MoveType.low)
                        {
                            anim.Play("LowHit", 0, 0f);
                        }
                        else
                        {
                            anim.Play("HighHit", 0, 0f);
                        }
                        TimeControl.slowDownTimer = normalHitSlowDown;
                    }
                    PushBack(attacker, receiverRigid, attackerRigid);
                }
            }
            if (attacker.GetComponent <MBison>() != null && attAnim.GetBool("headStompActive"))
            {
                attAnim.SetTrigger("headStompHit");
            }
        }
        switch (attacker.GetSparkType())
        {
        case Character.SparkType.normal:
            AudioSource.PlayClipAtPoint(normalHit, transform.position);
            Instantiate(hitSpark, sparkPlace, Quaternion.identity);
            break;

        case Character.SparkType.big:
            AudioSource.PlayClipAtPoint(bigHit, transform.position);
            Instantiate(bigHitSpark, sparkPlace, Quaternion.identity);
            break;

        case Character.SparkType.shoryuken:
            AudioSource.PlayClipAtPoint(shoryukenHit, transform.position);
            Instantiate(shoryukenSpark, sparkPlace, Quaternion.identity);
            break;
        }
        anim.SetFloat("hitStunTimer", hitStunTimer);
    }
 void ProjectileLanded(Animator hurtCharAnimator, Character hurtCharacter, Rigidbody2D hurtPhysicsbody)
 {
     TimeControl.slowDown = true;
     AudioSource.PlayClipAtPoint(connectedSound, transform.position);
     hurtCharacter.SetDamage(damage);
     if (gameObject.tag == "Player1")
     {
         if (hurtCharAnimator.GetBool("isInHitStun"))
         {
             comboCounter.GetComboCountP1++;
             comboCounter.GetStartTimerP1 = false;
             comboCounter.ResetComboFinishedTimerP1();
         }
     }
     else if (gameObject.tag == "Player2")
     {
         if (hurtCharAnimator.GetBool("isInHitStun"))
         {
             comboCounter.GetComboCountP2++;
             comboCounter.GetStartTimerP2 = false;
             comboCounter.ResetComboFinishedTimerP2();
         }
     }
     if (hurtCharacter.GetHealth() <= 0f)
     {
         CharacterKOed(hurtCharacter, hurtPhysicsbody, hurtCharAnimator);
     }
     else
     {
         TimeControl.slowDownTimer = 30f;
         timer = hitStun * 0.2f;
         if (hurtCharAnimator.GetBool("isAirborne") == true)
         {
             if (numHits > 1)
             {
                 AirPushBack(hurtCharAnimator, hurtPhysicsbody, "MidAirHit", 0.25f);
             }
             else
             {
                 AirPushBack(hurtCharAnimator, hurtPhysicsbody, "KnockDownBlendTree", 3f);
             }
         }
         else
         {
             if (hurtCharAnimator.GetBool("isCrouching") == true)
             {
                 hurtCharAnimator.Play("CrouchHit", 0, 0f);
             }
             else
             {
                 if (moveType == MoveType.low)
                 {
                     hurtCharAnimator.Play("LowHit", 0, 0f);
                 }
                 else
                 {
                     hurtCharAnimator.Play("HighHit", 0, 0f);
                 }
             }
             PushBack(hurtPhysicsbody);
         }
         hurtCharAnimator.SetBool("isInHitStun", true);
         hurtCharAnimator.SetFloat("hitStunTimer", timer);
     }
     Instantiate(shoryukenSpark, transform.position, Quaternion.identity);
 }