示例#1
0
    private bool DamageableIsImmune(DamageableTemplate damageable)
    {
        bool dodgeItsOwnAttack      = damageable == spawnerOfThisDamager && spawnerIsImmune;
        bool damageableTypeIsImmune = immuneDamageableTypes.Contains(damageable.GetType());

        return(dodgeItsOwnAttack || damageableTypeIsImmune);
    }
示例#2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamageableTemplate damageable = other.GetComponent <DamageableTemplate>();

        if (damageable)
        {
            DecideIfIsImmuneThenDealDamage(damageable);
        }
    }
示例#3
0
 private void DecideIfIsImmuneThenDealDamage(DamageableTemplate damageable)
 {
     if (DamageableIsImmune(damageable))
     {
         return;
     }
     else
     {
         ExecuteDamageAlgorightm(damageable);
     }
 }
示例#4
0
    private void ExecuteDamageAlgorightm(DamageableTemplate damageable)
    {
        BeforeDoingDamage(damageable);

        damageable.Damage(this, damageAmount);

        AfterDoingDamage();

        if (destroyItselfAfterHit)
        {
            Destroy(gameObject);
        }
    }
示例#5
0
 public void SetSpawner(DamageableTemplate spawner)
 {
     this.spawnerOfThisDamager = spawner;
 }
示例#6
0
 protected virtual void BeforeDoingDamage(DamageableTemplate damageable)
 {
 }