IEnumerator LoadDelay()
        {
            yield return(0);

            Q_Inventory            playerInventory        = Q_GameMaster.Instance.inventoryManager.playerInventory;
            PlayerInventoryManager playerInventoryManager = Q_GameMaster.Instance.inventoryManager.playerInventoryManager;
            InventorySaveData      saveData           = Q_GameMaster.Instance.inventoryManager.itemDataBase.saveData;
            GameObject             equipmentContainer = Q_GameMaster.Instance.inventoryManager.m_EquipmentContainer;

            foreach (var item in saveData.playerInventoryItems)
            {
                for (int i = 0; i < item.amount; i++)
                {
                    playerInventory.AddItem(item.item.ID);
                }
            }

            for (int i = 0; i < saveData.playerAttributes.Count; i++)
            {
                playerInventoryManager.playerAttributes[i].currentValue = saveData.playerAttributes[i].currentValue;
                playerInventoryManager.playerAttributes[i].minValue     = saveData.playerAttributes[i].minValue;
                playerInventoryManager.playerAttributes[i].maxValue     = saveData.playerAttributes[i].maxValue;
            }

            for (int i = 0; i < saveData.playerCurrencies.Count; i++)
            {
                playerInventoryManager.playerCurrencies[i].amount = saveData.playerCurrencies[i].amount;
            }

            for (int i = 0; i < saveData.onEquipmentItems.Count; i++)
            {
                playerInventory.AddItem(saveData.onEquipmentItems[i]).WearEquipmentItemWithoutChangeAttribute();
            }
        }
        public void Load()
        {
            //Player
            Q_Inventory            playerInventory        = Q_GameMaster.Instance.inventoryManager.playerInventory;
            PlayerInventoryManager playerInventoryManager = Q_GameMaster.Instance.inventoryManager.playerInventoryManager;
            InventorySaveData      saveData           = Q_GameMaster.Instance.inventoryManager.itemDataBase.saveData;
            GameObject             equipmentContainer = Q_GameMaster.Instance.inventoryManager.m_EquipmentContainer;

            for (int i = 0; i < equipmentContainer.transform.childCount; i++)
            {
                if (equipmentContainer.transform.GetChild(i).childCount == 2)
                {
                    ItemData data = equipmentContainer.transform.GetChild(i).GetChild(1).GetComponent <ItemData>();
                    data.UnwearItemWithoutAdd();
                }
            }

            playerInventory.ClearAllItems();

            StartCoroutine(LoadDelay());
        }
示例#3
0
        //用于实现制作CD的
        IEnumerator AddCraftingItem(ItemData itemdata)
        {
            int amount = itemdata.amountToCraft;

            CostIngredients(itemdata.m_CraftingBluePrint.ingredients, amount);
            PlayerInventoryManager.UpdatePlayerCurrency(itemdata.m_CraftingBluePrint.craftingPrices, -1 * amount);
            //Debug.Log(amount);
            for (int i = 0; i < amount; i++)
            {
                StartCD(itemdata.slot, itemdata.m_CraftingBluePrint.craftingTime);
                if (itemdata.m_CraftingBluePrint.CDAllWhenCrafting)
                {
                    AllStartCD(itemdata.m_CraftingBluePrint.craftingTime);
                }

                yield return(new WaitForSeconds(itemdata.m_CraftingBluePrint.craftingTime));

                int chance = Random.Range(0, 100);
                if (chance < itemdata.m_CraftingBluePrint.successChance * 100)
                {
                    Debug.Log("Crafting Success");
                    //废用的,直接加到玩家背包里,他们说不好
                    //playerInventory.AddItem(id);

                    //现在是在指定合成地点掉落
                    Instantiate(Q_GameMaster.Instance.inventoryManager.itemDataBase.getItemByID(itemdata.item.ID).m_object, craftingSpawningPosition.position + spawnOffset, Quaternion.identity);
                    itemdata.inputField.text = (--itemdata.amountToCraft).ToString();
                }


                else
                {
                    Debug.Log("Crafting Failed");
                }
            }

            itemdata.amountToCraft   = 1;
            itemdata.isCrafting      = false;
            itemdata.inputField.text = (itemdata.amountToCraft).ToString();
        }
示例#4
0
        //卖东西
        public void SellItem()
        {
            PlayerInventoryManager.UpdatePlayerCurrency(item.sell_Price, amount);

            ClearItem();
        }
示例#5
0
 void AddCurrency()
 {
     PlayerInventoryManager.UpdatePlayerCurrency(currencyAmounts, 1);
     Destroy(gameObject);
 }
 public static void ChangePlayerCurrency(List <Price> prices, int itemAmount)
 {
     PlayerInventoryManager.UpdatePlayerCurrency(prices, itemAmount);
 }
 public static float GetPlayerCurrency(string name)
 {
     return(PlayerInventoryManager.FindPlayerCurrencyByName(name));
 }
 public static void SetPlayerAttributeValue(string attributeName, float amount, SetType type)
 {
     PlayerInventoryManager.SetPlayerAttributeByName(attributeName, amount, type);
 }
 public static void ChangePlayerAttributeValue(string attributeName, float amount, Effect effect)
 {
     PlayerInventoryManager.ChangePlayerAttributeByName(attributeName, amount, effect);
 }
 public static float GetPlayerAttributeMinValue(string attributeName)
 {
     return(PlayerInventoryManager.FindPlayerAttributeMinValueByName(attributeName));
 }