示例#1
0
 public void ApplyToMap(Map map)
 {
     Dictionary<int, List<Unit>> playerUnits = new Dictionary<int, List<Unit>>();
     foreach (Tile t in map.GetAllTiles())
     {
         foreach (Unit u in t.Units)
         {
             if (!playerUnits.ContainsKey(u.UnitOwner))
                 playerUnits[u.UnitOwner] = new List<Unit>();
             playerUnits[u.UnitOwner].Add(u);
         }
         t.Units.Clear();
     }
     foreach (PlayerStart ps in PlayerStarts)
         map.GetTile(ps.StartX, ps.StartY).Units.AddRange(playerUnits[ps.PlayerId]);
 }
示例#2
0
 public List<MapState> GetNeighbouringStates(Map map, List<int> fixedStarts, int minimumDistanceBetweenCapitals)
 {
     List<MapState> list = new List<MapState>();
     foreach (var startToMove in PlayerStarts)
     {
         if (fixedStarts.Contains(startToMove.PlayerId)) continue;
         foreach (Tile t in map.GetNeighbours(map.GetTile(startToMove.StartX, startToMove.StartY), true))
         {
             if (t.IsTraversableByLand())
             {
                 MapState clone = this.Clone();
                 clone.PlayerStarts[startToMove.PlayerId].StartX = t.X;
                 clone.PlayerStarts[startToMove.PlayerId].StartY = t.Y;
                 if(clone.RespectsMinimumDistance(map, minimumDistanceBetweenCapitals))
                     list.Add(clone);
             }
         }
     }
     return list;
 }
示例#3
0
 public static Map CropToSelection(Map thisMap, Selection selection)
 {
     int minX = int.MaxValue; int maxX = int.MinValue; int minY = int.MaxValue; int maxY = int.MinValue;
     foreach (var t in selection)
     {
         minX = Math.Min(minX, t.X);
         minY = Math.Min(minY, t.Y);
         maxX = Math.Max(maxX, t.X);
         maxY = Math.Max(maxY, t.Y);
     }
     Map map = (Map)thisMap.Clone();
     if (minX == int.MaxValue) return map; // return uncropped map if no selected tiles
     map.SetDimensions(maxX - minX + 1, maxY - minY + 1);
     for (int x = minX; x <= maxX; x++)
     {
         for (int y = minY; y <= maxY; y++)
         {
             Tile t = (Tile)thisMap.GetTile(x, y).Clone();
             map.SetTile(x - minX, y - minY, t);
         }
     }
     return map;
 }
示例#4
0
 public void SetTiles(Map map, int minX, int minY)
 {
     for (int x = minX; x < minX + map.Width; x++)
         for (int y = minY; y < minY + map.Height; y++)
             this.SetTile(x, y, (Tile)map.GetTile(x - minX, y - minY).Clone());
 }
示例#5
0
 public static Map RepeatVertically(Map thisMap, int times)
 {
     if (times < 2) return thisMap;
     Map map = (Map)thisMap.Clone();
     map.SetDimensions(thisMap.Width, thisMap.Height * times);
     for (int x = 0; x < thisMap.Width; x++)
     {
         for (int y = 0; y < thisMap.Height; y++)
         {
             Tile t = thisMap.GetTile(x, y);
             for (int r = 0; r < times; r++)
                 map.SetTile(x, y + r * thisMap.Height, (Tile)t.Clone());
         }
     }
     return map;
 }
示例#6
0
 public static Map MirrorWest(Map thisMap)
 {
     Map map = (Map)thisMap.Clone();
     map.SetDimensions(thisMap.Width * 2, thisMap.Height);
     for (int x = 0; x < thisMap.Width; x++)
     {
         for (int y = 0; y < thisMap.Height; y++)
         {
             Tile t = thisMap.GetTile(x, y);
             map.SetTile(thisMap.Width + x, y, (Tile)t.Clone());
             map.SetTile(thisMap.Width - 1 - x, y, (Tile)t.Clone());
         }
     }
     map.FlipRiversHorizontally(0, thisMap.Width - 1);
     return map;
 }
示例#7
0
 public static Map MirrorSouth(Map thisMap)
 {
     Map map = (Map)thisMap.Clone();
     map.SetDimensions(thisMap.Width, thisMap.Height * 2);
     for (int x = 0; x < thisMap.Width; x++)
     {
         for (int y = 0; y < thisMap.Height; y++)
         {
             Tile t = thisMap.GetTile(x, y);
             map.SetTile(x, thisMap.Height + y, (Tile)t.Clone());
             map.SetTile(x, thisMap.Height - 1 - y, (Tile)t.Clone());
         }
     }
     map.FlipRiversVertically(0, thisMap.Height - 1);
     return map;
 }