コード例 #1
0
 /// <summary>
 /// Create planet system through cloning, so that connection the the planetsystem "template" is severed
 /// </summary>
 /// <param name="name"></param>
 /// <param name="location"></param>
 /// <param name="title"></param>
 /// <returns></returns>
 public SystemType CreateSystem(string name, HexLocation location, string title)
 {
     SystemType spaceSystem = Systems.Single(s => s.name == name).CloneThroughXML();
     spaceSystem.Location = location;
     spaceSystem.name = title;
     return spaceSystem;
 }
コード例 #2
0
 public int DistanceTo(HexLocation other)
 {
     if (this == other)
     {
         return 0;
     }
     else
     {
         return 1 + StepTowards(other).DistanceTo(other);
     }
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: rbrother/lords-of-space
 public void CreateEmptyMap(int size)
 {
     List<SystemType> systems = new List<SystemType>();
     int radius = size / 2;
     HexLocation center = new HexLocation(radius, radius);
     for (int y = 0; y <= size; ++y)
     {
         for (int x = 0; x <= size; ++x)
         {
             HexLocation loc = new HexLocation(x, y);
             int distanceFromCenter = loc.DistanceTo(center);
             if (distanceFromCenter <= radius)
             {
                 systems.Add(App.CreateSystem(SetupTileName(distanceFromCenter), loc, loc.ToString()));
             }
         }
     }
     this.Map = systems.ToArray();
 }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: rbrother/lords-of-space
 public static SystemType CreateSystem(string name, HexLocation location, string description)
 {
     return Configuration.CreateSystem(name, location, description);
 }
コード例 #5
0
 public HexLocation StepTowards(HexLocation destination)
 {
     // Find minimum orthogonal distance after step
     int minDistance = NeighbourTiles.Min(p => p.OrthogonalDistanceTo(destination));
     // Return neighbour points that leads to minimum orthogonal distance
     return NeighbourTiles.First(p => p.OrthogonalDistanceTo(destination) == minDistance);
 }
コード例 #6
0
 public int OrthogonalDistanceTo(HexLocation b)
 {
     return Math.Abs(X - b.X) + Math.Abs(Y - b.Y);
 }