public Item GetItemFromSavefile(string section) { float quantity = 0; ItemVariety var; ShipPart fooItem; switch (GetPropertyAsString(section, "name", "error")) { // Weapons case "basic laser": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new BasicLaserWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "beam": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new BeamWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "drill beam": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new DrillBeamWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "flame shot": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new FlameShotWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "multiple shot": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new MultipleShotWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "spread bullet": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new SpreadBulletWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "ballistic laser": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new BallisticLaserWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "minelayer": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new MineLayerWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "advanced laser": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new AdvancedLaserWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "proximity laser": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new ProximityLaserWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "wave beam": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new WaveBeamWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "dual laser": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new DualLaserWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); // Secondary case "homingmissile": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new HomingMissileWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "bomb": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new RegularBombWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "sidemissiles": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new SideMissilesWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "fragmentmissile": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new FragmentMissileWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "puny turret": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new PunyTurretWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "turret": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new TurretWeapon(Game); fooItem.SetShipPartVariety(var); return(fooItem); // Shields case "regular shield": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new RegularShield(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "plasma shield": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new AdvancedShield(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "durable shield": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new BasicShield(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "collision shield": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new CollisionShield(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "bullet shield": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new BulletShield(Game); fooItem.SetShipPartVariety(var); return(fooItem); // Energy case "regular cell": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new RegularEnergyCell(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "durable cell": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new BasicEnergyCell(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "plasma cell": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new AdvancedEnergyCell(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "weapon boost cell": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new WeaponBoostEnergyCell(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "shield boost cell": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new ShieldBoostEnergyCell(Game); fooItem.SetShipPartVariety(var); return(fooItem); // Plating case "regular plating": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new RegularPlating(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "light plating": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new LightPlating(Game); fooItem.SetShipPartVariety(var); return(fooItem); case "heavy plating": var = (ItemVariety)Enum.Parse(typeof(ItemVariety), GetPropertyAsString(section, "variety", "none"), true); fooItem = new HeavyPlating(Game); fooItem.SetShipPartVariety(var); return(fooItem); // Resource case "copper": quantity = Game.saveFile.GetPropertyAsInt(section, "quantity", 0); return(new CopperResource(Game, quantity)); case "gold": quantity = Game.saveFile.GetPropertyAsInt(section, "quantity", 0); return(new GoldResource(Game, quantity)); case "titanium": quantity = Game.saveFile.GetPropertyAsInt(section, "quantity", 0); return(new TitaniumResource(Game, quantity)); // Other items case "fine whiskey": quantity = Game.saveFile.GetPropertyAsInt(section, "quantity", 0); return(new FineWhiskey(Game, quantity)); case "---": return(new EmptyItem(Game)); default: throw new ArgumentException("Not implemented!"); } }
// Appends items to item pool public void UpdateItemPool() { Random random = new Random(); Sprite sprite = Game.stateManager.shooterState.spriteSheet; itemPool.Clear(); Item tempItem = null; int itemsToAdd = 3 + random.Next(7) + 1; for (int i = 0; i < itemsToAdd; i++) { switch (random.Next(14)) { case 0: tempItem = new BasicLaserWeapon(this.Game, ItemVariety.Regular); break; case 1: tempItem = new MultipleShotWeapon(this.Game, ItemVariety.Regular); break; case 2: tempItem = new SpreadBulletWeapon(this.Game, ItemVariety.Regular); break; case 3: tempItem = new BeamWeapon(this.Game, ItemVariety.Regular); break; case 4: tempItem = new RegularBombWeapon(this.Game, ItemVariety.Regular); break; case 5: tempItem = new HomingMissileWeapon(this.Game, ItemVariety.Regular); break; case 6: tempItem = new SideMissilesWeapon(this.Game, ItemVariety.Regular); break; case 7: tempItem = new DrillBeamWeapon(this.Game, ItemVariety.Regular); break; case 8: tempItem = new BasicShield(this.Game, ItemVariety.Regular); break; case 9: tempItem = new AdvancedShield(this.Game, ItemVariety.Regular); break; case 10: tempItem = new RegularShield(this.Game, ItemVariety.Regular); break; case 11: tempItem = new BasicEnergyCell(this.Game, ItemVariety.Regular); break; case 12: tempItem = new AdvancedEnergyCell(this.Game, ItemVariety.Regular); break; case 13: tempItem = new RegularEnergyCell(this.Game, ItemVariety.Regular); break; } itemPool.Add(tempItem); } if (itemPool.Count < 14) { int tempCount = itemPool.Count; for (int i = tempCount; i < 14; i++) { itemPool.Add(new EmptyItem(this.Game)); } } }