Exemple #1
0
        public void process()
        {
            for (int i = 0; i < 2; i++)
            {
                if (fHearingCount[i] > 0)
                {
                    fHearingCount[i]--;
                    if (fHearingCount[i] == 0)
                    {
                        fNoiseLevel[i] = 0;
                    }
                }
            }
            for (int i = 0; i < 3; i++)
            {
                if (fScentCount[i] > 0)
                {
                    fScentCount[i]--;
                }
            }
            if (fMuck > 0)
            {
                fMuck--;
            }

            if (fSpawn && fLair != null)
            {
                int interval = kLairProduction * fLair.getKillScore();
                // halve the interval (+1) if the lair is empty
                if (!GameEngine.instance.hasMonster(this))
                {
                    interval = (interval + 1) / 2;
                }
                if (interval < kLairProduction)
                {
                    interval = kLairProduction;
                }
                // double the interval if the lair has but one door
                if (this.getNumPassages() == 0)
                {
                    interval *= 2;
                }

                for (int i = 0; i < fLairCount; i++)
                {
                    if (GameEngine.rand.range(1, interval) == 1)
                    {
                        if (GameEngine.instance.canAddMonsters())
                        {
                            Monster monster = this.createMonster();
                            monster.setRoom(this);
                            this.fCoins = this.fCoins + 1;
                            if (!GameEngine.instance.addMonster(monster))
                            {
                                fMonsterBuffer++;
                            }
                            if (GameEngine.rand.range(0, 1) == 1)                      // half are stationary
                            {
                                monster.setStationary(true);
                            }
                            if (GameEngine.fDisplayDebugInfo)
                            {
                                Utility.Assert(false, monster.getMonsterDescription() + " entered the maze in room " + this.getRoomNumber());
                            }
                            Utility.Trace(monster.getMonsterDescription() + " entered the maze in room " + this.getRoomNumber());
                        }
                        else
                        {
                            fMonsterBuffer++;
                        }
                    }
                }
                if (fMonsterBuffer > 0 && (this.getNumPassages() > 0 || (this.hasDoor() && this.isDoorOpen())))
                {
                    int count = fMonsterBuffer / 10 + 1;
                    for (int i = 0; i < count; ++i)
                    {
                        if (GameEngine.instance.canAddMonsters())
                        {
                            Utility.Trace("Entering buffered monsters in room " + this.getRoomNumber());
                            Monster monster = this.createMonster();
                            monster.setRoom(this);
                            if (GameEngine.instance.addMonster(monster))
                            {
                                fMonsterBuffer--;
                            }
                            monster.setStationary(false);                     // none are stationary
                            if (GameEngine.fDisplayDebugInfo)
                            {
                                Utility.Assert(false, monster.getMonsterDescription() + " entered the maze in room " + this.getRoomNumber());
                            }
                            Utility.Trace(monster.getMonsterDescription() + " entered the maze in room " + this.getRoomNumber());
                        }
                    }
                }
            }
        }
Exemple #2
0
        override public void displayKill(Monster[] monsters, Room room, Staff staff, bool splinter)
        {
            fShotsFired++;
            bool magic = false;

            if (staff != null)
            {
                magic = true;
            }
            Player player = fEngine.getCurrentPlayer();
            String str    = "";

            if (player.fRoom == room)
            {
                if (magic)
                {
                    str = "You fire a lightning bolt with your " + Staff.TYPE_STRING[staff.getType()] + " staff!\n";
                }
            }
            else
            {
                if (magic)
                {
                    str = "You fire a lightning bolt to cavern " + room.getRoomNumber() + ".\n";
                }
                else
                {
                    str = "You fire an arrow to cavern " + room.getRoomNumber() + ".\n";
                }
            }

            if (splinter)
            {
                str += "Your " + Staff.TYPE_STRING[staff.getType()] + " staff splintered!\n";
                if (fShooting)
                {
                    fShotsFired = player.getNumBolts();
                }
                else
                {
                    fShotsFired = player.getNumBalls();
                }
                int damage = GameEngine.rand.range(0, 2);
                player.applyDamage(damage);
                if (!player.isAlive())
                {
                    str += "\nYou're dead.\n";
                }
                player.makeNoise(Player.kFightNoise);
            }

            if (monsters.Length == 0)
            {
                str += "That wasn't very clever, was it?";
            }

            for (int i = 0; i < monsters.Length; i++)
            {
                Monster monster = monsters[i];
                if (monster.isAlive())
                {
                    str += "You wounded ";
                }
                else
                {
                    str += "You killed ";
                }
                str += monster.getMonsterDescription() + "\n";
            }
            System.Console.WriteLine(str);

            if (fShooting)
            {
                if (fEngine.hasAdjacentMonster(player.fRoom))
                {
                    if (!magic && fShotsFired < player.getMaxNumShots() && player.fArrows > 0)
                    {
                        fEngine.doCommandShootArrow();
                        return;
                    }
                    if (magic && fShotsFired < player.getNumBolts() && player.hasChargedStaff())
                    {
                        fEngine.doCommandCastLightningBolt();
                        return;
                    }
                }
            }
            else
            {
                if (fEngine.hasMonster(player.fRoom))
                {
                    if (magic && fShotsFired < player.getNumBalls() && player.hasChargedStaff())
                    {
                        fEngine.doCommandCastFireball();
                        return;
                    }
                }
            }

            fEngine.processNextPlayer();
        }