示例#1
0
        private void PlaceMobs()
        {
            for (Rectangle room = iterator.First(); !iterator.IsDone; room = iterator.Next())
            //foreach (var room in _map.Rooms)
            {
                Random pickupRandomizeCount = new Random();
                int    pickupCount          = pickupRandomizeCount.Next(3);
                Pickup pickup;
                if (pickupCount != 0)
                {
                    for (int i = 0; i < pickupCount; i++)
                    {
                        Point randomPickupPoint = _map.GetRandomFreeTile(room);
                        if (randomPickupPoint != null && _map.GetPickupAt(randomPickupPoint.X, randomPickupPoint.Y) == null)
                        {
                            int roll = Dice.Roll("1D5");
                            switch (roll)
                            {
                            case 1:
                            {
                                pickup = PickupFactory.GetInstance().getPickup(PickupType.DEF_POTION);
                                break;
                            }

                            case 2:
                            {
                                pickup = PickupFactory.GetInstance().getPickup(PickupType.STR_POTION);
                                break;
                            }

                            case 3:
                            {
                                pickup = PickupFactory.GetInstance().getPickup(PickupType.EXP_POTION);
                                break;
                            }

                            case 4:
                            {
                                pickup = PickupFactory.GetInstance().getPickup(PickupType.GOLD_COIN);
                                break;
                            }

                            case 5:
                            {
                                pickup = PickupFactory.GetInstance().getPickup(PickupType.HP_POTION);
                                break;
                            }

                            default:
                            {
                                pickup = PickupFactory.GetInstance().getPickup(PickupType.GOLD_COIN);
                                break;
                            }
                            }
                            //GoldCoin pickup = new GoldCoin();
                            //pickup.X = randomPickupPoint.X;
                            //pickup.Y = randomPickupPoint.Y;
                            _map.AddPickup(randomPickupPoint, pickup);
                        }
                    }
                }
                if (Dice.Roll("1D10") < 7)
                {
                    var numberOfMonsters = Dice.Roll("1D4");
                    if (Game.DanteMustDie)
                    {
                        numberOfMonsters = 7;
                    }
                    else if (Game.KoboldKarnage)
                    {
                        numberOfMonsters = room.Height * room.Width - 10;
                    }
                    if (numberOfMonsters < 1)
                    {
                        numberOfMonsters = 1;
                    }
                    for (int i = 0; i < numberOfMonsters; i++)
                    {
                        CreationType type;
                        var          typeDecider = Dice.Roll("1D100");
                        if (typeDecider <= 60)
                        {
                            type = CreationType.NORMAL;
                        }
                        else if (typeDecider <= 80)
                        {
                            type = CreationType.WEAK;
                        }
                        else if (typeDecider <= 92)
                        {
                            type = CreationType.MINI_BOSS;
                        }
                        else
                        {
                            type = CreationType.BOSS;
                        }



                        Point randomRoomLocation = _map.GetRandomFreeTile(room);
                        if (randomRoomLocation != null)
                        {
                            int level = Player.GetInstance().Level + Facade._mapLevel + Dice.Roll("1D5") - Dice.Roll("1D5");
                            if (level < 1)
                            {
                                level = 1;
                            }
                            int whatMonster = Dice.Roll("1D100");
                            if (Game.KoboldKarnage)
                            {
                                whatMonster = 1;
                            }
                            if (whatMonster <= 25)
                            {
                                Monster monster = MonsterFactoryStore.getFactory(FactoryType.KOBOLD).Create(type);
                                monster.SetAttributes(level);
                                monster.X = randomRoomLocation.X;
                                monster.Y = randomRoomLocation.Y;
                                _map.AddMonster(monster);
                            }
                            else if (whatMonster <= 50)
                            {
                                Monster monster = MonsterFactoryStore.getFactory(FactoryType.ORC).Create(type);
                                monster.SetAttributes(level);
                                monster.X = randomRoomLocation.X;
                                monster.Y = randomRoomLocation.Y;
                                _map.AddMonster(monster);
                            }
                            else if (whatMonster <= 90)
                            {
                                Monster monster = MonsterFactoryStore.getFactory(FactoryType.GOBLIN).Create(type);
                                monster.SetAttributes(level);
                                monster.X = randomRoomLocation.X;
                                monster.Y = randomRoomLocation.Y;
                                _map.AddMonster(monster);
                            }
                            else if (whatMonster <= 95)
                            {
                                Monster monster = MonsterFactoryStore.getFactory(FactoryType.BEHOLDER).Create(type);
                                monster.SetAttributes(level);
                                monster.X = randomRoomLocation.X;
                                monster.Y = randomRoomLocation.Y;
                                _map.AddMonster(monster);
                            }
                            else if (whatMonster <= 100)
                            {
                                Monster monster = MonsterFactoryStore.getFactory(FactoryType.GOBLIN_SHAMAN).Create(type);
                                monster.SetAttributes(level);
                                monster.X = randomRoomLocation.X;
                                monster.Y = randomRoomLocation.Y;
                                _map.AddMonster(monster);
                            }
                        }
                    }
                }
            }
        }