public bool IsValidPoint(BoardPoint p) { return(p.X >= 0 && p.X < Width && p.Y >= 0 && p.Y < Height); }
public void Set(BoardPoint p, GameTileState state) { if (tiles[p.X, p.Y].State != state) { tiles[p.X, p.Y].State = state; if (fireUpdateEvents) { OnBoardUpdate(this, new EventArgs()); } } }
public bool IsBadPoint(BoardPoint p) { if (!IsValidPoint(p)) { return(false); } var state = Get(p); return( state == GameTileState.Obstacle || state == GameTileState.WormBody || state == GameTileState.WormHead); }
public void SlitherTo(BoardPoint pos, ref GameBoard board) { segments.AddFirst(new Segment() { Point = pos }); if (segments.Count > MaxLength) { board.Set(segments.Last.Value.Point, GameTileState.Empty); segments.RemoveLast(); } board.Set(pos, GameTileState.WormHead); if (segments.Count > 1) { board.Set(segments.First.Next.Value.Point, GameTileState.WormBody); } }
public void Clear(BoardPoint p) { Set(p, GameTileState.Empty); }
public GameTileState Get(BoardPoint p) { return(tiles[p.X, p.Y].State); }