Exemple #1
0
    protected override void DealDamage(Collider2D hitBox)
    {
        AITarget target = hitBox.GetComponentInParent <AITarget>();

        if (target != null && !AITarget.FactionsHostile(instigatorAlignment, target.alignment))
        {
            return;
        }
        base.DealDamage(hitBox);
        hitBox.gameObject.SendMessage("OnFireDamage",
                                      new FireDamageArgs(burnDuration, damagePerSecond, damage),
                                      SendMessageOptions.DontRequireReceiver);
    }
Exemple #2
0
    protected virtual void DealDamage(Collider2D hitBox)
    {
        AITarget target = hitBox.GetComponentInParent <AITarget>();

        if (target != null && !AITarget.FactionsHostile(instigatorAlignment, target.alignment))
        {
            return;
        }

        Damageable damageable = hitBox.GetComponent <Damageable>();

        if (damageable == null)
        {
            return;
        }

        damageable.TakeDamage(damage, transform.position, force);
    }
Exemple #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        AITarget target = collision.GetComponentInParent <AITarget>();

        if (target != null && !AITarget.FactionsHostile(instigatorAlignment, target.alignment))
        {
            return;
        }

        if (burning)
        {
            collision.gameObject.SendMessage("OnFireDamage",
                                             new FireDamageArgs(burningDuration, burningDamagePerSecond, burningDamage),
                                             SendMessageOptions.DontRequireReceiver);
        }

        Torch torch = collision.GetComponent <Torch>();

        if (torch != null)
        {
            if (torch.lit)
            {
                burning = true;
                return;
            }
            return;
        }

        Damageable damageable = collision.GetComponent <Damageable>();

        if (damageable == null)
        {
            Destroy(gameObject);
            return;
        }

        damageable.TakeDamage(burning ? burningDamage : baseDamage,
                              transform.position, force);
        Destroy(gameObject);
    }
Exemple #4
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        AITarget  self = GetComponentInParent <AITarget>();
        Alignment instigatorAlignment = self != null ? self.alignment : Alignment.Wildcard;
        AITarget  target = collision.GetComponentInParent <AITarget>();

        if (target != null && !AITarget.FactionsHostile(instigatorAlignment, target.alignment))
        {
            return;
        }

        Damageable damageable = collision.GetComponent <Damageable>();

        if (damageable == null || alreadyHitTargets.Contains(damageable))
        {
            return;
        }

        alreadyHitTargets.Add(damageable);

        damageable.TakeDamage(damage, transform.position, attackForce);
    }
Exemple #5
0
 protected virtual bool ShouldAttack(AITarget other)
 {
     return(AITarget.FactionsHostile(selfTarget.alignment, other.alignment) &&
            (selfTarget.alignment != Alignment.Wildcard ||
             selfTarget.attackingEnemies.Contains(other.gameObject)));
 }