/// <summary> /// 加载背包数据 /// </summary> public void LoadInventory() { //mSlotList.Clear(); if (PlayerPrefs.HasKey("DIAZDownTownRPG") == false) { return; } string str = PlayerPrefs.GetString("DIAZDownTownRPG"); //print(str); string[] itemArray = str.Split('-'); for (int i = 0; i < itemArray.Length - 1; i++) { string itemStr = itemArray[i]; if (itemStr != "0") { //print(itemStr); string[] temp = itemStr.Split(','); int id = int.Parse(temp[0]); Item item = ItemsData.GetItemByID(id); int amount = int.Parse(temp[1]); for (int j = 0; j < amount; j++) { mSlotList[i].StoreItem(item); } } } Debug.Log("加载物品 ++++++ " + mSlotList.Count.ToString()); }
public bool StoreItem(int id) { Item item = ItemsData.GetItemByID(id); if (item.IsNotNull()) { return(StoreItem(ItemsData.GetItemByID(id))); } else { Debug.Log("没有找到对应id的item··"); return(false); } }