コード例 #1
0
        protected virtual bool CanRemoveRequiredItems(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.removeItemsFromCollection != null && craftInfo.removeItemsFromCollection.useReferences == false)
            {
                foreach (var item in craftInfo.blueprint.requiredItems)
                {
                    uint count = craftInfo.removeItemsFromCollection.GetItemCount(item.item.ID);
                    if (count < item.amount * craftInfo.craftAmount)
                    {
                        return(false);
                    }
                }

                return(true);
            }

            foreach (var item in craftInfo.blueprint.requiredItems)
            {
                uint count = InventoryManager.GetItemCount(item.item.ID, craftInfo.category.alsoScanBankForRequiredItems);
                if (count < item.amount * craftInfo.craftAmount)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
 protected virtual void NotifyOnCraftStart(CraftingProgressContainer.CraftInfo craftInfo)
 {
     if (OnCraftStart != null)
     {
         OnCraftStart(craftInfo);
     }
 }
コード例 #3
0
 protected virtual void NotifyOnCraftCancelled(CraftingProgressContainer.CraftInfo craftInfo, float progress)
 {
     if (OnCraftCancelled != null)
     {
         OnCraftCancelled(craftInfo, progress);
     }
 }
コード例 #4
0
        protected virtual bool CanAddItemsRewardItems(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.storeItemsInCollection != null)
            {
                var before = craftInfo.storeItemsInCollection.canPutItemsInCollection;
                craftInfo.storeItemsInCollection.canPutItemsInCollection = true;


                var l = new List <ItemAmountRow>();
                for (int i = 0; i < craftInfo.craftAmount; i++)
                {
                    l.AddRange(craftInfo.blueprint.resultItems);
                }

                if (craftInfo.storeItemsInCollection.CanAddItems(l.ToArray()) == false)
                {
                    return(false);
                }

                bool stored = craftInfo.storeItemsInCollection.CanAddItems(l.ToArray());

                craftInfo.storeItemsInCollection.canPutItemsInCollection = before;
                return(stored);
            }

            if (InventoryManager.IsInventoryCollection(removeItemsFromCollection))
            {
                return(InventoryManager.CanRemoveItemsThenAdd(craftInfo.blueprint.resultItems, craftInfo.blueprint.requiredItems));
            }

            return(InventoryManager.CanAddItems(craftInfo.blueprint.resultItems));
        }
コード例 #5
0
 protected virtual void NotifyOnCraftFailed(CraftingProgressContainer.CraftInfo craftInfo)
 {
     if (OnCraftFailed != null)
     {
         OnCraftFailed(craftInfo);
     }
 }
コード例 #6
0
        public virtual void GiveCraftReward(CraftingProgressContainer.CraftInfo craftInfo)
        {
            var itemsToAdd = InventoryItemUtility.RowsToItems(craftInfo.blueprint.resultItems, true);

#if UFPS_MULTIPLAYER
            foreach (var item in itemsToAdd)
            {
                var i = item as Devdog.InventoryPro.Integration.UFPS.UFPSInventoryItemBase;
                if (i != null && Devdog.InventoryPro.Integration.UFPS.Multiplayer.InventoryMPUFPSPickupManager.instance != null)
                {
                    Devdog.InventoryPro.Integration.UFPS.Multiplayer.InventoryMPUFPSPickupManager.instance.InstantiateAndRegisterPickupOnAllClients(i);
                }
            }
#endif

            if (craftInfo.storeItemsInCollection != null)
            {
                var before = craftInfo.storeItemsInCollection.canPutItemsInCollection;
                craftInfo.storeItemsInCollection.canPutItemsInCollection = true;

                bool added = craftInfo.storeItemsInCollection.AddItems(itemsToAdd);

                craftInfo.storeItemsInCollection.canPutItemsInCollection = before;

                Assert.IsTrue(added, "Couldn't add items even though check passed. Please report this error + stack trace.");
            }
            else
            {
                // Store crafted item
                bool added = InventoryManager.AddItems(itemsToAdd);
                Assert.IsTrue(added, "Couldn't add items even though check passed. Please report this error + stack trace.");
            }
        }
コード例 #7
0
        protected virtual void NotifyOnCraftProgress(CraftingProgressContainer.CraftInfo craftInfo, float progress)
        {
            blueprintCraftingProgress.Repaint(progress, 1f);

            if (OnCraftProgress != null)
            {
                OnCraftProgress(craftInfo, progress);
            }
        }
コード例 #8
0
        private void NotifyOnCraftCancelled(CraftingProgressContainer.CraftInfo craftInfo, float progress)
        {
            if (craftInfo.validator.gameObject != gameObject)
            {
                return;
            }

            if (OnCraftCancelled != null)
            {
                OnCraftCancelled(craftInfo, progress);
            }
        }
コード例 #9
0
        private void NotifyOnCraftSuccess(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.validator.gameObject != gameObject)
            {
                return;
            }

            if (OnCraftSuccess != null)
            {
                OnCraftSuccess(craftInfo);
            }
        }
