Beispiel #1
0
 // Remembers the saved item if it existed
 public override void RememberHeldItem()
 {
     ItemIDHeld = PlayerPrefs.GetString("GauntletsID" + SlotNumber, "None");
     if (ItemIDHeld == "None")
     {
         //Debug.Log("Nothing Loaded; ID: 'None'");
         SlotWeight = 0;
         ItemsHeld  = 0;
     }
     else
     {
         ItemsHeld = PlayerPrefs.GetInt("GauntletsCount" +
                                        "" + SlotNumber, 1);
         string[]      str = ItemIDHeld.Split('-');
         ItemCatalogue cat = Resources.Load <ItemCatalogue>("Prefabs/Items/Catalogue/" + str[0]);
         if (cat != null)
         {
             cat = Instantiate(cat);
             //Debug.Log(cat.gameObject.name + " Loaded");
             if (cat.FindObjectID(str[0], int.Parse(str[1])) != null)
             {
                 HeldItem = Instantiate(cat.FindObjectID(str[0], int.Parse(str[1])));
             }
             if (HeldItem != null)
             {
                 //Debug.Log(HeldItem.gameObject.name + " Loaded (ID: " + HeldItem.itemID + ")");
                 HeldItem.transform.parent        = ParentInventory.transform;
                 HeldItem.transform.localPosition = Vector3.zero;
             }
         }
         if (HeldItem == null)
         {
             string Name       = PlayerPrefs.GetString(ItemIDHeld);
             Item   folderItem = Resources.Load <Item>("Prefabs/Items/" + Name + ".prefab");
             if (folderItem != null)
             {
                 HeldItem = Instantiate(folderItem, ParentInventory.transform);
             }
         }
         Destroy(cat.gameObject);
         if (HeldItem != null)
         {
             Durability = PlayerPrefs.GetInt("GauntletID_Durability" + SlotNumber, Durability);
             SetDurability(Durability);
             HeldItem.SetStack(ItemsHeld);
             ItemsHeld = HeldItem.stackCount;
             SetHeldItem();
             HeldItem.DeactivateItem();
         }
     }
     UpdateItemDisplay();
 }