Example #1
0
 public void descend()
 {
     current.detach(player);
     if (depth + 1 >= Levels.Count)
     {
         Level level = new Level(MapGenerater.MapGen(current.width, current.height, 100));
         Levels.Add(level);
         level.world = this;
         //Add items
         for (int i = 0; i < 15; i++)
         {
             while (true)
             {
                 int x = random.Next(0, level.width), y = random.Next(0, level.height);
                 if (current.isMove(x, y))
                 {
                     Item item = Item.createItem();
                     if (random.Next(100) < 30)
                     {
                         item.set(Item.Flags.Cursed);
                     }
                     else if (random.Next(100) < 30)
                     {
                         item.set(Item.Flags.Blessed);
                     }
                     item.pos = new System.Drawing.Point(x, y);
                     current.attach(item);
                     break;
                 }
             }
         }
         while (true)
         {
             if (random.Next(100) > 25)
             {
                 break;
             }
             while (true)
             {
                 int x = random.Next(0, level.width), y = random.Next(0, level.height);
                 if (level.isMove(x, y) && level.atTrap(new System.Drawing.Point(x, y)) == null)
                 {
                     Trap trap = Trap.Generate();
                     trap.pos = new System.Drawing.Point(x, y);
                     level.attach(trap);
                     break;
                 }
             }
         }
     }
     depth++;
     fov.load(current);
     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;
                 current.attach(player);
                 return;
             }
         }
     }
 }
Example #2
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;
                    }
                }
            }
        }