Exemple #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (ramming)
        {
            if (!(collision.gameObject.layer == GlobalVariables.WALL_LAYER_INDEX))
            {
                if (!(collision.gameObject.GetComponent <LockableDoor>() != null))
                {
                    if (collision.gameObject.GetComponent <PlayerCharacter>() == null)
                    {
                        if ((collision.gameObject.transform.parent != null) &&
                            (collision.gameObject.transform.parent.parent != null) &&
                            (collision.gameObject.transform.parent.parent.gameObject.GetComponent <LockableDoor>() == null))
                        {
                            return;
                        }
                    }
                }
            }

            //if hit player, deal damage to player
            if (collision.gameObject.layer == GlobalVariables.PLAYER_LAYER_INDEX)
            {
                PlayerCharacter.instance.DamagablePlayer.ModifyHealth(-damage, DamageType.Physical);
                //play ram hit sound
                ramHitSfx.Play();
            }

            ramming = false;
            BossOwner.YieldPriority();
            rbody.velocity = Vector2.zero;
            CombatHandler.WalkingSuspended = false;
        }
    }
 //this is used as event call on animation
 public void YieldAbilityPrio()
 {
     CombatHandler.WalkingSuspended = false;
     BossOwner.YieldPriority();
 }