Ejemplo n.º 1
0
        /// <summary>
        /// Gets the <see cref="SnakeGame.GridSystem.Cell"/> with the specified coordinates.
        /// </summary>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        public Cell this[int x, int y]
        {
            get
            {
/*
 *                              if (!CheckWidth(x))
 *                              {
 *                                      throw new IndexOutOfRangeException("X component of indexer (first argument) must be in the range " + FormatRange(0, Width) + ".");
 *                              }
 *                              if (!CheckHeight(y))
 *                              {
 *                                      throw new IndexOutOfRangeException("Y component of indexer (second argument) must be in the range " + FormatRange(0, Height) + ".");
 *                              }
 */
                Cell res = Cell.INVALID_CELL;
                if (RangeX.InRange(x) && RangeY.InRange(y))
                {
                    res = _cells[y][x];
                }

/*
 *                              if (res == Cell.INVALID_CELL)
 *                              {
 *                                      throw new DataMisalignedException("A valid value was not create during object construction.");
 *                              }
 */
                return(res);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Determines whether the specified coordinate is within this grid's range.
 /// </summary>
 /// <returns><c>true</c> if the coordinate is in range; otherwise, <c>false</c>.</returns>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 public bool IsDefined(int x, int y)
 {
     return(RangeX.InRange(x) && RangeY.InRange(y));
 }