static Item createItem(Type type, int id) { switch (type) { case Type.Armor: Armor armor = new Armor(id); armor.Count = 1; return(armor); case Type.Weapon: Weapon weapon = new Weapon(id); weapon.Count = 1; return(weapon); case Type.Ring: Ring ring = new Ring(id); ring.Count = 1; return(ring); case Type.Potion: Potion potion = new Potion(id); potion.Count = 1; return(potion); case Type.Food: Food food = new Food(id); food.Count = 1; return(food); case Type.Stick: Stick stick = new Stick(id); stick.Count = 1; return(stick); case Type.Scroll: Scroll scroll = new Scroll(id); scroll.Count = 1; return(scroll); } return(null); }
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; } } } }