Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public int DistanceTo(HexLocation other)
 {
     if (this == other)
     {
         return 0;
     }
     else
     {
         return 1 + StepTowards(other).DistanceTo(other);
     }
 }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
 public static SystemType CreateSystem(string name, HexLocation location, string description)
 {
     return Configuration.CreateSystem(name, location, description);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 6
0
 public int OrthogonalDistanceTo(HexLocation b)
 {
     return Math.Abs(X - b.X) + Math.Abs(Y - b.Y);
 }