Beispiel #1
0
        private bool ClickOutput(AC.Menu _menu, MouseState _mouseState)
        {
            if (invInstances.Count > 0)
            {
                if (_mouseState == MouseState.SingleClick && !InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
                {
                    // Pick up created item
                    switch (activeRecipe.onCreateRecipe)
                    {
                    case OnCreateRecipe.SelectItem:
                        KickStarter.runtimeInventory.PerformCrafting(activeRecipe, true);
                        break;

                    case OnCreateRecipe.JustMoveToInventory:
                        KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false);
                        break;

                    case OnCreateRecipe.RunActionList:
                        KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false);
                        if (activeRecipe.invActionList)
                        {
                            AdvGame.RunActionListAsset(activeRecipe.invActionList);
                        }
                        break;

                    default:
                        break;
                    }

                    return(true);
                }
            }

            return(false);
        }
        public MatchingInvInteractionData(Hotspot hotspot)
        {
            invInstances          = new List <InvInstance> ();
            invInteractionIndices = new List <int>();
            selectItemModes       = new List <SelectItemMode>();

            for (int i = 0; i < hotspot.invButtons.Count; i++)
            {
                Button button = hotspot.invButtons[i];
                if (button.isDisabled)
                {
                    continue;
                }

                foreach (InvInstance invInstance in KickStarter.runtimeInventory.PlayerInvCollection.InvInstances)
                {
                    if (InvInstance.IsValid(invInstance) && invInstance.ItemID == button.invID && !button.isDisabled)
                    {
                        invInteractionIndices.Add(i);
                        selectItemModes.Add(button.selectItemMode);
                        invInstances.Add(invInstance);
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        private bool ListItems(InvCollection invCollection)
        {
            bool isCarrying = false;

            foreach (InvInstance invInstance in invCollection.InvInstances)
            {
                if (InvInstance.IsValid(invInstance))
                {
                    isCarrying = true;

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Item:", GUILayout.Width(80f));
                    if (invInstance.InvItem.canCarryMultiple)
                    {
                        EditorGUILayout.LabelField(invInstance.InvItem.label, EditorStyles.boldLabel, GUILayout.Width(135f));
                        EditorGUILayout.LabelField("Count:", GUILayout.Width(50f));
                        EditorGUILayout.LabelField(invInstance.InvItem.count.ToString(), GUILayout.Width(44f));
                    }
                    else
                    {
                        EditorGUILayout.LabelField(invInstance.InvItem.label, EditorStyles.boldLabel);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            return(isCarrying);
        }
Beispiel #4
0
        protected void DrawInventoryCursor()
        {
            InvInstance invInstance = KickStarter.runtimeInventory.SelectedInstance;

            if (!InvInstance.IsValid(invInstance))
            {
                return;
            }

            if (invInstance.CursorIcon.texture)
            {
                if (KickStarter.settingsManager.inventoryActiveEffect != InventoryActiveEffect.None)
                {
                    // Only animate when active
                    DrawIcon(invInstance.CursorIcon, false, false);
                }
                else
                {
                    DrawIcon(invInstance.CursorIcon, false, true);
                }
            }
            else
            {
                DrawIcon(AdvGame.GUIBox(KickStarter.playerInput.GetMousePosition(), KickStarter.cursorManager.inventoryCursorSize), invInstance.InvItem.tex);
            }
            pulseDirection = 0;
        }
Beispiel #5
0
        /**
         * <summary>Deletes all inventory item instances associated with a given inventory item</summary>
         * <param name="itemID">The ID of the inventory item to delete</param>
         */
        public void DeleteAllOfType(int itemID)
        {
            if (KickStarter.inventoryManager == null)
            {
                return;
            }

            InvItem itemToRemove = KickStarter.inventoryManager.GetItem(itemID);

            if (itemToRemove == null)
            {
                return;
            }

            for (int i = 0; i < invInstances.Count; i++)
            {
                if (InvInstance.IsValid(invInstances[i]) && invInstances[i].ItemID == itemID)
                {
                    invInstances[i].Clear();
                }
            }

            Clean();
            PlayerMenus.ResetInventoryBoxes();
        }
Beispiel #6
0
        protected override void AutoSize()
        {
            if (invInstances.Count > 0)
            {
                foreach (InvInstance invInstance in invInstances)
                {
                    if (InvInstance.IsValid(invInstance))
                    {
                        switch (displayType)
                        {
                        case ConversationDisplayType.IconOnly:
                            AutoSize(new GUIContent(invInstance.InvItem.tex));
                            break;

                        case ConversationDisplayType.TextOnly:
                            AutoSize(new GUIContent(invInstance.InvItem.label));
                            break;

                        default:
                            break;
                        }
                        return;
                    }
                }
            }
            else
            {
                AutoSize(GUIContent.none);
            }
        }
Beispiel #7
0
        /**
         * <summary>Deletes all item instances that make up a recipe's ingredients</summary>
         * <param name="recipe">The recipe to delete ingredients from</param>
         */
        public void DeleteRecipeIngredients(Recipe recipe)
        {
            if (recipe.useSpecificSlots)
            {
                for (int i = 0; i < recipe.ingredients.Count; i++)
                {
                    int numToRemove = recipe.ingredients[i].Amount;

                    if (i >= 0 && i < invInstances.Count && InvInstance.IsValid(invInstances[i]))
                    {
                        invInstances[i].Count -= numToRemove;
                    }
                }

                Clean();
                PlayerMenus.ResetInventoryBoxes();
            }
            else
            {
                foreach (Ingredient ingredient in recipe.ingredients)
                {
                    int itemIDToRemove = ingredient.ItemID;
                    int numToRemove    = ingredient.Amount;

                    Delete(itemIDToRemove, numToRemove);
                }
            }
        }
Beispiel #8
0
 /** Selects the associated item */
 public void Select(SelectItemMode _selectItemMode = SelectItemMode.Use)
 {
     if (InvInstance.IsValid(this))
     {
         KickStarter.runtimeInventory.SelectItem(this, _selectItemMode);
     }
 }
Beispiel #9
0
        private void Clean()
        {
            // Limit max slots
            if (maxSlots > 0 && maxSlots < invInstances.Count)
            {
                invInstances.RemoveRange(maxSlots, invInstances.Count - maxSlots);
            }

            // Convert invalid to empty
            for (int i = 0; i < invInstances.Count; i++)
            {
                if (!InvInstance.IsValid(invInstances[i]))
                {
                    invInstances[i] = null;
                }
            }

            // Remove empty slots on end
            for (int i = invInstances.Count - 1; i >= 0; i--)
            {
                if (!InvInstance.IsValid(invInstances[i]))
                {
                    invInstances.RemoveAt(i);
                }
                else
                {
                    break;
                }
            }

            // Remove empty slots inside, if re-ordering is disallowed
            if (!CanReorder())
            {
                for (int i = 0; i < invInstances.Count; i++)
                {
                    if (invInstances[i] == null)
                    {
                        invInstances.RemoveAt(i);
                        i--;
                    }
                }
            }

            // Separate by max count

            /*for (int i=0; i< invInstances.Count; i++)
             * {
             *      if (InvInstance.IsValid (invInstances[i]) && invInstances[i].InvItem.canCarryMultiple && invInstances[i].Count > invInstances[i].InvItem.maxCount)
             *      {
             *              while (invInstances[i].Count > invInstances[i].InvItem.maxCount)
             *              {
             *                      int surplus = invInstances[i].Count - invInstances[i].InvItem.maxCount;
             *                      invInstances[i].TransferCount = Mathf.Clamp (surplus, 0, invInstances[i].InvItem.maxCount);
             *
             *
             *                      Insert (invInstances[i], i+1);
             *              }
             *      }
             * }*/
        }
Beispiel #10
0
        protected void DrawActiveInventoryCursor()
        {
            InvInstance invInstance = KickStarter.runtimeInventory.SelectedInstance;

            if (!InvInstance.IsValid(invInstance))
            {
                return;
            }

            if (invInstance.CursorIcon.texture)
            {
                DrawIcon(invInstance.CursorIcon, false, true);
            }
            else if (invInstance.InvItem.activeTex == null)
            {
                DrawInventoryCursor();
            }
            else if (KickStarter.settingsManager.inventoryActiveEffect == InventoryActiveEffect.Simple)
            {
                DrawIcon(AdvGame.GUIBox(KickStarter.playerInput.GetMousePosition(), KickStarter.cursorManager.inventoryCursorSize), invInstance.InvItem.activeTex);
            }
            else if (KickStarter.settingsManager.inventoryActiveEffect == InventoryActiveEffect.Pulse && invInstance.InvItem.tex)
            {
                if (pulseDirection == 0)
                {
                    pulse          = 0f;
                    pulseDirection = 1;
                }
                else if (pulse > 1f)
                {
                    pulse          = 1f;
                    pulseDirection = -1;
                }
                else if (pulse < 0f)
                {
                    pulse          = 0f;
                    pulseDirection = 1;
                }
                else if (pulseDirection == 1)
                {
                    pulse += KickStarter.settingsManager.inventoryPulseSpeed * Time.deltaTime;
                }
                else if (pulseDirection == -1)
                {
                    pulse -= KickStarter.settingsManager.inventoryPulseSpeed * Time.deltaTime;
                }

                Color backupColor = GUI.color;
                Color tempColor   = GUI.color;

                tempColor.a = pulse;
                GUI.color   = tempColor;
                DrawIcon(AdvGame.GUIBox(KickStarter.playerInput.GetMousePosition(), KickStarter.cursorManager.inventoryCursorSize), invInstance.InvItem.activeTex);
                GUI.color = backupColor;
                DrawIcon(AdvGame.GUIBox(KickStarter.playerInput.GetMousePosition(), KickStarter.cursorManager.inventoryCursorSize), invInstance.InvItem.tex);
            }
        }
Beispiel #11
0
        /**
         * <summary>Deletes a set number of inventory item instances at a given index</summary>
         * <param name="index">The index to delete from</param>
         * <param name="amount">The amount to delete</param>
         */
        public void DeleteAtIndex(int index, int amount)
        {
            if (index > 0 && index < invInstances.Count && InvInstance.IsValid(invInstances[index]))
            {
                invInstances[index].Clear(amount);

                Clean();
                PlayerMenus.ResetInventoryBoxes();
            }
        }
Beispiel #12
0
        /**
         * <summary>Adds an inventory item to the Container's contents, at a particular index.</summary>
         * <param name = "itemInstance">The instance of the item to place within the Container</param>
         * <param name = "_index">The index number within the Container's current contents to insert the new item</param>
         * <param name = "count">If >0, the quantity of the item to be added. Otherwise, the same quantity as _item will be added</param>
         */
        public void InsertAt(InvInstance itemInstance, int index, int amountOverride = 0)
        {
            if (!InvInstance.IsValid(itemInstance))
            {
                return;
            }

            itemInstance.TransferCount = (amountOverride > 0) ? amountOverride : 0;
            invCollection.Insert(itemInstance, index);
        }
Beispiel #13
0
 /**
  * <summary>Gets the slot index number that a given InvItem (inventory item) appears in.</summary>
  * <param name = "invInstance">The instance of the InvItem to search for</param>
  * <returns>The slot index number that the inventory item appears in</returns>
  */
 public int GetItemSlot(InvInstance invInstance)
 {
     for (int i = 0; i < invInstances.Count; i++)
     {
         if (InvInstance.IsValid(invInstances[i]) && invInstances[i] == invInstance)
         {
             return(i - offset);
         }
     }
     return(0);
 }
Beispiel #14
0
 /**
  * <summary>Gets the inventory item instance in the collection at a given index</summary>
  * <param name="index">The index to get</param>
  * <returns>The inventory item instance at the index</returns>
  */
 public InvInstance GetInstanceAtIndex(int index)
 {
     if (index >= 0 && index < invInstances.Count)
     {
         if (InvInstance.IsValid(invInstances[index]))
         {
             return(invInstances[index]);
         }
     }
     return(null);
 }
Beispiel #15
0
 /** Checks if the collection contains an inventory instance associated with a given inventory item */
 public bool Contains(int invID)
 {
     foreach (InvInstance invInstance in invInstances)
     {
         if (InvInstance.IsValid(invInstance) && invInstance.ItemID == invID)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #16
0
 /**
  * <summary>Gets the first-found inventory item instance in the collection that's associated with a specific inventory item</summary>
  * <param name="invID">The ID number of the inventory item</param>
  * <returns>The first-found inventory item instance</returns>
  */
 public InvInstance GetFirstInstance(int invID)
 {
     foreach (InvInstance invInstance in invInstances)
     {
         if (InvInstance.IsValid(invInstance) && invInstance.ItemID == invID)
         {
             return(invInstance);
         }
     }
     return(null);
 }
Beispiel #17
0
 /**
  * <summary>Gets the first-found inventory item instance in the collection that's associated with a specific inventory item</summary>
  * <param name="invName">The name of the inventory item</param>
  * <returns>The first-found inventory item instance</returns>
  */
 public InvInstance GetFirstInstance(string invName)
 {
     foreach (InvInstance invInstance in invInstances)
     {
         if (InvInstance.IsValid(invInstance) && invInstance.InvItem.label == invName)
         {
             return(invInstance);
         }
     }
     return(null);
 }
Beispiel #18
0
        protected void CycleCursors()
        {
            if (KickStarter.playerInteraction.GetActiveHotspot() && KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction())
            {
                return;
            }

            int newSelectedCursor = selectedCursor;

            if (KickStarter.cursorManager.cursorIcons.Count > 0)
            {
                newSelectedCursor++;

                if (newSelectedCursor >= KickStarter.cursorManager.cursorIcons.Count)
                {
                    newSelectedCursor = -1;
                }
                else if (newSelectedCursor >= 0 && newSelectedCursor < KickStarter.cursorManager.cursorIcons.Count && KickStarter.cursorManager.cursorIcons [newSelectedCursor].dontCycle)
                {
                    while (KickStarter.cursorManager.cursorIcons [newSelectedCursor].dontCycle)
                    {
                        newSelectedCursor++;

                        if (newSelectedCursor >= KickStarter.cursorManager.cursorIcons.Count)
                        {
                            newSelectedCursor = -1;
                            break;
                        }
                    }
                }
            }
            else
            {
                // Pointer
                newSelectedCursor = -1;
            }

            if (newSelectedCursor == -1 && selectedCursor >= 0)
            {
                // Ended icon cycle
                if (KickStarter.settingsManager.cycleInventoryCursors)
                {
                    KickStarter.runtimeInventory.ReselectLastItem();
                    if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
                    {
                        KickStarter.playerInput.ResetMouseClick();
                        return;
                    }
                }
            }

            SelectedCursor = newSelectedCursor;
        }
Beispiel #19
0
 /**
  * <summary>Deletes all item instances in a specific category</summary>
  * <param name="categoryID">The ID of the category to remove items from</param>
  */
 public void DeleteAllInCategory(int categoryID)
 {
     for (int i = 0; i < invInstances.Count; i++)
     {
         if (InvInstance.IsValid(invInstances[i]) && invInstances[i].InvItem.binID == categoryID)
         {
             invInstances[i] = null;
             i = -1;
         }
     }
     Clean();
 }
Beispiel #20
0
        private bool ItemIsSelected(int index)
        {
            if (!InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
            {
                return(false);
            }

            if (index > 0 && index < invInstances.Count && (!KickStarter.settingsManager.InventoryDragDrop || KickStarter.playerInput.GetDragState() == DragState.Inventory))
            {
                return(invInstances[index] == KickStarter.runtimeInventory.SelectedInstance);
            }
            return(false);
        }
Beispiel #21
0
        /**
         * <summary>Gets all inventory item instance in the collection that are associated with a specific inventory item</summary>
         * <param name="invName">The nameof the inventory item</param>
         * <returns>An array of inventory item instance</returns>
         */
        public InvInstance[] GetAllInstances(string invName)
        {
            List <InvInstance> foundInstances = new List <InvInstance> ();

            foreach (InvInstance invInstance in invInstances)
            {
                if (InvInstance.IsValid(invInstance) && invInstance.InvItem.label == invName)
                {
                    foundInstances.Add(invInstance);
                }
            }
            return(foundInstances.ToArray());
        }
Beispiel #22
0
        /**
         * <summary>Gets all inventory item instance in the collection that are associated with a specific inventory item</summary>
         * <param name="invID">The ID of the inventory item</param>
         * <returns>An array of inventory item instance</returns>
         */
        public InvInstance[] GetAllInstances(int invID)
        {
            List <InvInstance> foundInstances = new List <InvInstance>();

            foreach (InvInstance invInstance in invInstances)
            {
                if (InvInstance.IsValid(invInstance) && invInstance.ItemID == invID)
                {
                    foundInstances.Add(invInstance);
                }
            }
            return(foundInstances.ToArray());
        }
        public override bool CheckCondition()
        {
            if (KickStarter.runtimeInventory)
            {
                switch (selectedCheckMethod)
                {
                case SelectedCheckMethod.NoneSelected:
                    if (!InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
                    {
                        return(true);
                    }
                    break;

                case SelectedCheckMethod.SpecificItem:
                    if (includeLast)
                    {
                        if (InvInstance.IsValid(KickStarter.runtimeInventory.LastSelectedInstance) && KickStarter.runtimeInventory.LastSelectedInstance.ItemID == invID)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance) && KickStarter.runtimeInventory.SelectedInstance.ItemID == invID)
                        {
                            return(true);
                        }
                    }
                    break;

                case SelectedCheckMethod.InSpecificCategory:
                    if (includeLast)
                    {
                        if (InvInstance.IsValid(KickStarter.runtimeInventory.LastSelectedInstance) && KickStarter.runtimeInventory.LastSelectedInstance.InvItem.binID == binID)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance) && KickStarter.runtimeInventory.SelectedInstance.InvItem.binID == binID)
                        {
                            return(true);
                        }
                    }
                    break;
                }
            }
            return(false);
        }
Beispiel #24
0
        /**
         * <summary>Deletes a set number of inventory item instances</summary>
         * <param name="itemID">The ID of the inventory item to delete</param>
         * <param name="amount">The amount to delete</param>
         */
        public void Delete(int itemID, int amount)
        {
            if (KickStarter.inventoryManager == null)
            {
                return;
            }

            InvItem itemToRemove = KickStarter.inventoryManager.GetItem(itemID);

            if (itemToRemove == null)
            {
                return;
            }

            for (int i = 0; i < invInstances.Count; i++)
            {
                if (InvInstance.IsValid(invInstances[i]) && invInstances[i].ItemID == itemID)
                {
                    // Count check
                    if (itemToRemove.canCarryMultiple)
                    {
                        int diff = invInstances[i].Count - amount;
                        if (diff >= 0)
                        {
                            invInstances[i].Clear(amount);
                            amount = 0;
                        }
                        else
                        {
                            amount -= invInstances[i].Count;
                            invInstances[i].Clear();
                        }
                    }

                    if (!itemToRemove.canCarryMultiple || invInstances[i].Count <= 0)
                    {
                        invInstances[i].Clear();
                    }

                    if (!itemToRemove.canCarryMultiple || amount <= 0)
                    {
                        break;
                    }
                }
            }

            Clean();
            PlayerMenus.ResetInventoryBoxes();
        }
Beispiel #25
0
 /**
  * <summary>Gets the slot index number that a given InvItem (inventory item) appears in.</summary>
  * <param name = "itemID">The ID number of the InvItem to search for</param>
  * <returns>The slot index number that the inventory item appears in</returns>
  */
 public int GetItemSlot(int itemID)
 {
     for (int i = 0; i < invInstances.Count; i++)
     {
         if (InvInstance.IsValid(invInstances[i]) && invInstances[i].ItemID == itemID)
         {
             if (craftingType == CraftingElementType.Ingredients)
             {
                 return(i);
             }
             return(i - offset);
         }
     }
     return(0);
 }
Beispiel #26
0
 private string GetPropertyDisplayValue(int languageNumber, InvInstance invInstance)
 {
     if (InvInstance.IsValid(invInstance))
     {
         InvVar invVar = invInstance.GetProperty(itemPropertyID);
         if (invVar != null)
         {
             if (multiplyByItemCount)
             {
                 return(invVar.GetDisplayValue(languageNumber, invInstance.Count));
             }
             return(invVar.GetDisplayValue(languageNumber));
         }
     }
     return(string.Empty);
 }
Beispiel #27
0
        public InvItem GetItem(int i)
        {
            if (craftingType == CraftingElementType.Ingredients && !Application.isPlaying)
            {
                i = 0;
            }

            if (i >= 0 && i < invInstances.Count)
            {
                if (InvInstance.IsValid(invInstances[i]))
                {
                    return(invInstances[i].InvItem);
                }
            }
            return(null);
        }
Beispiel #28
0
        /**
         * <summary>Transfer all counts of a given inventory item from another collection</summary>
         * <param name="invID">The ID of the inventory item (InvItem) to transfer</param>
         * <param name="fromCollection">The collection to transfer from</param>
         */
        public void Transfer(int invID, InvCollection fromCollection)
        {
            if (fromCollection == null || !fromCollection.Contains(invID))
            {
                return;
            }

            foreach (InvInstance invInstance in fromCollection.invInstances)
            {
                if (!InvInstance.IsValid(invInstance) || invInstance.ItemID != invID)
                {
                    continue;
                }

                Add(invInstance);
            }
        }
Beispiel #29
0
        public string GetFullLabel(Hotspot _hotspot, InvInstance invInstance, int _language)
        {
            if (_hotspot == null)
            {
                return(string.Empty);
            }

            if (_hotspot.lookButton == this)
            {
                string prefix      = KickStarter.cursorManager.GetLabelFromID(KickStarter.cursorManager.lookCursor_ID, _language);
                string hotspotName = _hotspot.GetName(_language);
                if (_hotspot.canBeLowerCase && !string.IsNullOrEmpty(prefix))
                {
                    hotspotName = hotspotName.ToLower();
                }

                return(AdvGame.CombineLanguageString(prefix, hotspotName, _language));
            }
            else if (_hotspot.useButtons.Contains(this))
            {
                string prefix      = KickStarter.cursorManager.GetLabelFromID(iconID, _language);
                string hotspotName = _hotspot.GetName(_language);
                if (_hotspot.canBeLowerCase && !string.IsNullOrEmpty(prefix))
                {
                    hotspotName = hotspotName.ToLower();
                }

                return(AdvGame.CombineLanguageString(prefix, hotspotName, _language));
            }
            else if (_hotspot.invButtons.Contains(this) && InvInstance.IsValid(invInstance))
            {
                string prefix      = invInstance.GetHotspotPrefixLabel(_language);
                string hotspotName = _hotspot.GetName(_language);
                if (_hotspot.canBeLowerCase && !string.IsNullOrEmpty(prefix))
                {
                    hotspotName = hotspotName.ToLower();
                }

                return(AdvGame.CombineLanguageString(prefix, hotspotName, _language));
            }

            return(string.Empty);
        }
Beispiel #30
0
        private Container GetSourceContainer(InvInstance invInstance)
        {
            if (!InvInstance.IsValid(invInstance))
            {
                return(null);
            }

            if (KickStarter.stateHandler)
            {
                foreach (Container container in KickStarter.stateHandler.Containers)
                {
                    if (container && container.InvCollection.Contains(invInstance))
                    {
                        return(container);
                    }
                }
            }
            return(null);
        }