Ejemplo n.º 1
0
		private void SetRandomPathPosition()
		{
			this.MazeGenerator.StartDirection = _startDirection = (_prevFloor == null ? Direction.Down : Direction.GetOppositeDirection(_prevFloor._startDirection));

			var mt = _dungeonGenerator.RngMaze;
			if (this.HasBossRoom)
			{
				if (_dungeonGenerator.Option.Contains("largebossroom=" + '"' + "true"))  // <option largebossroom="true" />
				{
					while (true)
					{
						_pos.X = (int)(mt.GetUInt32() % (this.Width - 2) + 1);
						_pos.Y = (int)(mt.GetUInt32() % (this.Height - 3) + 1);
						if (this.MazeGenerator.IsFree(_pos))
							if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y)))
								if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y)))
									if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 1)))
										if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y + 1)))
											if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y + 1)))
												if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 2)))
													if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y + 2)))
														if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y + 2)))
															break;
					}

					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 1));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y + 1));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y + 1));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 2));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y + 2));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y + 2));
				}
				else
				{
					while (true)
					{
						_pos.X = (int)(mt.GetUInt32() % (this.Width - 2) + 1);
						_pos.Y = (int)(mt.GetUInt32() % (this.Height - 3) + 1);
						if (this.MazeGenerator.IsFree(_pos))
							if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y)))
								if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y)))
									if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 1)))
										if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y + 1)))
											if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y + 1)))
												if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 2)))
													break;
					}

					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 1));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y + 1));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y + 1));
					this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 2));
				}
			}
			else
			{
				var free = false;
				while (!free)
				{
					_pos.X = (int)(mt.GetUInt32() % this.Width);
					_pos.Y = (int)(mt.GetUInt32() % this.Height);

					free = this.MazeGenerator.IsFree(_pos);
				}
			}

			if (!this.IsLastFloor && !HasBossRoom)
			{
				var rndDir = new RandomDirection();
				while (true)
				{
					var direction = rndDir.GetDirection(mt);
					if (this.SetTraits(_pos, direction, (int)DungeonBlockType.StairsDown))
					{
						_startDirection = direction;
						break;
					}
				}
			}

			this.MazeGenerator.SetPathPosition(_pos);
		}
Ejemplo n.º 2
0
        private void SetRandomPathPosition()
        {
            this.MazeGenerator.StartDirection = _startDirection = (_prevFloor == null ? Direction.Down : Direction.GetOppositeDirection(_prevFloor._startDirection));

            var mt = _dungeonGenerator.RngMaze;

            if (this.HasBossRoom)
            {
                if (_dungeonGenerator.Option.Contains("largebossroom=" + '"' + "true"))                  // <option largebossroom="true" />
                {
                    while (true)
                    {
                        _pos.X = (int)(mt.GetUInt32() % (this.Width - 2) + 1);
                        _pos.Y = (int)(mt.GetUInt32() % (this.Height - 3) + 1);
                        if (this.MazeGenerator.IsFree(_pos))
                        {
                            if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y)))
                            {
                                if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y)))
                                {
                                    if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 1)))
                                    {
                                        if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y + 1)))
                                        {
                                            if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y + 1)))
                                            {
                                                if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 2)))
                                                {
                                                    if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y + 2)))
                                                    {
                                                        if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y + 2)))
                                                        {
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 1));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y + 1));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y + 1));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 2));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y + 2));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y + 2));
                }
                else
                {
                    while (true)
                    {
                        _pos.X = (int)(mt.GetUInt32() % (this.Width - 2) + 1);
                        _pos.Y = (int)(mt.GetUInt32() % (this.Height - 3) + 1);
                        if (this.MazeGenerator.IsFree(_pos))
                        {
                            if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y)))
                            {
                                if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y)))
                                {
                                    if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 1)))
                                    {
                                        if (this.MazeGenerator.IsFree(new Position(_pos.X - 1, _pos.Y + 1)))
                                        {
                                            if (this.MazeGenerator.IsFree(new Position(_pos.X + 1, _pos.Y + 1)))
                                            {
                                                if (this.MazeGenerator.IsFree(new Position(_pos.X, _pos.Y + 2)))
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 1));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X - 1, _pos.Y + 1));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X + 1, _pos.Y + 1));
                    this.MazeGenerator.MarkReservedPosition(new Position(_pos.X, _pos.Y + 2));
                }
            }
            else
            {
                var free = false;
                while (!free)
                {
                    _pos.X = (int)(mt.GetUInt32() % this.Width);
                    _pos.Y = (int)(mt.GetUInt32() % this.Height);

                    free = this.MazeGenerator.IsFree(_pos);
                }
            }

            if (!this.IsLastFloor && !HasBossRoom)
            {
                var rndDir = new RandomDirection();
                while (true)
                {
                    var direction = rndDir.GetDirection(mt);
                    if (this.SetTraits(_pos, direction, (int)DungeonBlockType.StairsDown))
                    {
                        _startDirection = direction;
                        break;
                    }
                }
            }

            this.MazeGenerator.SetPathPosition(_pos);
        }