Пример #1
0
        /// <summary>
        /// Add a monster with a random patrol. Needs the mapgenerator of the level in question
        /// </summary>
        /// <param name="monster"></param>
        /// <param name="mapGen"></param>
        private void AddMonsterSquarePatrol(MonsterFightAndRunAI monster, int level, MapGenerator mapGen)
        {
            Dungeon dungeon = Game.Dungeon;

            Point startLocation;

            int loops = 0;
            int maxLoops = 50;

            do
            {
                CreaturePatrol patrol = mapGen.CreatureStartPosAndWaypoints(monster.GetPatrolRotationClockwise());
                monster.Waypoints = patrol.Waypoints;
                startLocation = patrol.StartPos;

                loops++;
            } while (!Game.Dungeon.AddMonster(monster, level, startLocation) && loops < maxLoops);

            if (loops == maxLoops)
            {
                LogFile.Log.LogEntryDebug("Failed to place patrolling monster: " + monster.Representation, LogDebugLevel.High);
            }
        }
Пример #2
0
        /// <summary>
        /// Add a monster with a random patrol. Needs the mapgenerator of the level in question
        /// </summary>
        /// <param name="monster"></param>
        /// <param name="mapGen"></param>
        private void AddMonsterLinearPatrol(MonsterFightAndRunAI monster, int level, MapGenerator mapGen)
        {
            Dungeon dungeon = Game.Dungeon;

            Point startLocation;

            int loops = 0;
            int maxLoops = 50;

            bool success = false;

            do
            {
                CreaturePatrol patrol = mapGen.CreatureStartPosAndWaypointsSisterRooms(monster.GetPatrolRotationClockwise(), 3);
                monster.Waypoints = patrol.Waypoints;
                startLocation = patrol.StartPos;

                loops++;

                success = Game.Dungeon.AddMonster(monster, level, startLocation);

                //Linear patrols start from the centre of rooms so monsters often overlap in small number of room levels
                //Try with a random point
                if(!success)
                    success = Game.Dungeon.AddMonster(monster, level, patrol.StartRoom.RandomPointInRoom());

            } while (!success && loops < maxLoops);

            if (loops == maxLoops)
            {
                LogFile.Log.LogEntryDebug("Failed to place patrolling monster: " + monster.Representation, LogDebugLevel.High);
            }
        }