Ejemplo n.º 1
0
    private void InstantAttack(HumanCell target)
    {
        if (target)
        {
            target.DamageOrganism(target.GetHealth());

            if (target == attackTarget)
            {
                // Reset target
                attackTarget = null;
                if (orgMovement)
                {
                    orgMovement.SetTarget(null);
                }

                // Start recall to prevent chain attack
                StartCoroutine(AttackRecall());
            }
        }
    }
Ejemplo n.º 2
0
    private IEnumerator AttackOverTime()
    {
        canAttack = false;

        // Compute dot to apply and round it up
        int damageOverTime = attackTime == 0f ? attackTarget.GetHealth() : (int)((float)attackTarget.GetHealth() / attackTime) + 1;

        // While target alive we apply damage to it
        while (attackTarget)
        {
            targetLastPosition = attackTarget.transform.position;
            attackTarget.DamageOrganism(damageOverTime);

            if (!attackTarget)
            {
                selfOrganism.InstantiateOrganism(targetLastPosition);
            }
            yield return(new WaitForSeconds(attackTarget ? 1f : 0f));
        }

        // Start recall to prevent chain attack
        StartCoroutine(AttackRecall());
    }