public void saveInventory() { List <ItemAbstract> items = new List <ItemAbstract>(); foreach (string key in inventory.Keys) { ItemAbstract item = ItemDefinitions.stringToItem(key); for (int i = 0; i < inventory[key]; i++) { items.Add(item); } } ItemDefinitions.saveItems(uniqueId, ItemDefinitions.itemsToString(items)); /* * string invSlotLabel = uniqueId + "InventorySlotLabel[Weapon]"; * for (int i = 0; i < WeaponItem.numWeaponTypes; i++) * { * string currLabel = invSlotLabel + i.ToString(); * print("Saving weapon item: " + i + " and num = " + numOfEachWeapItem[i]); * UnityEngine.PlayerPrefs.SetInt(currLabel, numOfEachWeapItem[i]); * } * invSlotLabel = uniqueId + "InventorySlotLabel[Engine]"; * for (int i = 0; i < EngineItem.numEngineTypes; i++) * { * string currLabel = invSlotLabel + i.ToString(); * print("Saving engine item: " + i + " and num = " + numOfEachEngItem[i]); * UnityEngine.PlayerPrefs.SetInt(currLabel, numOfEachEngItem[i]); * } */ }
public void exit() { List <ItemAbstract> playerItems = playerItemList.getAllItems(); ItemDefinitions.saveItems("Player", ItemDefinitions.itemsToString(playerItems)); List <ItemAbstract> merchantItems = merchantItemList.getAllItems(); ItemDefinitions.saveItems(merchantId, ItemDefinitions.itemsToString(merchantItems)); playerInventory.saveCurrency(); merchantInventory.saveCurrency(); loadPreviousLevel(); }
public void callEvent(string param) { string[] full = param.Split(' '); string eventName = full[0]; switch (eventName) { case "print": printTest(); break; case "dialogue": if (full.Length != 2) { print("ERROR: dialogue called but no character name given!"); return; } dialogue(full[1]); break; case "scene": if (full.Length != 2) { print("ERROR: scene called but no scene given!"); return; } loadScene(full[1]); break; case "trigger": { if (full.Length != 2) { print("ERROR: trigger called but no scene given!"); return; } triggerLevel(full[1]); break; } case "money": { if (full.Length != 2) { print("ERROR: money called but no value given!"); return; } money(int.Parse(full[1])); break; } case "addmoney": { if (full.Length != 2) { print("ERROR: money called but no value given!"); return; } addmoney(int.Parse(full[1])); break; } case "hack": { addmoney(1000); List <ItemAbstract> items = new List <ItemAbstract>(); items.Add(new EngineItem(EngineItem.EngineType.Spinjet, 4)); items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 1)); items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRange, 2)); items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 4)); items.Add(new WeaponItem(WeaponItem.WeaponType.MissileModAmmoCap, 1)); items.Add(new WeaponItem(WeaponItem.WeaponType.MissileModAmmoCap, 1)); ItemDefinitions.saveItems("Player", ItemDefinitions.itemsToString(items)); List <ItemAbstract> aitems = new List <ItemAbstract>(); aitems.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 1)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 2)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 4)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRange, 2)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRechargeRate, 3)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.FlameModAmmoCap, 2)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.FlameModAmmoCap, 2)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 3)); aitems.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 1)); ItemDefinitions.saveItems("MerchantTest", ItemDefinitions.itemsToString(items)); break; } } }