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