public override int GetThreat(Script_IEntity p_entity) { Script_IFriendly friendly = p_entity as Script_IFriendly; Assert.IsNotNull(friendly); return(_threatDictionary [friendly]); }
private void InitializeThreatList() { List <Script_IEntity> friendlies = _manager.GetFriendlies(); foreach (Script_IEntity entity in friendlies) { Script_IFriendly friendly = entity as Script_IFriendly; Assert.IsNotNull(friendly); _threatDictionary.Add(friendly, 0); } }
public override void TakeDamage(Script_IEntity p_attacker, int p_damage) { Script_IFriendly attacker = p_attacker as Script_IFriendly; Assert.IsNotNull(attacker); int threatMultiplier = attacker.GetThreatMultiplier(); if (!_threatDictionary.ContainsKey(attacker)) { _threatDictionary.Add(attacker, p_damage * threatMultiplier); } else { int threat = _threatDictionary[attacker] + p_damage * threatMultiplier; _threatDictionary [attacker] = threat; } _health -= p_damage; }
private Script_IEntity GetHighestThreat(List <Script_IEntity> p_entityList) { int threat = 0; Script_IEntity highestThreatEntity = null; foreach (Script_IEntity entity in p_entityList.ToList()) { Script_IFriendly friendly = entity as Script_IFriendly; if (_threatReceiver.GetThreat(friendly) > threat) { highestThreatEntity = entity; threat = _threatReceiver.GetThreat(friendly); } } return(highestThreatEntity); }