Beispiel #1
0
        protected Room huntPrey()
        {
            //		if (fLastHunt != null)
            //			fHunting = true;

            // if alive player in room, stay and fight
            //		if (GameEngine.instance.hasPlayer(fRoom))
            //			return fRoom;

            // else follow trail (if present)
            Room room = fRoom.getHearCandidate(this.getHearing());

            if (room != null)
            {
                Utility.Trace(this.getMonsterDescription() + " is following hearing from room " + fRoom.getRoomNumber() + " to " + room.getRoomNumber());
                //                  + " and makes noise");
                //             this.makeNoise(Player.kFightNoise, fRoom);
            }
            else
            {
                room = fRoom.getScentCandidate();
                if (room != null)
                {
                    Utility.Trace(this.getMonsterDescription() + " is following scent from room " + fRoom.getRoomNumber() + " to " + room.getRoomNumber());
                }
            }

            // if alive player in room, stay and fight,
            // unless there is another player in the next room!
            // if alive player in room, stay and fight, unless there is fighting to be had in another room, in which
            // case the monster has a hard time deciding...
            if (room != null)
            {
                if (fTargetRoom == null)
                {
                    fTargetRoom = room.getRandomPassage(fRoom);
                    if (fTargetRoom == fRoom)
                    {
                        fTargetRoom = room;
                    }
                }
                if (GameEngine.instance.hasPlayer(fRoom))
                {
                    if (GameEngine.rand.range(0, 1) == 0)
                    {
                        return(fRoom);
                    }
                }
            }
            //      if (GameEngine.instance.hasPlayer(fRoom))
            //      {
            //          if (room != null && !GameEngine.instance.hasPlayer(room))
            //          {
            //              return fRoom;
            //          }
            //      }

            fHunting = true;

            if (room == null && fTargetRoom != null)
            {
                Room[] path = GameEngine.instance.fMaze.findRoute(fRoom, fTargetRoom, null, Maze.USE_OPEN_DOORS);
                if (path.Length > 0)
                {
                    room = path[0];
                }
            }
            else if (room != null)
            {
                if (!fRoom.isPassable(room))
                {
                    room = fRoom.getRandomPassage(fLastRoom);
                }
            }

            if (room == null)
            {
                fHunting = false;
            }
            else
            {
                fStationary = false;
            }

            if (fHunting)
            {
                //          Utility.Trace(this.getMonsterDescription() + " hunts prey and makes noise");
                //          this.makeNoise(Player.kFightNoise);
            }
            return(room);
        }