Пример #1
0
        public World(int _w, int _h)
        {
            w = _w;
            h = _w;
            Level level = new Level(MapGenerater.MapGen(_w, _h, 100));

            level.world = this;
            Levels.Add(level);
            //Add items
            int items = random.Next(3, 10);

            for (int i = 0; i < items; i++)
            {
                while (true)
                {
                    int x = random.Next(current.width), y = random.Next(current.height);
                    if (current.isMove(x, y))
                    {
                        Item item = Item.createItem();
                        item.pos = new System.Drawing.Point(x, y);
                        if (random.Next(100) < 30)
                        {
                            item.set(Item.Flags.Cursed);
                        }
                        else if (random.Next(100) < 30)
                        {
                            item.set(Item.Flags.Blessed);
                        }
                        current.attach(item);
                        break;
                    }
                }
            }
            fov = new Fov(_w, _h);
            fov.load(level);
            fov.setIntensity(10.0f);
            Item weapon = new Weapon(0);

            weapon.Count = 10 + random.Next(10);
            weapon.set((1 << (int)Item.Flags.Many) | (1 << (int)Item.Flags.Blessed) | (1 << (int)Item.Flags.Identified));
            Item stick = new Stick(1);

            weapon.set((1 << (int)Item.Flags.Identified) | (1 << (int)Item.Flags.Blessed));
            Item potion = new Potion(0);

            potion.set((1 << (int)Item.Flags.Many) | (1 << (int)Item.Flags.Blessed) | (1 << (int)Item.Flags.Identified));
            potion.Count = 10 + random.Next(10);
            weapon.set(Item.Flags.Many);
            player.addPack(ref weapon);
            player.addPack(ref stick);
            player.addPack(ref potion);
            for (int x = current.width - 1; x >= 0; x--)
            {
                for (int y = current.height - 1; y >= 0; y--)
                {
                    if (current.isMove(x, y))
                    {
                        player.pos.X = x;
                        player.pos.Y = y;
                        level.attach(player);
                        return;
                    }
                }
            }
        }