/// <summary> /// Calculates the magnitude of the specified field relative to the center of the map. /// </summary> /// <param name="field"></param> /// <param name="force"></param> /// <param name="forceStep"></param> /// <param name="rangePercentage"></param> /// <returns></returns> public double PFMapCenterAttraction(Position field, double force, double forceStep, int rangePercentage) { double distance = field.getDistance(SCMath.GetMapCenterPosition()); return(distance <= SCMath.GetPercentageOfMaxDistancePixels(rangePercentage) ? force//0 : force - forceStep * distance); }
/// <summary> /// Calculates the magnitude of the specified position on the map relative to the centroid of the squad /// (being close to the other units in the squad will give the best magnitude/attraction). /// </summary> /// <param name="squad"></param> /// <param name="possibleNextPosition"></param> /// <param name="force"></param> /// <param name="forceStep"></param> /// <param name="rangePercentage">How big the Range to the centroid of all the Units positions in the Squad/Group</param> /// <returns>The magnitude of squad attraction. 0 if a unit is inside the specified range and gives a negative linear drop-off the further away the unit is from the group.</returns> public double PFSquadAttraction(List <UnitAgent> squad, Position possibleNextPosition, double force, double forceStep, int rangePercentage) { if (squad != null && squad.Count > 0) { double distance = possibleNextPosition.getDistance(CombatControl.CalculateCentroidPosition(squad.Select(ua => ua.SCUnit))); return(distance <= SCMath.GetPercentageOfMaxDistancePixels(rangePercentage) ? force//0 : force - forceStep * distance); } log.Error("squad unit list is null or has zero elements in PFSquadAttraction"); return(0); }