Exemple #1
0
        protected Staircase CreateStaircase(MapState state, int mapIndex, Staircase.StaircaseDirection stairDirection)
        {
            bool     foundPosition = false;
            Position stairPosition = null;

            // We need to make sure that we aren't spawning staircases on top of each other.
            while (!foundPosition)
            {
                stairPosition = state.SelectRandomWalkableTile(true);

                if (state.Map.Stairs.Where(s => s.Location.Equals(stairPosition)).FirstOrDefault() == null)
                {
                    foundPosition = true;
                }
            }

            DungeonLocation location = new DungeonLocation(this, mapIndex, stairPosition);

            return(new Staircase(location, stairDirection));
        }