public void GenerateItems() { int uid = 0; foreach (var tile in _map.Layers[(int)Layer.Meta].Tiles) { switch ((MetaTile)tile.Gid) { case MetaTile.Melee: var melee = new MeleeWeapon(); melee.Copy(EntityStore.MeleeWeapons[_randomGenerator.Next(1, EntityStore.MeleeWeapons.Count)]); melee.Init(); melee.position = new Point(tile.X, tile.Y); melee.uid = uid; items.Add(melee); uid++; break; case MetaTile.Pistol: var pistol = new RangedWeapon(); pistol.Copy(EntityStore.RangedWeapons[_randomGenerator.Next(0, EntityStore.RangedWeapons.Count)]); pistol.Init(); pistol.position = new Point(tile.X, tile.Y); pistol.uid = uid; items.Add(pistol); uid++; break; default: break; } } }
public static Item GetItemWithId(string id) { foreach (var melee in MeleeWeapons) { if (melee.id == id) { var copy = new MeleeWeapon(); copy.Copy(melee); copy.Init(); return(copy); } } foreach (var firearm in RangedWeapons) { if (firearm.id == id) { var copy = new RangedWeapon(); copy.Copy(firearm); copy.Init(); return(copy); } } return(null); }