Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        var entity = collision.GetEntity();
        var damageable = entity == null ? null : entity.GetComponent<Damageable>();

        if (HitEffect != null)
            ParticleManager.Instance.Create(HitEffect, Entity.Transform.position);

        if (damageable != null)
            Damage(damageable);
        else
            Entity.SendMessage(EntityMessages.OnDie);
    }
Exemplo n.º 2
0
    void OnTriggerStay2D(Collider2D collision)
    {
        var time = Entity.GetComponent<TimeComponent>();

        if (time.Time < nextDamageTime)
            return;

        var entity = collision.GetEntity();
        var damageable = entity == null ? null : entity.GetComponent<Damageable>();

        if (damageable != null)
        {
            nextDamageTime = time.Time + DamageInterval;
            Damage(damageable);
            Animator.SetTrigger(AttackTrigger);
            Entity.SendMessage(EntityMessages.OnStartAttacking);
        }
    }