public void ApplyToMaps(InfluenceMaps maps, ICivilization targetCiv) { foreach (var unit in UnitFactory.AllUnits) { var unitOwner = UnitPossessionCanon.GetOwnerOfPossession(unit); var unitLocation = UnitPositionCanon.GetOwnerOfPossession(unit); float unitStrength = UnitStrengthEstimator.EstimateUnitStrength(unit); if (unitOwner == targetCiv) { InfluenceMapApplier.ApplyInfluenceToMap( unitStrength, maps.AllyPresence, unitLocation, AIConfig.UnitMaxInfluenceRadius, InfluenceMapApplier.PowerOfTwoRolloff, InfluenceMapApplier.ApplySum ); } else if (WarCanon.AreAtWar(unitOwner, targetCiv)) { InfluenceMapApplier.ApplyInfluenceToMap( unitStrength, maps.EnemyPresence, unitLocation, AIConfig.UnitMaxInfluenceRadius, InfluenceMapApplier.PowerOfTwoRolloff, InfluenceMapApplier.ApplySum ); } } }
public void AssignMaps(InfluenceMaps maps, ICivilization targetCiv) { if (maps.AllyPresence == null) { maps.AllyPresence = new float[Grid.Cells.Count]; } if (maps.EnemyPresence == null) { maps.EnemyPresence = new float[Grid.Cells.Count]; } if (maps.PillagingValue == null) { maps.PillagingValue = new float[Grid.Cells.Count]; } foreach (var cell in Grid.Cells) { maps.AllyPresence [cell.Index] = 0f; maps.EnemyPresence [cell.Index] = 0f; maps.PillagingValue[cell.Index] = 0f; } foreach (var influenceSource in InfluenceSources) { influenceSource.ApplyToMaps(maps, targetCiv); } }
public void ApplyToMaps(InfluenceMaps maps, ICivilization targetCiv) { if (maps == null) { throw new ArgumentNullException("maps"); } else if (targetCiv == null) { throw new ArgumentNullException("targetCiv"); } foreach (var nonDomesticCell in Grid.Cells.Where(cell => CivTerritoryLogic.GetCivClaimingCell(cell) != targetCiv)) { float pillageValue = 0f; if (nonDomesticCell.HasRoads) { pillageValue += AIConfig.RoadPillageValue; } var improvementAt = ImprovementLocationCanon.GetPossessionsOfOwner(nonDomesticCell).FirstOrDefault(); if (improvementAt != null && !improvementAt.IsPillaged) { var nodeAt = NodeLocationCanon.GetPossessionsOfOwner(nonDomesticCell).FirstOrDefault(); if (nodeAt != null && nodeAt.Resource.Extractor == improvementAt.Template) { pillageValue += AIConfig.ExtractingImprovementPillageValue; } else { pillageValue += AIConfig.NormalImprovementPillageValue; } } maps.PillagingValue[nonDomesticCell.Index] = pillageValue; } }
public void ClearMaps(InfluenceMaps maps) { maps.AllyPresence = null; maps.EnemyPresence = null; maps.PillagingValue = null; }