Ejemplo n.º 1
0
 /// <summary>
 /// Returns an estimate of the current mood of a position for a gob.
 /// Mood is not measured in any specific units. Returned values are mutually comparable;
 /// the larger the return value, the better the mood is.
 /// </summary>
 private static float GetMood(Gob gob, Vector2 pos)
 {
     const float MOOD_DISTANCE_MIN = 400;
     const float MOOD_DISTANCE_MAX = 2000;
     var constituents =
         from minion in gob.Game.DataEngine.Minions
         where minion != gob
         let distance = Vector2.Distance(pos, minion.Pos)
         let sign = gob.IsFriend(minion) ? 1 : -1
         let amplitude = MathHelper.Clamp(1 - (distance - MOOD_DISTANCE_MIN) / (MOOD_DISTANCE_MAX - MOOD_DISTANCE_MIN), 0, 1)
         select sign * amplitude;
     return constituents.Sum();
 }