Esempio n. 1
0
        private void CreateObstacles(RLNET.RLConsole console, Rectangle room)
        {
            int numberOfObstacles = Game.Random.Next(1, 6);

            for (int i = 0; i < numberOfObstacles; i++)
            {
                int xPosition = Game.Random.Next(room.Left + 2, room.Right - 2);
                int yPosition = Game.Random.Next(room.Top + 2, room.Bottom - 2);
                if (_map.IsWalkable(xPosition, yPosition) && !(room.Center.X == xPosition && room.Center.Y == yPosition))
                {
                    _map.SetCellProperties(xPosition, yPosition, false, false, false);
                    DungeonMap.Columns.Add(new Column(xPosition, yPosition));
                    _map.SetIsWalkable(xPosition, yPosition, false);
                }
                else
                {
                    i--;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Copies contents of one console to another
        /// </summary>
        /// <param name="srcConsole">Source console to copy from.</param>
        /// <param name="srcX">Starting X position of the copy.</param>
        /// <param name="srcY">Starting Y position of the copy.</param>
        /// <param name="srcWidth">Width of the copy.</param>
        /// <param name="srcHeight">Height of the copy.</param>
        /// <param name="destConsole">Destination console to copy to.</param>
        /// <param name="destX">Desitination X position to copy to.</param>
        /// <param name="destY">Desitination Y position to copy to.</param>
        public static void Blit(RLConsole srcConsole, int srcX, int srcY, int srcWidth, int srcHeight, RLConsole destConsole, int destX, int destY)
        {
            if (srcConsole == null)
            {
                throw new ArgumentNullException("srcConsole");
            }
            if (destConsole == null)
            {
                throw new ArgumentNullException("destConsole");
            }
            if (srcWidth <= 0)
            {
                throw new ArgumentOutOfRangeException("srcWidth must be greater than zero.");
            }
            if (srcHeight <= 0)
            {
                throw new ArgumentOutOfRangeException("srcHeight must be greater than zero.");
            }

            for (int iy = 0; iy < srcHeight; iy++)
            {
                for (int ix = 0; ix < srcWidth; ix++)
                {
                    if (ix + destX >= 0 && iy + destY >= 0 && ix + destX < destConsole.Width && iy + destY < destConsole.Height &&
                        ix + srcX >= 0 && iy + srcY >= 0 && ix + srcX < srcConsole.Width && iy + srcY < srcConsole.Height)
                    {
                        destConsole.cells[ix + destX, iy + destY] = srcConsole.cells[ix + srcX, iy + srcY];
                    }
                }
            }
        }