Exemple #1
0
    private void OnCollision(Collider2D collider)
    {
        if (!_characterState.CanBeStunned())         // || _knockdown.state != KnockDown.State.Null || (tag == "Player" && _jump.state != Jump.State.Null))
        {
            return;
        }

        AttackArea attackArea = collider.GetComponent <AttackArea>();

        if (attackArea && attackArea.IsShootType())
        {
            return;
        }

        if (collider.tag == "Damage")
        {
            if (tag != "Player" || ShouldStunPlayer(attackArea))
            { // only 50% chance to stun if it's Abe
                Attack attack       = collider.GetComponentInParent <Attack>();
                float  directionMod = (collider.GetComponentInParent <Movement>().direction == Movement.Direction.Right ? 1f : -1f);

                if (attack.attackState == Attack.State.Heavy)
                {
                    if (attack.getAttackHand() == Attack.Hand.Right)
                    {
                        GetStunned(attack.GetStunAmount(), attack.GetKnockbackAmount(), directionMod, Direction.Right, Power.Heavy);
                    }
                    else
                    {
                        GetStunned(attack.GetStunAmount(), attack.GetKnockbackAmount(), directionMod, Direction.Left, Power.Heavy);
                    }
                }
                else // if (attack.attackState == Attack.State.Light)
                {
                    if (attack.getAttackHand() == Attack.Hand.Right)
                    {
                        GetStunned(attack.GetStunAmount(), attack.GetKnockbackAmount(), directionMod, Direction.Right, Power.Light);
                    }
                    else
                    {
                        GetStunned(attack.GetStunAmount(), attack.GetKnockbackAmount(), directionMod, Direction.Left, Power.Light);
                    }
                }
            }

            if (tag == "Player")
            {
                GetComponent <Attack>().SetState(Attack.State.Null);
            }
        }
    }
Exemple #2
0
    private void OnCollision(Collider2D collider)
    {
        AttackArea attackArea = collider.GetComponent <AttackArea>();

        if (attackArea && attackArea.IsShootType())
        {
            return;
        }

        if (collider.tag == "Damage")
        {
            damageAmount = collider.transform.GetComponentInParent <Attack>().GetDamageAmount();
            ExecuteDamage(damageAmount, collider);

            if (name.Contains("Bear"))
            {
                if (UnityEngine.Random.value < 0.33f)
                {
                    SoundPlayer.Play("Damage React Bear");
                }
            }
            else if (name.Contains("Officer-Boss"))
            {
                SoundPlayer.Play("Battlefield Boss Hit");
            }
            else if (name.Contains("RobertELee"))
            {
                SoundPlayer.Play("Lee Hit");
            }
            //else if (name.Contains("Officer"))
            //    SoundPlayer.Play("Officer Hit");
            else if (name.Contains("Rifleman"))
            {
                SoundPlayer.Play("Rifleman Hit");
            }
            else if (name.Contains("Bushwhacker"))
            {
                SoundPlayer.Play("BushWhacker Hit");
            }
            else if (name.Contains("Officer"))
            {
                SoundPlayer.Play("Officer Hit");
            }
            else if (name.Contains("Woman"))
            {
                SoundPlayer.Play("Woman Hit");
            }
            else if (tag != "Player")
            {
                SoundPlayer.Play("Damage React Light");
            }

            if (attackArea)
            {
                if (attackArea.GetAttackState() == Attack.State.Heavy)
                {
                    if (attackArea.GetAttackType() == Weapon.AttackType.Swing)
                    {
                        SoundPlayer.Play("Heavy Axe Impact 1");
                        SoundPlayer.Play("Heavy Axe Impact 1.1");
                    }
                    else if (attackArea.GetAttackType() == Weapon.AttackType.Melee)
                    {
                        SoundPlayer.Play("Heavy Punch Impact 1");
                        SoundPlayer.Play("Heavy Punch Impact 1.2");
                        SoundPlayer.Play("Heavy Punch Impact 1.3");
                    }
                    else if (attackArea.GetAttackType() == Weapon.AttackType.Slash)
                    {
                        SoundPlayer.Play("Saber Impact");
                    }

                    else if (attackArea.GetAttackType() == Weapon.AttackType.Knife)
                    {
                        SoundPlayer.Play("Knife Impact");
                    }
                }
                else
                {
                    if (attackArea.GetAttackType() == Weapon.AttackType.Swing)
                    {
                        if (attackArea.GetAttackChainNumber() >= 2)
                        {
                            SoundPlayer.Play("Light Axe Impact 3");
                        }
                        else if (attackArea.GetAttackChainNumber() >= 1)
                        {
                            SoundPlayer.Play("Light Axe Impact 2");
                        }
                        else
                        {
                            SoundPlayer.Play("Light Axe Impact 1");
                        }
                    }
                    else if (attackArea.GetAttackType() == Weapon.AttackType.Melee)
                    {
                        SoundPlayer.Play("Light Punch Impact");
                    }

                    else if (attackArea.GetAttackType() == Weapon.AttackType.Slash)
                    {
                        SoundPlayer.Play("Saber Impact");
                    }

                    else if (attackArea.GetAttackType() == Weapon.AttackType.Knife)
                    {
                        SoundPlayer.Play("Knife Impact");
                    }
                }
            }
        }
    }