Пример #1
0
    public void DamageEnemy()
    {
        for (int j = 0; j < targets.Count; j++)
        {
            LevelAgent pc = targets[j];
            if (pc != null)
            {
                int damage = skillDamages[j].damage;
                int heal   = skillDamages[j].heal;
                IAlignmentProvider alignment = skillDamages[j].alignment;
                if (heal > 0)
                {
                    pc.Cure(heal, pc.position, alignment);
                }
                else
                {
                    if (isAOE)
                    {
                        IsAOE(pc, damage, alignment);
                    }
                    else
                    {
                        pc.OnSkillDamageTaken(damage, pc.position, alignment, true, null, "");
                    }
                }
            }
        }

        if (isOver != null)
        {
            isOver(this);
        }
    }
Пример #2
0
    void IsAOE(LevelAgent target, int damage, IAlignmentProvider alignment)
    {
        Collider[] cols = Physics.OverlapSphere(target.position, radius);
        foreach (Collider col in cols)
        {
            // If target can receive damage
            LevelAgent pc = col.gameObject.GetComponent <LevelAgent>();
            if (pc != null && target.configuration.alignmentProvider.IsFriend(pc.configuration.alignmentProvider))
            {
                Vector3 targetDir = pc.transform.position - target.transform.position;

                float proportion  = 1 - targetDir.sqrMagnitude / (radius * radius);
                int   finalDamage = (int)(damage * proportion);

                pc.OnSkillDamageTaken(finalDamage, pc.position, alignment, true, null, "");
            }
        }
    }