Beispiel #1
0
        public Board(Boundaries boundaries, int boardSpaceSize)
        {
            this.boardSpaceSize = boardSpaceSize;
            this.Boundaries     = boundaries;
            var width  = boundaries.Right - boundaries.Left;
            var height = boundaries.Bottom - boundaries.Top;

            var horizontalSpaces = width / boardSpaceSize;
            var verticalSpaces   = height / boardSpaceSize;

            this.BoardSpaces = new BoardSpace[verticalSpaces, horizontalSpaces];

            for (var i = 0; i < horizontalSpaces; i++)
            {
                for (var j = 0; j < verticalSpaces; j++)
                {
                    var position = new Vector2(i * boardSpaceSize, j * boardSpaceSize);
                    this.BoardSpaces[j, i] = new BoardSpace(position, boardSpaceSize, boardSpaceSize);
                }
            }

            Transform = new Transform(boundaries.Left, boundaries.Top, width, height);
        }
Beispiel #2
0
 /// <summary>
 /// Checks whether a transform is out of bounds
 /// </summary>
 /// <param name="transform"></param>
 /// <returns></returns>
 public bool IsEntityOutOfBounds(Transform transform)
 {
     return(Boundaries.IsOutOfBounds(transform));
 }