Example #1
0
        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;
        }
Example #2
0
        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;
        }
Example #3
0
 public Tile(IList<SubArea> subAreas, Position position)
     : base(position.X, position.Y)
 {
     areas = subAreas.ToList();
 }
Example #4
0
        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);
        }