コード例 #10
0
        private void NotifyOnCraftStart(CraftingProgressContainer.CraftInfo craftInfo)
        {
            if (craftInfo.validator.gameObject != gameObject)
            {
                return;
            }

            Debug.Log("On craft start on " + gameObject.name + " validator : " + craftInfo.validator.gameObject.name, gameObject);
            if (OnCraftStart != null)
            {
                OnCraftStart(craftInfo);
            }
        }
コード例 #11
0
        /// <summary>
        /// Does the inventory contain the required items?
        /// </summary>
        public override bool CanCraftBlueprint(InventoryPlayer player, CraftingProgressContainer.CraftInfo craftInfo)
        {
            bool can = base.CanCraftBlueprint(player, craftInfo);

            if (can == false)
            {
                return(false);
            }

            // No blueprint found
            if (GetBlueprintFromCurrentLayout(craftInfo.removeItemsFromCollection ?? mainItemsCollection, craftInfo.category) == null)
            {
                return(false);
            }

            return(true);
        }
コード例 #12
0
        public virtual void RemoveRequiredCraftItemsAndCurrency(CraftingProgressContainer.CraftInfo craftInfo)
        {
            craftInfo.removedCraftItems = true;

            if (craftInfo.removeItemsFromCollection != null && craftInfo.removeItemsFromCollection.useReferences == false)
            {
                foreach (var item in craftInfo.blueprint.requiredItems)
                {
                    craftInfo.removeItemsFromCollection.RemoveItem(item.item.ID, item.amount);
                }
            }
            else
            {
                foreach (var item in craftInfo.blueprint.requiredItems)
                {
                    InventoryManager.RemoveItem(item.item.ID, item.amount, craftInfo.category.alsoScanBankForRequiredItems);
                }
            }

            InventoryManager.RemoveCurrency(craftInfo.blueprint.craftingCost);
        }
コード例 #13
0
        public virtual bool CanCraftBlueprint(InventoryPlayer player, CraftingProgressContainer.CraftInfo craftInfo)
        {
            // Required properties?
            if (player.characterUI != null)
            {
                foreach (var propLookup in craftInfo.blueprint.usageRequirement)
                {
                    if (propLookup.CanUse(player) == false)
                    {
                        InventoryManager.langDatabase.craftingCannotStatNotValid.Show(craftInfo.blueprint.name, craftInfo.blueprint.description, propLookup.stat.statName);
                        return(false);
                    }
                }
            }

            if (CanRemoveRequiredItems(craftInfo) == false)
            {
                InventoryManager.langDatabase.craftingDontHaveRequiredItems.Show(craftInfo.blueprint.requiredItems[0].item.name, craftInfo.blueprint.requiredItems[0].item.description, craftInfo.blueprint.name);
                return(false);
            }

            if (CanAddItemsRewardItems(craftInfo) == false)
            {
                InventoryManager.langDatabase.collectionFull.Show(craftInfo.blueprint.name, craftInfo.blueprint.description, "Reward collection");
                return(false);
            }

            // Enough currency?
            if (CanRemoveRequiredCurrency(craftInfo) == false)
            {
                InventoryManager.langDatabase.userNotEnoughGold.Show(craftInfo.blueprint.name, craftInfo.blueprint.description, craftInfo.craftAmount, craftInfo.blueprint.craftingCost.ToString(craftInfo.craftAmount));
                return(false);
            }

            return(true);
        }
コード例 #14
0
 private void UpdateTrigger(CraftingProgressContainer.CraftInfo craftInfo)
 {
     craftingWindow.UseWithTrigger(craftInfo.category, progressContainer, this, craftingItemsCollection, craftingRewardItemsCollection);
 }
コード例 #15
0
 private void CraftingWindowOnCraftSuccess(CraftingProgressContainer.CraftInfo craftInfo)
 {
     UpdateTrigger(craftInfo);
 }
コード例 #16
0
 private void CraftingWindowOnOnCraftCancelled(CraftingProgressContainer.CraftInfo craftInfo, float progress)
 {
     UpdateTrigger(craftInfo);
 }
コード例 #17
0
 public void GiveCraftReward(CraftingProgressContainer.CraftInfo craftInfo)
 {
     craftingWindow.GiveCraftReward(craftInfo);
 }
コード例 #18
0
 public void RemoveRequiredCraftItemsAndCurrency(CraftingProgressContainer.CraftInfo craftInfo)
 {
     craftingWindow.RemoveRequiredCraftItemsAndCurrency(craftInfo);
 }
コード例 #19
0
 public bool CanCraftBlueprint(InventoryPlayer player, CraftingProgressContainer.CraftInfo craftInfo)
 {
     return(craftingWindow.CanCraftBlueprint(player, craftInfo));
 }
コード例 #20
0
 /// <summary>
 /// Does the inventory contain the required items?
 /// </summary>
 public virtual bool CanCraftBlueprint(CraftingProgressContainer.CraftInfo craftInfo)
 {
     return(CanCraftBlueprint(PlayerManager.instance.currentPlayer.inventoryPlayer, craftInfo));
 }
コード例 #21
0
 private bool CanRemoveRequiredCurrency(CraftingProgressContainer.CraftInfo craftInfo)
 {
     return(InventoryManager.CanRemoveCurrency(craftInfo.blueprint.craftingCost, true, craftInfo.category.alsoScanBankForRequiredItems));
 }