/// <summary> /// Apply effects to the target changing its parameters. /// </summary> /// <param name="targetAgent"></param> private void INTERNAL_ApplyEffect(Agent targetAgent) { if (!targetAgent || !_agent) { return; } OnApplyEffect(targetAgent.gameObject); var hitPower = UnityEngine.Random.Range(_minPower, _maxPower + 1); if (_interruptTarget) { targetAgent.Interrupt(); } if (_affectHealth) { switch (_healthAffectionWay) { case AffectionWay.Reduce: targetAgent.Resources.Damage(hitPower); break; case AffectionWay.Add: targetAgent.Resources.Heal(hitPower); break; } } if (_affectEnergy) { switch (_energyAffectionWay) { case AffectionWay.Reduce: targetAgent.Resources.UseEnergy(hitPower); break; case AffectionWay.Add: targetAgent.Resources.AddEnergy(hitPower); break; } } if (_pushPower > 0) { targetAgent.Motion.Push(_agent.transform.position, hitPower * _pushPower); } if (_setStatus) { targetAgent.SetStatus(_status, _statusDuration); } if (_setPositionAsTarget) { var tmp = targetAgent.Perception.Memory.GetDefaultEntity(_agent.transform.position); targetAgent.Target = tmp.transform; } if (_additionalEffects.Count <= 0) { return; } foreach (var effect in _additionalEffects) { if (effect) { targetAgent.AddEffect(effect, _agent); } } }
/// <summary> /// Let Agent know that someithing is going on at cpecific position. /// </summary> /// <param name="position"></param> /// <param name="duration"></param> public void HearSomething(Vector3 position, float duration) { _suspiciousPosition = position; _agent.SetStatus(AgentStatus.HeardSomething, duration); }