public Direction DirectionTo(Position other) { if(!(this | other)) throw new InvalidOperationException(); if (X + 1 == other.X) return Representation.Direction.Up; else if (X - 1 == other.X) return Representation.Direction.Down; else if (Y + 1 == other.Y) return Representation.Direction.Right; else return Representation.Direction.Left; }
protected virtual bool NeighbourTo(Position other) { if (Math.Abs(this.X - other.X) == 1 || Math.Abs(this.Y - other.Y) == 1) return true; return false; }
public Tile(IList<SubArea> subAreas, Position position) : base(position.X, position.Y) { areas = subAreas.ToList(); }
private Tile ReadTile(DataRow row, int index) { Position position = new Position( Convert.ToInt16(row[string.Format(positionKeyTemplate, "X", index)].ToString()), Convert.ToInt16(row[string.Format(positionKeyTemplate, "Y", index)].ToString())); var subAreas = ReadSubAreas(row[string.Format(areaDescriptionKeyTemplate, index)].ToString().Split(';')); return new Tile(subAreas, position); }