示例#1
0
 void Damage(Targetable enemy)
 {
     if (enemy != null)
     {
         enemy.TakeDamage(damage, enemy.position, alignmentProvider);
     }
 }
示例#2
0
 public virtual void OnRemove()
 {
     // If scene is in progress
     if (isQuitting == false)
     {
         // Find all colliders in specified radius
         //Collider2D[] cols = Physics2D.OverlapCircleAll(transform.position, radius);
         Collider[] cols = Physics.OverlapSphere(transform.position, radius);
         foreach (Collider col in cols)
         {
             // If target can receive damage
             Targetable damageTaker = col.gameObject.GetComponent <Targetable>();
             if (damageTaker != null)
             {
                 // Target takes damage equal bullet damage * AOE Damage Rate
                 damageTaker.TakeDamage((int)(Mathf.Ceil(aoeDamageRate * (float)bullet.GetDamage())), col.transform.position, alignmentProvider);
             }
         }
         if (explosion != null)
         {
             // Create explosion visual effect
             Destroy(Instantiate <GameObject>(explosion, transform.position, transform.rotation), explosionDuration);
         }
     }
 }
示例#3
0
 // Create damage to enemy.
 protected void DealDamage()
 {
     if (target == null)
     {
         return;
     }
     target.TakeDamage(damager.damage, target.position, damager.alignmentProvider);
 }
    private void OnTriggerEnter(Collider other)
    {
        Targetable targetable = other.transform.GetComponent <Targetable>();

        if (targetable)
        {
            targetable.TakeDamage(damageOnHit);
        }
    }
示例#5
0
    /// <summary>
    /// Damage targets on trigger enter
    /// </summary>
    /// <param name="other">Other.</param>
    void OnTriggerEnter2D(Collider2D other)
    {
        // If target can receive damage
        Targetable damageTaker = other.GetComponent <Targetable> ();

        if (damageTaker != null)
        {
            damageTaker.TakeDamage(damage, other.transform.position, alignmentProvider);
        }
    }
    private void OnCollisionEnter(Collision collision)
    {
        Targetable targetable = collision.transform.GetComponent <Targetable>();

        if (targetable)
        {
            targetable.TakeDamage(damage);
        }

        // TODO effect

        Destroy(gameObject);
    }
示例#7
0
    public override void Use(Unit Owner, Targetable Target)
    {
        DamagePacket MeleeDamagePacked = new DamagePacket(Damage * Owner.DamageMultiplier, DamageType);

        Target.TakeDamage(MeleeDamagePacked, (bool bKilled) =>
        {
            if (bKilled)
            {
                Debug.Log("Killed enemy");
            }
        });

        bReady = false;
    }
示例#8
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            m_Enemy = other.gameObject.GetComponent <Targetable>();
            m_Enemy.TakeDamage(m_Damager.damage, m_Enemy.position, m_Damager.alignmentProvider);



            var pfx = Poolable.TryGetPoolable <ParticleSystem>(collisionParticles.gameObject);

            pfx.transform.position = other.transform.position;
            pfx.Play();
        }
    }
示例#9
0
    public void ApplyEffect(Targetable target)
    {
        Dictionary <Modifier, ParameterModiferValue> effectParameters = GetEffectValue(activeEffect, target);

        foreach (KeyValuePair <Modifier, ParameterModiferValue> parameter in effectParameters)
        {
            if (parameter.Key == Modifier.Damage)
            {
                target.TakeDamage(parameter.Value.value, target.transform.position, LevelManager.instance.playerAlignment.GetInterface());
            }
            else
            {
                ActiveUnit        activeUnit = target as ActiveUnit;
                ParameterModifier param      = new ParameterModifier(parameter.Value.value, parameter.Value.modType);
                activeUnit.parameters.UpdateParameter(parameter.Key, param, this.gameObject);
            }
        }
    }
示例#10
0
        /// <summary>
        /// The actual attack of the hitscan attack.
        /// Early returns from the method if the there is no enemy to attack.
        /// </summary>
        protected void DealDamage()
        {
            Poolable.TryPool(gameObject);

            if (m_Enemy == null)
            {
                return;
            }

            // effects
            ParticleSystem pfxPrefab    = m_Damager.collisionParticles;
            var            attackEffect = Poolable.TryGetPoolable <ParticleSystem>(pfxPrefab.gameObject);

            attackEffect.transform.position = m_Enemy.position;
            attackEffect.Play();

            m_Enemy.TakeDamage(m_Damager.damage, m_Enemy.position, m_Damager.alignmentProvider);
            m_PauseTimer = true;
        }
示例#11
0
    private void OnTriggerEnter(Collider other)
    {
        Targetable TargetHit = other.gameObject.GetComponent <Targetable>();

        if (TargetHit != null)
        {
            if (TargetHit.Allegiance != Owner.Allegiance)
            {
                TargetHit.TakeDamage(DamagePacket,
                                     (bool bKilled) =>
                {
                    if (bKilled)
                    {
                        Debug.Log("Projectile killed");
                    }
                });
                Destroy(gameObject);
            }
        }
    }
示例#12
0
    /// <summary>
    /// Make damage specified by delays and amount.
    /// </summary>
    /// <returns>The coroutine.</returns>
    private IEnumerator DamageCoroutine()
    {
        foreach (float delay in delaysBeforeDamage)
        {
            yield return(new WaitForSeconds(delay));

            // Search for targets
            Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, radius);
            foreach (Collider2D col in hits)
            {
                if (col.CompareTag("Enemy") == true)
                {
                    Targetable damageTaker = col.GetComponent <Targetable>();
                    if (damageTaker != null)
                    {
                        damageTaker.TakeDamage(damage, transform.position, alignmentProvider);
                    }
                }
            }
        }

        Destroy(gameObject);
    }