Ejemplo n.º 1
0
        private void DamageMonster(float damage)
        {
            if (giant == null)
            {
                return;
            }

            AgentHealth healthComp = giant.RequestComponent <AgentHealth>();

            if (healthComp != null)
            {
                float damageReceived = -(DamageResist - damage);
                healthComp.ApplyDamage(damageReceived);
            }
        }
Ejemplo n.º 2
0
        public void Attack <T>() where T : Agent
        {
            T[] damageables = GameObject.FindObjectsOfType <T>();

            foreach (T d in damageables)
            {
                float distance = Vector3.Distance(attacker.WorlPos, d.WorlPos);
                if (distance > attacker.attackRange)
                {
                    return;
                }

                AgentHealth health = d.RequestComponent <AgentHealth>();

                if (health != null)
                {
                    health.ApplyDamage(attacker.attackDamage);
                }
            }
        }