public InvItem (InvItem assetItem)
		{
			count = assetItem.count;
			tex = assetItem.tex;
			activeTex = assetItem.activeTex;
			carryOnStart = assetItem.carryOnStart;
			canCarryMultiple = assetItem.canCarryMultiple;
			label = assetItem.label;
			altLabel = assetItem.altLabel;
			id = assetItem.id;
			lineID = assetItem.lineID;
			useIconID = assetItem.useIconID;
			binID = assetItem.binID;
			useSeparateSlots = assetItem.useSeparateSlots;
			isEditing = false;
			recipeSlot = -1;
			
			useActionList = assetItem.useActionList;
			lookActionList = assetItem.lookActionList;
			interactions = assetItem.interactions;
			combineActionList = assetItem.combineActionList;
			unhandledActionList = assetItem.unhandledActionList;
			unhandledCombineActionList = assetItem.unhandledCombineActionList;
			combineID = assetItem.combineID;
		}
        private void ShowContextIcons(InvItem invItem)
        {
            if (KickStarter.cursorManager.cursorIcons.Count > 0)
            {
                if (invItem.lookActionList != null && CanDisplayIconsSideBySide())
                {
                    if (invItem.useIconID < 0)
                    {
                        // Hide use
                        if (invItem.lookActionList != null)
                        {
                            CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID(KickStarter.cursorManager.lookCursor_ID);
                            DrawIcon(icon, true);
                        }
                        return;
                    }
                    else
                    {
                        CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID(invItem.useIconID);
                        DrawIcon(new Vector2(-icon.size * Screen.width / 2f, 0f), icon, false);
                    }
                }
                else if (CanCycleContextSensitiveMode() && contextCycleExamine && invItem.lookActionList != null)
                {
                }
                else
                {
                    DrawIcon(KickStarter.cursorManager.GetCursorIconFromID(invItem.useIconID), false);
                }

                if (invItem.lookActionList != null)
                {
                    CursorIcon lookIcon = KickStarter.cursorManager.GetCursorIconFromID(KickStarter.cursorManager.lookCursor_ID);

                    if (invItem.lookActionList != null && CanDisplayIconsSideBySide())
                    {
                        DrawIcon(new Vector2(lookIcon.size * Screen.width / 2f, 0f), lookIcon, true);
                    }
                    else if (CanCycleContextSensitiveMode())
                    {
                        if (contextCycleExamine)
                        {
                            DrawIcon(Vector2.zero, lookIcon, true);
                        }
                    }
                    else
                    {
                        DrawIcon(lookIcon, true);
                    }
                }
            }
        }
Exemple #3
0
        public string GetLabel(InvItem item, int languageNumber)
        {
            if (languageNumber > 0)
            {
                return(SpeechManager.GetTranslation(item.label, item.lineID, languageNumber));
            }
            else if (item.altLabel != "")
            {
                return(item.altLabel);
            }

            return(item.label);
        }
Exemple #4
0
        /**
         * <summary>Generates a label that represents the name of the parameter's value, if appropriate<summary>
         * <returns>A label that represents the name of the parameter's value<summary>
         */
        public string GetLabel()
        {
            switch (parameterType)
            {
            case ParameterType.GameObject:
                if (gameObject != null)
                {
                    Hotspot _hotspot = gameObject.GetComponent <Hotspot>();
                    if (_hotspot)
                    {
                        return(_hotspot.GetName(Options.GetLanguage()));
                    }

                    Char _char = gameObject.GetComponent <Char>();
                    if (_char)
                    {
                        return(_char.GetName(Options.GetLanguage()));
                    }

                    return(gameObject.name);
                }
                return(string.Empty);

            case ParameterType.InventoryItem:
                InvItem invItem = KickStarter.inventoryManager.GetItem(intValue);
                if (invItem != null)
                {
                    return(invItem.GetLabel(Options.GetLanguage()));
                }
                return(GetSaveData());

            case ParameterType.GlobalVariable:
                GVar gVar = KickStarter.variablesManager.GetVariable(intValue);
                if (gVar != null)
                {
                    return(gVar.label);
                }
                return(GetSaveData());

            case ParameterType.LocalVariable:
                GVar lVar = LocalVariables.GetVariable(intValue);
                if (lVar != null)
                {
                    return(lVar.label);
                }
                return(GetSaveData());

            default:
                return(GetSaveData());
            }
        }
Exemple #5
0
        private string GetCount(int i)
        {
            InvItem item = GetItem(i);

            if (item != null)
            {
                if (GetItem(i).count < 2)
                {
                    return("");
                }
                return(GetItem(i).count.ToString());
            }
            return("");
        }
Exemple #6
0
 public void SelectItem(InvItem item, SelectItemMode _mode)
 {
     if (selectedItem == item)
     {
         selectedItem = null;
         KickStarter.playerCursor.ResetSelectedCursor();
     }
     else
     {
         SetSelectItemMode(_mode);
         selectedItem = item;
     }
     PlayerMenus.ResetInventoryBoxes();
 }
Exemple #7
0
        public void TransferLocalToCrafting(InvItem _item, int _slot)
        {
            if (_item != null && localItems.Contains(_item))
            {
                _item.recipeSlot = _slot;
                craftingItems.Add(_item);

                localItems [localItems.IndexOf(_item)] = null;
                localItems = ReorderItems(localItems);
                localItems = RemoveEmptySlots(localItems);

                SetNull();
            }
        }
Exemple #8
0
        override public ActionEnd End(List <AC.Action> actions)
        {
            if (_parameter == null)
            {
                return(GenerateStopActionEnd());
            }

            GVar     compareVar  = null;
            InvItem  compareItem = null;
            Document compareDoc  = null;

            if (_parameter.parameterType == ParameterType.GlobalVariable ||
                _parameter.parameterType == ParameterType.LocalVariable ||
                _parameter.parameterType == ParameterType.ComponentVariable ||
                _parameter.parameterType == ParameterType.InventoryItem ||
                _parameter.parameterType == ParameterType.Document)
            {
                if (compareVariableID == -1)
                {
                    return(GenerateStopActionEnd());
                }

                if (_parameter.parameterType == ParameterType.GlobalVariable)
                {
                    compareVar = GlobalVariables.GetVariable(compareVariableID, true);
                }
                else if (_parameter.parameterType == ParameterType.LocalVariable && !isAssetFile)
                {
                    compareVar = LocalVariables.GetVariable(compareVariableID);
                }
                else if (_parameter.parameterType == ParameterType.ComponentVariable)
                {
                    runtimeCompareVariables = AssignFile <Variables> (compareObjectConstantID, compareVariables);
                    if (runtimeCompareVariables != null)
                    {
                        compareVar = runtimeCompareVariables.GetVariable(compareVariableID);
                    }
                }
                else if (_parameter.parameterType == ParameterType.InventoryItem)
                {
                    compareItem = KickStarter.inventoryManager.GetItem(compareVariableID);
                }
                else if (_parameter.parameterType == ParameterType.Document)
                {
                    compareDoc = KickStarter.inventoryManager.GetDocument(compareVariableID);
                }
            }

            return(ProcessResult(CheckCondition(compareItem, compareVar, compareDoc), actions));
        }
        /**
         * <summary>A Constructor that sets all its values by copying another InvItem.</summary>
         * <param name = "assetItem">The InvItem to copy</param>
         */
        public InvItem(InvItem assetItem)
        {
            count       = assetItem.count;
            tex         = assetItem.tex;
            activeTex   = assetItem.activeTex;
            selectedTex = assetItem.selectedTex;

            //cursorIcon = assetItem.cursorIcon;
            cursorIcon = new CursorIcon();
            cursorIcon.Copy(assetItem.cursorIcon);

            carryOnStart           = assetItem.carryOnStart;
            carryOnStartNotDefault = assetItem.carryOnStartNotDefault;
            carryOnStartID         = assetItem.carryOnStartID;
            canCarryMultiple       = assetItem.canCarryMultiple;
            label     = assetItem.label;
            altLabel  = assetItem.altLabel;
            id        = assetItem.id;
            lineID    = assetItem.lineID;
            useIconID = assetItem.useIconID;

            binID = assetItem.binID;
            if (binID == -1 && KickStarter.inventoryManager != null && KickStarter.inventoryManager.bins != null && KickStarter.inventoryManager.bins.Count > 0)
            {
                // Place item in first available cateogry if undefined
                binID = KickStarter.inventoryManager.bins[0].id;
            }

            useSeparateSlots = assetItem.useSeparateSlots;
            selectSingle     = assetItem.selectSingle;
            isEditing        = false;
            recipeSlot       = -1;

            overrideUseSyntax = assetItem.overrideUseSyntax;
            hotspotPrefix1    = assetItem.hotspotPrefix1;
            hotspotPrefix2    = assetItem.hotspotPrefix2;

            useActionList              = assetItem.useActionList;
            lookActionList             = assetItem.lookActionList;
            interactions               = assetItem.interactions;
            combineActionList          = assetItem.combineActionList;
            unhandledActionList        = assetItem.unhandledActionList;
            unhandledCombineActionList = assetItem.unhandledCombineActionList;
            combineID    = assetItem.combineID;
            vars         = assetItem.vars;
            linkedPrefab = assetItem.linkedPrefab;

            canBeAnimated = DetermineCanBeAnimated();
        }
Exemple #10
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();
        }
Exemple #11
0
 /**
  * <summary>A Constructor based on the linked InvItem</summary>
  * <param name="_itemID">The associated InvItem</param>
  * <param name="_count">The amount of that item to reference</param>
  */
 public InvInstance(InvItem _invItem, int _count = 1)
 {
     invItem = _invItem;
     if (invItem != null)
     {
         invItem.Upgrade();
     }
     itemID     = (invItem != null) ? invItem.id : -1;
     Count      = _count;
     invVars    = new List <InvVar>();
     cursorIcon = (invItem != null) ? new CursorIcon(invItem.cursorIcon) : null;
     matchingInvInteractionData = null;
     lastInteractionIndex       = 0;
     GenerateDefaultProperties();
 }
Exemple #12
0
        public void Remove(InvItem _item)
        {
            if (_item != null && localItems.Contains(_item))
            {
                if (_item == selectedItem)
                {
                    SetNull();
                }

                localItems [localItems.IndexOf(_item)] = null;

                localItems = ReorderItems(localItems);
                localItems = RemoveEmptySlots(localItems);
            }
        }
Exemple #13
0
 /**
  * <summary>A Constructor based on the linked InvItem's ID</summary>
  * <param name="_itemID">The ID number of the associated InvItem</param>
  * <param name="_count">The amount of that item to reference</param>
  */
 public InvInstance(int _itemID, int _count = 1)
 {
     itemID  = _itemID;
     invItem = (KickStarter.inventoryManager) ? KickStarter.inventoryManager.GetItem(itemID) : null;
     if (invItem != null)
     {
         invItem.Upgrade();
     }
     Count      = _count;
     invVars    = new List <InvVar>();
     cursorIcon = (invItem != null) ? new CursorIcon(invItem.cursorIcon) : null;
     matchingInvInteractionData = null;
     lastInteractionIndex       = 0;
     GenerateDefaultProperties();
 }
Exemple #14
0
        /**
         * <summary>Recalculates display for a particular inventory item.</summary>
         * <param name = "item">The InvItem to recalculate the Menus's display for</param>
         */
        public void MatchInteractions(InvItem item)
        {
            bool match = false;

            foreach (InvInteraction interaction in item.interactions)
            {
                if (interaction.icon.id == iconID)
                {
                    match = true;
                    break;
                }
            }

            isVisible = match;
        }
Exemple #15
0
        /**
         * <summary>Adds an inventory item to the Container's contents, at a particular index.</summary>
         * <param name = "_item">The InvItem to place within the Container</param>
         * <param name = "_index">The index number within the Container's current contents to insert the new item</param>
         */
        public void InsertAt(InvItem _item, int _index)
        {
            ContainerItem newContainerItem = new ContainerItem(_item.id, GetIDArray());

            newContainerItem.count = _item.count;

            if (items.Count <= _index)
            {
                items.Add(newContainerItem);
            }
            else
            {
                items.Insert(_index, newContainerItem);
            }
        }
 private void RemoveWrongItems()
 {
     if (limitToCategory && categoryIDs.Count > 0)
     {
         for (int i = 0; i < items.Count; i++)
         {
             InvItem listedItem = KickStarter.inventoryManager.GetItem(items[i].linkedID);
             if (!categoryIDs.Contains(listedItem.binID))
             {
                 items.RemoveAt(i);
                 i--;
             }
         }
     }
 }
Exemple #17
0
        /**
         * <summary>Checks if the item has an InvInteraction combine interaction for a specific InvItem.</summary>
         * <param name = "invItem">The InvITem to check for</param>
         * <returns>True if the item has an InvInteraction combine interaction for the InvItem.</returns>
         */
        public bool DoesHaveInventoryInteraction(InvItem invItem)
        {
            if (invItem != null)
            {
                foreach (int invID in combineID)
                {
                    if (invID == invItem.id)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #18
0
        public bool IsItemCarried(InvItem _item)
        {
            if (_item == null)
            {
                return(false);
            }
            foreach (InvItem item in localItems)
            {
                if (item == _item)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #19
0
 private string GetPropertyDisplayValue(int languageNumber, InvItem invItem)
 {
     if (invItem != null)
     {
         InvVar invVar = invItem.GetProperty(itemPropertyID);
         if (invVar != null)
         {
             if (multiplyByItemCount)
             {
                 return(invVar.GetDisplayValue(languageNumber, invItem.count));
             }
             return(invVar.GetDisplayValue(languageNumber));
         }
     }
     return(string.Empty);
 }
Exemple #20
0
 /**
  * <summary>A Constructor based on the linked InvItem's name</summary>
  * <param name="_itemName">The name number of the associated InvItem</param>
  * <param name="_count">The amount of that item to reference</param>
  */
 public InvInstance(string _itemName, int _count = 1)
 {
     invItem = (KickStarter.inventoryManager) ? KickStarter.inventoryManager.GetItem(_itemName) : null;
     if (invItem != null)
     {
         invItem.Upgrade();
     }
     Count      = _count;
     itemID     = (invItem != null) ? invItem.id : -1;
     invVars    = new List <InvVar> ();
     cursorIcon = (invItem != null) ? new CursorIcon(invItem.cursorIcon) : null;
     matchingInvInteractionData = null;
     lastInteractionIndex       = 0;
     GenerateDefaultProperties();
     canBeAnimated = DetermineCanBeAnimated();
 }
        private void SetNextInventoryItem()
        {
            // Cycle through the collection of inventory items and select the next one

            if (KickStarter.runtimeInventory.localItems.Count > 0)
            {
                inventoryItemIndex++;
                if (inventoryItemIndex >= KickStarter.runtimeInventory.localItems.Count)
                {
                    inventoryItemIndex = 0;
                }

                InvItem selectedInventoryItem = KickStarter.runtimeInventory.localItems[inventoryItemIndex];
                KickStarter.runtimeInventory.SelectItem(selectedInventoryItem);
            }
        }
Exemple #22
0
 /**
  * <summary>A Constructor based on a Container item</summary>
  * <param name="containerItem">The Container item to create an instance from</param>
  */
 public InvInstance(ContainerItem containerItem)
 {
     itemID  = containerItem.ItemID;
     invItem = (KickStarter.inventoryManager) ? KickStarter.inventoryManager.GetItem(itemID) : null;
     if (invItem != null)
     {
         invItem.Upgrade();
     }
     Count      = containerItem.Count;
     invVars    = new List <InvVar> ();
     cursorIcon = (invItem != null) ? new CursorIcon(invItem.cursorIcon) : null;
     matchingInvInteractionData = null;
     lastInteractionIndex       = 0;
     GenerateDefaultProperties();
     canBeAnimated = DetermineCanBeAnimated();
 }
Exemple #23
0
        /**
         * <summary>Triggers either the OnInventoryCombine or InventoryInteract events.</summary>
         * <param name = "iconID">The ID number of the 'use' icon, as defined in CursorManager, if the item was used</param>
         * <param name = "combineItem">The other inventory item, if the item was combined with another</param>
         */
        public void Call_OnUseInventory(InvItem invItem, int iconID, InvItem combineItem = null)
        {
            if (invItem == null)
            {
                return;
            }

            if (OnInventoryCombine != null && combineItem != null)
            {
                OnInventoryCombine(invItem, combineItem);
            }
            else if (OnInventoryInteract != null && combineItem == null)
            {
                OnInventoryInteract(invItem, iconID);
            }
        }
Exemple #24
0
        protected void RemoveWrongItems()
        {
            if (limitToCategory && categoryIDs.Count > 0)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (!items[i].IsEmpty)
                    {
                        InvItem listedItem = KickStarter.inventoryManager.GetItem(items[i].linkedID);
                        if (!categoryIDs.Contains(listedItem.binID))
                        {
                            if (KickStarter.settingsManager.canReorderItems)
                            {
                                items[i].IsEmpty = true;
                            }
                            else
                            {
                                items.RemoveAt(i);
                            }
                            i--;
                        }
                    }
                }
            }

            for (int i = items.Count - 1; i >= 0; i--)
            {
                if (!items[i].IsEmpty)
                {
                    InvItem invItem = KickStarter.inventoryManager.GetItem(items[i].linkedID);
                    if (invItem != null && invItem.canCarryMultiple && invItem.useSeparateSlots && items[i].count > 1)
                    {
                        while (items[i].count > 1)
                        {
                            ContainerItem newItem = new ContainerItem(items[i].linkedID, 1, GetIDArray());
                            items.Insert(i + 1, newItem);
                            items[i].count--;
                        }
                    }
                }
            }

            if (maxSlots > 0 && items.Count > maxSlots)
            {
                items.RemoveRange(maxSlots, items.Count - maxSlots);
            }
        }
Exemple #25
0
        private bool RequiresItem(InvItem invItem)
        {
            if (invItem == null)
            {
                return(false);
            }

            foreach (Ingredient ingredient in ingredients)
            {
                if (ingredient.ItemID == invItem.id)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #26
0
        public void Use(InvItem item)
        {
            if (item == null || item.recipeSlot > -1)
            {
                return;
            }

            if (item.useActionList)
            {
                selectedItem = null;
                AdvGame.RunActionListAsset(item.useActionList);
            }
            else if (KickStarter.settingsManager.CanSelectItems(true))
            {
                SelectItem(item, SelectItemMode.Use);
            }
        }
            public string GetCellText(InvItem invItem, InventoryManager inventoryManager)
            {
                string cellText = " ";

                switch (columnType)
                {
                case ColumnType.InternalName:
                    cellText = invItem.label;
                    break;

                case ColumnType.Label:
                    cellText = invItem.altLabel;
                    break;

                case ColumnType.MainGraphic:
                    cellText = (invItem.tex) ? invItem.tex.name : "";
                    break;

                case ColumnType.Category:
                    if (invItem.binID >= 0)
                    {
                        InvBin invBin = inventoryManager.GetCategory(invItem.binID);
                        cellText = (invBin != null) ? invBin.label : "";
                    }
                    break;

                case ColumnType.CategoryID:
                    cellText = (invItem.binID >= 0) ? invItem.binID.ToString() : "";
                    break;

                case ColumnType.CarryOnStart:
                    cellText = (invItem.carryOnStart) ? "True" : "False";
                    break;

                case ColumnType.CanCarryMultiple:
                    cellText = (invItem.canCarryMultiple) ? "True" : "False";
                    break;
                }

                if (cellText == "")
                {
                    cellText = " ";
                }
                return(RemoveLineBreaks(cellText));
            }
		private int pulseDirection = 0; // 0 = none, 1 = in, -1 = out
		
		
		public void Awake ()
		{
			selectedItem = null;
			GetReferences ();
			
			craftingItems.Clear ();
			localItems.Clear ();
			GetItemsOnStart ();
			
			if (inventoryManager)
			{
				unhandledCombine = inventoryManager.unhandledCombine;
				unhandledHotspot = inventoryManager.unhandledHotspot;
			}
			else
			{
				Debug.LogError ("An Inventory Manager is required - please use the Adventure Creator window to create one.");
			}
		}
Exemple #29
0
        /** A Constructor that populates itself based on a Container's default set of items */
        public InvCollection(Container container)
        {
            maxSlots           = container.maxSlots;
            limitToCategoryIDs = (container.limitToCategory) ? container.categoryIDs : null;
            invInstances       = new List <InvInstance> ();

            foreach (ContainerItem containerItem in container.items)
            {
                InvItem invItem = containerItem.InvItem;
                if (invItem == null)
                {
                    continue;
                }

                bool alreadyAdded = false;
                if (invItem.canCarryMultiple && containerItem.Count > invItem.maxCount)
                {
                    int countLeft = containerItem.Count;
                    while (countLeft > 0)
                    {
                        if (countLeft > invItem.maxCount)
                        {
                            AddToEnd(new InvInstance(invItem, invItem.maxCount));
                            alreadyAdded = true;
                            countLeft   -= invItem.maxCount;
                        }
                        else
                        {
                            AddToEnd(new InvInstance(invItem, countLeft));
                            alreadyAdded = true;
                            countLeft    = 0;
                        }
                    }
                }

                if (!alreadyAdded)
                {
                    AddToEnd(new InvInstance(containerItem));
                }
            }

            Clean();
        }
        override public float Run()
        {
            InvItem invItem = (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) ?
                              KickStarter.runtimeInventory.LastSelectedItem :
                              KickStarter.inventoryManager.GetItem(invID);

            if (invItem != null && runtimeVariable != null)
            {
                InvVar invVar = invItem.GetProperty(propertyID);

                if (invVar == null)
                {
                    LogWarning("Cannot find property with ID " + propertyID + " on Inventory item " + invItem.GetLabel(0));
                    return(0f);
                }

                if (runtimeVariable.type == VariableType.String)
                {
                    runtimeVariable.textVal = invVar.GetDisplayValue(Options.GetLanguage());
                }
                else if (runtimeVariable.type == invVar.type)
                {
                    if (invVar.type == VariableType.Float)
                    {
                        runtimeVariable.FloatValue = invVar.FloatValue;
                    }
                    else if (invVar.type == VariableType.Vector3)
                    {
                        runtimeVariable.Vector3Value = invVar.Vector3Value;
                    }
                    else
                    {
                        runtimeVariable.IntegerValue = invVar.IntegerValue;
                    }
                }
                else
                {
                    LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match.");
                }
            }

            return(0);
        }
Exemple #31
0
 private List <InvItem> MatchInteractionsFromItem(List <InvItem> items, InvItem _item)
 {
     if (_item != null && _item.combineID != null)
     {
         foreach (int combineID in _item.combineID)
         {
             foreach (InvItem item in localItems)
             {
                 if (item != null && item.id == combineID)
                 {
                     matchingInvInteractions.Add(_item.combineID.IndexOf(combineID));
                     items.Add(item);
                     break;
                 }
             }
         }
     }
     return(items);
 }
Exemple #32
0
        private string GetCount(int i)
        {
            if (inventoryItemCountDisplay == InventoryItemCountDisplay.Never)
            {
                return(string.Empty);
            }

            InvItem item = GetItem(i);

            if (item != null)
            {
                if (GetItem(i).count < 2 && inventoryItemCountDisplay == InventoryItemCountDisplay.OnlyIfMultiple)
                {
                    return(string.Empty);
                }
                return(GetItem(i).count.ToString());
            }
            return(string.Empty);
        }
        private void PopulateList()
        {
            if (Application.isPlaying)
            {
                if (inventoryBoxType == AC_InventoryBoxType.HotspotBased)
                {
                    if (limitToDefinedInteractions)
                    {
                        items = KickStarter.runtimeInventory.MatchInteractions ();
                    }
                    else
                    {
                        items = KickStarter.runtimeInventory.localItems;
                    }
                }
                else if (inventoryBoxType == AC_InventoryBoxType.DisplaySelected)
                {
                    items = KickStarter.runtimeInventory.GetSelected ();
                }
                else if (inventoryBoxType == AC_InventoryBoxType.DisplayLastSelected)
                {
                    if (KickStarter.runtimeInventory.selectedItem != null)
                    {
                        items = new List<InvItem>();
                        items = KickStarter.runtimeInventory.GetSelected ();
                    }
                    else if (items.Count == 1 && !KickStarter.runtimeInventory.IsItemCarried (items[0]))
                    {
                        items.Clear ();
                    }
                }
                else if (inventoryBoxType == AC_InventoryBoxType.Container)
                {
                    if (KickStarter.playerInput.activeContainer)
                    {
                        items.Clear ();
                        foreach (ContainerItem containerItem in KickStarter.playerInput.activeContainer.items)
                        {
                            InvItem referencedItem = new InvItem (KickStarter.inventoryManager.GetItem (containerItem.linkedID));
                            referencedItem.count = containerItem.count;
                            items.Add (referencedItem);
                        }
                    }
                }
                else
                {
                    items = new List<InvItem>();
                    foreach (InvItem _item in KickStarter.runtimeInventory.localItems)
                    {
                        if (KickStarter.settingsManager.hideSelectedFromMenu && KickStarter.runtimeInventory.selectedItem == _item)
                        {
                            items.Add (null);
                        }
                        else
                        {
                            items.Add (_item);
                        }
                    }
                }
            }
            else
            {
                items = new List<InvItem>();
                if (AdvGame.GetReferences ().inventoryManager)
                {
                    foreach (InvItem _item in AdvGame.GetReferences ().inventoryManager.items)
                    {
                        items.Add (_item);
                        if (_item != null)
                        {
                            _item.recipeSlot = -1;
                        }
                    }
                }
            }

            if (inventoryBoxType == AC_InventoryBoxType.Default || inventoryBoxType == AC_InventoryBoxType.CustomScript)
            {
                if (limitToCategory && categoryID > -1)
                {
                    while (AreAnyItemsInWrongCategory ())
                    {
                        foreach (InvItem _item in items)
                        {
                            if (_item != null && _item.binID != categoryID)
                            {
                                items.Remove (_item);
                                break;
                            }
                        }
                    }
                }

                while (AreAnyItemsInRecipe ())
                {
                    foreach (InvItem _item in items)
                    {
                        if (_item != null && _item.recipeSlot > -1)
                        {
                            if (AdvGame.GetReferences ().settingsManager.canReorderItems)
                                items [items.IndexOf (_item)] = null;
                            else
                                items.Remove (_item);
                            break;
                        }
                    }
                }
            }
        }
        private void DrawTexture(Rect rect, InvItem _item, bool isActive)
        {
            if (_item == null) return;

            Texture2D tex = null;
            if (Application.isPlaying && KickStarter.runtimeInventory != null && inventoryBoxType != AC_InventoryBoxType.DisplaySelected)
            {
                if (_item == KickStarter.runtimeInventory.highlightItem && _item.activeTex != null)
                {
                    KickStarter.runtimeInventory.DrawHighlighted (rect);
                    return;
                }

                if (_item.activeTex != null && ((isActive && KickStarter.settingsManager.activeWhenHover) || _item == KickStarter.runtimeInventory.selectedItem))
                {
                    tex = _item.activeTex;
                }
                else if (_item.tex != null)
                {
                    tex = _item.tex;
                }
            }
            else if (_item.tex != null)
            {
                tex = _item.tex;
            }

            if (tex != null)
            {
                GUI.DrawTexture (rect, tex, ScaleMode.StretchToFill, true, 0f);
            }
        }
        /**
         * Updates the state of all Menus.
         * This is called every frame by StateHandler.
         */
        public void UpdateAllMenus()
        {
            #if (UNITY_IPHONE || UNITY_ANDROID) && !UNITY_EDITOR
            if (keyboard != null && selectedInputBox != null)
            {
                selectedInputBox.label = keyboard.text;
            }
            #endif

            if (doResizeMenus > 0)
            {
                doResizeMenus ++;

                if (doResizeMenus == 4)
                {
                    doResizeMenus = 0;
                    foreach (AC.Menu menu in PlayerMenus.GetMenus ())
                    {
                        menu.Recalculate ();
                        menu.UpdateAspectRect ();
                        KickStarter.mainCamera.SetCameraRect ();
                        menu.Recalculate ();
                    }
                }
            }

            if (Time.time > 0f)
            {
                int languageNumber = Options.GetLanguage ();
                hotspotLabel = KickStarter.playerInteraction.GetLabel (languageNumber);

                if (!interactionMenuIsOn || !mouseOverInteractionMenu)
                {
                    oldHoverItem = KickStarter.runtimeInventory.hoverItem;
                    KickStarter.runtimeInventory.hoverItem = null;
                }

                if (KickStarter.stateHandler.gameState == GameState.Paused)
                {
                    if (Time.timeScale != 0f)
                    {
                        KickStarter.sceneSettings.PauseGame ();
                    }
                }
                else if (Time.timeScale == 0f)
                {
                    KickStarter.sceneSettings.UnpauseGame (KickStarter.playerInput.timeScale);
                }

                foundMouseOverMenu = false;
                foundMouseOverInteractionMenu = false;
                foundMouseOverInventory = false;

                foreach (AC.Menu menu in menus)
                {
                    UpdateMenu (menu);
                    if (menu.IsEnabled ())
                    {
                        UpdateElements (menu, languageNumber);
                    }
                }

                for (int i=0; i<dupMenus.Count; i++)
                {
                    UpdateMenu (dupMenus[i]);
                    UpdateElements (dupMenus[i], languageNumber);

                    if (dupMenus[i].IsOff () && KickStarter.stateHandler.gameState != GameState.Paused)
                    {
                        Menu oldMenu = dupMenus[i];
                        dupMenus.RemoveAt (i);
                        if (oldMenu.menuSource != MenuSource.AdventureCreator && oldMenu.canvas && oldMenu.canvas.gameObject.activeInHierarchy)
                        {
                            DestroyImmediate (oldMenu.canvas.gameObject);
                        }
                        DestroyImmediate (oldMenu);
                        i=0;
                    }

                }

                mouseOverMenu = foundMouseOverMenu;
                mouseOverInteractionMenu = foundMouseOverInteractionMenu;
                mouseOverInventory = foundMouseOverInventory;

                lastElementIdentifier = elementIdentifier;

                // Check clicks in reverse order
                for (int i=menus.Count-1; i>=0; i--)
                {
                    if (menus[i].IsEnabled () && !menus[i].ignoreMouseClicks/* && !menus[i].IsUnityUI ()*/)
                    {
                        CheckClicks (menus[i]);
                    }
                }
            }
        }
Exemple #36
0
        private void RebuildProperties(InvItem item)
        {
            // Which properties are available?
            List<int> availableVarIDs = new List<int>();
            foreach (InvVar invVar in invVars)
            {
                if (!invVar.limitToCategories || bins.Count == 0 || invVar.categoryIDs.Contains (item.binID))
                {
                    availableVarIDs.Add (invVar.id);
                }
            }

            // Create new properties / transfer existing values
            List<InvVar> newInvVars = new List<InvVar>();
            foreach (InvVar invVar in invVars)
            {
                if (availableVarIDs.Contains (invVar.id))
                {
                    InvVar newInvVar = new InvVar (invVar);
                    InvVar oldInvVar = item.GetProperty (invVar.id);
                    if (oldInvVar != null)
                    {
                        newInvVar.TransferValues (oldInvVar);
                    }
                    newInvVars.Add (newInvVar);
                }
            }

            item.vars = newInvVars;
        }
 /**
  * <summary>Fully highlights an inventory item instantly.</summary>
  * <param name = "_id">The ID number of the inventory item (see InvItem) to highlight</param>
  */
 public void HighlightItemOnInstant(int _id)
 {
     highlightItem = GetItem (_id);
     highlightState = HighlightState.None;
     pulse = 1f;
 }
		private void SideMenu (InvItem item)
		{
			GenericMenu menu = new GenericMenu ();
			sideItem = items.IndexOf (item);
			
			menu.AddItem (new GUIContent ("Insert after"), false, Callback, "Insert after");
			if (items.Count > 0)
			{
				menu.AddItem (new GUIContent ("Delete"), false, Callback, "Delete");
			}
			if (sideItem > 0 || sideItem < items.Count-1)
			{
				menu.AddSeparator ("");
			}
			if (sideItem > 0)
			{
				menu.AddItem (new GUIContent ("Move up"), false, Callback, "Move up");
			}
			if (sideItem < items.Count-1)
			{
				menu.AddItem (new GUIContent ("Move down"), false, Callback, "Move down");
			}
			
			menu.ShowAsContext ();
		}
		private void ActivateItem (InvItem item)
		{
			item.isEditing = true;
			selectedItem = item;
		}
 /**
  * <summary>Checks if a particular inventory item is currently held by the player.</summary>
  * <param name = "_item">The inventory item to check for</param>
  * <returns>True if the inventory item is currently held by the player</returns>
  */
 public bool IsItemCarried(InvItem _item)
 {
     if (_item == null) return false;
     foreach (InvItem item in localItems)
     {
         if (item == _item)
         {
             return true;
         }
     }
     return false;
 }
Exemple #41
0
 private bool ItemIsSelected(InvItem item)
 {
     if (item != null && item == KickStarter.runtimeInventory.selectedItem && (!KickStarter.settingsManager.inventoryDragDrop || KickStarter.playerInput.GetDragState () == DragState.Inventory))
     {
         return true;
     }
     return false;
 }
Exemple #42
0
        private Texture2D GetTexture(InvItem _item, bool isActive)
        {
            if (ItemIsSelected (_item))
            {
                switch (KickStarter.settingsManager.selectInventoryDisplay)
                {
                case SelectInventoryDisplay.ShowSelectedGraphic:
                    return _item.selectedTex;

                case SelectInventoryDisplay.ShowHoverGraphic:
                    return _item.activeTex;

                default:
                    break;
                }
            }
            else if (isActive && KickStarter.settingsManager.activeWhenHover)
            {
                return _item.activeTex;
            }
            return _item.tex;
        }
Exemple #43
0
        private void ExtractInventory(InvItem invItem, bool onlySeekNew)
        {
            if (onlySeekNew && invItem.lineID == -1)
            {
                // Assign a new ID on creation
                SpeechLine newLine;
                string _label = invItem.label;
                if (invItem.altLabel != "")
                {
                    _label = invItem.altLabel;
                }

                newLine = new SpeechLine (GetIDArray(), UnityVersionHandler.GetCurrentSceneName (), _label, languages.Count - 1, AC_TextType.InventoryItem);
                invItem.lineID = newLine.lineID;
                lines.Add (newLine);
            }

            else if (!onlySeekNew && invItem.lineID > -1)
            {
                // Already has an ID, so don't replace
                string _label = invItem.label;
                if (invItem.altLabel != "")
                {
                    _label = invItem.altLabel;
                }

                SpeechLine existingLine = new SpeechLine (invItem.lineID, UnityVersionHandler.GetCurrentSceneName (), _label, languages.Count - 1, AC_TextType.InventoryItem);

                int lineID = SmartAddLine (existingLine);
                if (lineID >= 0) invItem.lineID = lineID;
            }
        }
        /**
         * <summary>Recalculates display for a particular inventory item.</summary>
         * <param name = "item">The InvItem to recalculate the Menus's display for</param>
         */
        public void MatchInteractions(InvItem item)
        {
            bool match = false;
            foreach (InvInteraction interaction in item.interactions)
            {
                if (interaction.icon.id == iconID)
                {
                    match = true;
                    break;
                }
            }

            isVisible = match;
        }
        /**
         * <summary>Runs an inventory item's "Examine" interaction.</summary>
         * <param name = "item">The inventory item to examine</param>
         */
        public void Look(InvItem item)
        {
            if (item == null || item.recipeSlot > -1) return;

            if (item.lookActionList)
            {
                AdvGame.RunActionListAsset (item.lookActionList);
            }
        }
Exemple #46
0
        /**
         * <summary>Adds an inventory item to the Container's contents, at a particular index.</summary>
         * <param name = "_item">The InvItem to place within the Container</param>
         * <param name = "_index">The index number within the Container's current contents to insert the new item</param>
         */
        public void InsertAt(InvItem _item, int _index)
        {
            ContainerItem newContainerItem = new ContainerItem (_item.id, GetIDArray ());
            newContainerItem.count = _item.count;

            if (items.Count <= _index)
            {
                items.Add (newContainerItem);
            }
            else
            {
                items.Insert (_index, newContainerItem);
            }
        }
		private void CreateItemsGUI ()
		{
			EditorGUILayout.LabelField ("Inventory items", EditorStyles.boldLabel);

			filter = EditorGUILayout.TextField ("Filter by name:", filter);
			EditorGUILayout.Space ();

			foreach (InvItem item in items)
			{
				if (filter == "" || item.label.ToLower ().Contains (filter.ToLower ()))
				{
					EditorGUILayout.BeginHorizontal ();
					
					string buttonLabel = item.label;
					if (buttonLabel == "")
					{
						buttonLabel = "(Untitled)";	
					}

					if (GUILayout.Toggle (item.isEditing, item.id + ": " + buttonLabel, "Button"))
					{
						if (selectedItem != item)
						{
							DeactivateAllItems ();
							ActivateItem (item);
						}
					}

					if (GUILayout.Button (sideIcon, GUILayout.Width (20f), GUILayout.Height (15f)))
					{
						SideMenu (item);
					}

					EditorGUILayout.EndHorizontal ();
				}
			}

			if (GUILayout.Button("Create new item"))
			{
				Undo.RecordObject (this, "Create inventory item");

				ResetFilter ();
				InvItem newItem = new InvItem (GetIDArray ());
				items.Add (newItem);
				DeactivateAllItems ();
				ActivateItem (newItem);
			}
		}
Exemple #48
0
        public void SetOutput(MenuSource source, bool autoCreate)
        {
            items = new List<InvItem>();
            activeRecipe = KickStarter.runtimeInventory.CalculateRecipe (autoCreate);
            if (activeRecipe != null)
            {
                foreach (InvItem assetItem in AdvGame.GetReferences ().inventoryManager.items)
                {
                    if (assetItem.id == activeRecipe.resultID)
                    {
                        InvItem newItem = new InvItem (assetItem);
                        newItem.count = 1;
                        items.Add (newItem);
                    }
                }
            }

            if (!autoCreate)
            {
                base.RecalculateSize (source);
            }
        }
		private void DeactivateAllItems ()
		{
			foreach (InvItem item in items)
			{
				item.isEditing = false;
			}
			selectedItem = null;
		}
        private void CreateItemsGUI(string[] binList)
        {
            EditorGUILayout.LabelField ("Inventory items", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal ();
            EditorGUILayout.LabelField ("Filter by:", GUILayout.Width (100f));
            filterType = (FilterInventoryItem) EditorGUILayout.EnumPopup (filterType, GUILayout.Width (80f));
            if (filterType == FilterInventoryItem.Name)
            {
                nameFilter = EditorGUILayout.TextField (nameFilter);
            }
            else if (filterType == FilterInventoryItem.Category)
            {
                if (bins == null || bins.Count == 0)
                {
                    categoryFilter = -1;
                    EditorGUILayout.HelpBox ("No categories defined!", MessageType.Info);
                }
                else
                {
                    categoryFilter = EditorGUILayout.Popup (categoryFilter, binList);
                }
            }
            EditorGUILayout.EndHorizontal ();
            filterOnStart = EditorGUILayout.Toggle ("Filter by 'Carry on start?'?", filterOnStart);

            EditorGUILayout.Space ();

            scrollPos = EditorGUILayout.BeginScrollView (scrollPos, GUILayout.Height (Mathf.Min (items.Count * 21, 235f)+5));
            foreach (InvItem item in items)
            {
                if ((filterType == FilterInventoryItem.Name && (nameFilter == "" || item.label.ToLower ().Contains (nameFilter.ToLower ()))) ||
                    (filterType == FilterInventoryItem.Category && (categoryFilter == -1 || GetBinSlot (item.binID) == categoryFilter)))
                {
                    if (!filterOnStart || item.carryOnStart)
                    {
                        EditorGUILayout.BeginHorizontal ();

                        string buttonLabel = item.label;
                        if (buttonLabel == "")
                        {
                            buttonLabel = "(Untitled)";
                        }

                        if (GUILayout.Toggle (item.isEditing, item.id + ": " + buttonLabel, "Button"))
                        {
                            if (selectedItem != item)
                            {
                                DeactivateAllItems ();
                                ActivateItem (item);
                            }
                        }

                        if (GUILayout.Button (sideIcon, GUILayout.Width (20f), GUILayout.Height (15f)))
                        {
                            SideMenu (item);
                        }

                        EditorGUILayout.EndHorizontal ();
                    }
                }
            }
            EditorGUILayout.EndScrollView ();

            if (GUILayout.Button("Create new item"))
            {
                Undo.RecordObject (this, "Create inventory item");

                ResetFilter ();
                InvItem newItem = new InvItem (GetIDArray ());
                items.Add (newItem);
                DeactivateAllItems ();
                ActivateItem (newItem);
            }
        }
Exemple #51
0
 private string GetPropertyDisplayValue(int languageNumber, InvItem invItem)
 {
     if (invItem != null)
     {
         InvVar invVar = invItem.GetProperty (itemPropertyID);
         if (invVar != null)
         {
             return invVar.GetDisplayValue (languageNumber);
         }
     }
     return "";
 }
        /**
         * <summary>Moves an item already in an inventory to a different slot.</summary>
         * <param name = "item">The inventory item to move</param>
         * <param name = "items">The List of inventory items that the item is to be moved within</param>
         * <param name = "index">The index number of the MenuInventoryBox slot to move the item to</param>
         * <returns>The re-ordered List of inventory items</returns>
         */
        public List<InvItem> MoveItemToIndex(InvItem item, List<InvItem> items, int index)
        {
            if (item != null)
            {
                if (KickStarter.settingsManager.canReorderItems)
                {
                    // Check nothing in place already
                    int oldIndex = items.IndexOf (item);
                    while (items.Count <= Mathf.Max (index, oldIndex))
                    {
                        items.Add (null);
                    }

                    if (items [index] == null)
                    {
                        items [index] = item;
                        items [oldIndex] = null;
                    }

                    SetNull ();
                    items = RemoveEmptySlots (items);
                }
                else if (items.IndexOf (item) == index)
                {
                    SetNull ();
                }
            }
            return items;
        }
Exemple #53
0
        private void ShowContextIcons(InvItem invItem)
        {
            if (KickStarter.cursorManager.cursorIcons.Count > 0)
            {
                if (invItem.lookActionList != null && KickStarter.cursorManager.lookUseCursorAction == LookUseCursorAction.DisplayBothSideBySide)
                {
                    CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID (invItem.useIconID);
                    DrawIcon (new Vector2 (-icon.size * Screen.width / 2f, 0f), icon, false);
                }
                else
                {
                    DrawIcon (KickStarter.cursorManager.GetCursorIconFromID (invItem.useIconID), false);
                }

                if (invItem.lookActionList != null)
                {
                    CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID (KickStarter.cursorManager.lookCursor_ID);

                    if (invItem.lookActionList != null && KickStarter.cursorManager.lookUseCursorAction == LookUseCursorAction.DisplayBothSideBySide)
                    {
                        DrawIcon (new Vector2 (icon.size * Screen.width / 2f, 0f), icon, true);
                    }
                    else
                    {
                        DrawIcon (icon, true);
                    }
                }
            }
        }
        /**
         * <summary>Removes an inventory item from the player's inventory.</summary>
         * <param name = "_item">The inventory item (InvItem) to remove</param>
         */
        public void Remove(InvItem _item)
        {
            if (_item != null && localItems.Contains (_item))
            {
                if (_item == selectedItem)
                {
                    SetNull ();
                }

                localItems [localItems.IndexOf (_item)] = null;

                localItems = ReorderItems (localItems);
                localItems = RemoveEmptySlots (localItems);
            }
        }
		private void ExtractInventory (InvItem invItem, bool onlySeekNew)
		{
			if (onlySeekNew && invItem.lineID == -1)
			{
				// Assign a new ID on creation
				SpeechLine newLine;
				if (invItem.altLabel != "")
				{
					newLine = new SpeechLine (GetIDArray(), EditorApplication.currentScene, invItem.altLabel, languages.Count - 1, AC_TextType.InventoryItem);
				}
				else
				{
					newLine = new SpeechLine (GetIDArray(), EditorApplication.currentScene, invItem.label, languages.Count - 1, AC_TextType.InventoryItem);
				}
				invItem.lineID = newLine.lineID;
				lines.Add (newLine);
			}
			
			else if (!onlySeekNew && invItem.lineID > -1)
			{
				// Already has an ID, so don't replace
				if (invItem.altLabel != "")
				{
					lines.Add (new SpeechLine (invItem.lineID, EditorApplication.currentScene, invItem.altLabel, languages.Count - 1, AC_TextType.InventoryItem));
				}
				else
				{
					lines.Add (new SpeechLine (invItem.lineID, EditorApplication.currentScene, invItem.label, languages.Count - 1, AC_TextType.InventoryItem));
				}
			}
		}
		public void UpdateAllMenus ()
		{
			#if (UNITY_IPHONE || UNITY_ANDROID) && !UNITY_EDITOR
			if (keyboard != null && selectedInputBox != null)
			{
				selectedInputBox.label = keyboard.text;
			}
			#endif
			
			if (doResizeMenus > 0)
			{
				doResizeMenus ++;
				
				if (doResizeMenus == 4)
				{
					doResizeMenus = 0;
					foreach (Menu menu in PlayerMenus.GetMenus ())
					{
						menu.Recalculate ();
						menu.UpdateAspectRect ();
						KickStarter.mainCamera.SetCameraRect ();
						menu.Recalculate ();
					}
				}
			}
			
			if (stateHandler && settingsManager && playerInput && playerInteraction && options && dialog && menuSystem && Time.time > 0f)
			{
				hotspotLabel = playerInteraction.GetLabel ();
				oldHoverItem = runtimeInventory.hoverItem;
				runtimeInventory.hoverItem = null;
				
				if (stateHandler.gameState == GameState.Paused)
				{
					if (Time.timeScale != 0f)
					{
						//Time.timeScale = 0f;
						sceneSettings.PauseGame ();
					}
				}
				else
				{
					Time.timeScale = playerInput.timeScale;
				}
				
				playerInput.mouseOverMenu = false;
				
				if (!settingsManager.CanClickOffInteractionMenu ())
				{
					playerInput.interactionMenuIsOn = false;
				}
				
				foreach (Menu menu in menus)
				{
					UpdateMenu (menu);
					if (menu.IsEnabled ())
					{
						UpdateElements (menu);
					}
				}
				
				lastElementIdentifier = elementIdentifier;
				
				// Check clicks in reverse order
				for (int i=menus.Count-1; i>=0; i--)
				{
					if (menus[i].IsEnabled () && !menus[i].ignoreMouseClicks)
					{
						CheckClicks (menus[i]);
					}
				}
			}
		}
        /**
         * Resets any active recipe, and clears all MenuCrafting elements.
         */
        /*
        public void RemoveRecipes ()
        {
            while (craftingItems.Count > 0)
            {
                for (int i=0; i<craftingItems.Count; i++)
                {
                    Add (craftingItems[i].id, craftingItems[i].count, false, -1);
                    craftingItems.RemoveAt (i);
                }
            }
            PlayerMenus.ResetInventoryBoxes ();
        }*/
        /**
         * <summary>Moves an ingredient from a crafting recipe back into the player's inventory.</summary>
         * <param name = "_recipeSlot">The index number of the MenuCrafting slot that the ingredient was placed in</param>
         * <param name = "selectAfter">If True, the inventory item will be selected once the transfer is complete</param>
         */
        /*
        public void TransferCraftingToLocal (int _recipeSlot, bool selectAfter)
        {
            foreach (InvItem item in craftingItems)
            {
                if (item.recipeSlot == _recipeSlot)
                {
                    Add (item.id, item.count, selectAfter, -1);
                    SelectItemByID (item.id, SelectItemMode.Use);
                    craftingItems.Remove (item);
                    return;
                }
            }
        }*/
        /**
         * <summary>Moves an ingredient from the player's inventory into a crafting recipe as an ingredient.</summary>
         * <param name = "_item">The inventory item to transfer</param>
         * <param name = "_slot">The index number of the MenuCrafting slot to place the item in</param>
         */
        /*
        public void TransferLocalToCrafting (InvItem _item, int _slot)
        {
            if (_item != null && localItems.Contains (_item))
            {
                _item.recipeSlot = _slot;
                craftingItems.Add (_item);

                localItems [localItems.IndexOf (_item)] = null;
                localItems = ReorderItems (localItems);
                localItems = RemoveEmptySlots (localItems);

                SetNull ();
            }
        }*/
        /**
         * <summary>Gets a list of inventory items associated with the interactions of the current Hotspot or item being hovered over.</summary>
         * <returns>A list of inventory items associated with the interactions of the current Hotspot or item being hovered over</returns>
         */
        /*
        public List<InvItem> MatchInteractions ()
        {
            List<InvItem> items = new List<InvItem>();
            matchingInvInteractions = new List<int>();

            if (!KickStarter.settingsManager.cycleInventoryCursors)
            {
                return items;
            }

            if (hoverItem != null)
            {
                items = MatchInteractionsFromItem (items, hoverItem);
            }
            else if (KickStarter.playerInteraction.GetActiveHotspot ())
            {
                List<Button> invButtons = KickStarter.playerInteraction.GetActiveHotspot ().invButtons;
                foreach (Button button in invButtons)
                {
                    foreach (InvItem item in localItems)
                    {
                        if (item != null && item.id == button.invID && !button.isDisabled)
                        {
                            matchingInvInteractions.Add (invButtons.IndexOf (button));
                            items.Add (item);
                            break;
                        }
                    }
                }
            }
            return items;
        }*/
        private List<InvItem> MatchInteractionsFromItem(List<InvItem> items, InvItem _item)
        {
            if (_item != null && _item.combineID != null)
            {
                foreach (int combineID in _item.combineID)
                {
                    foreach (InvItem item in localItems)
                    {
                        if (item != null && item.id == combineID)
                        {
                            matchingInvInteractions.Add (_item.combineID.IndexOf (combineID));
                            items.Add (item);
                            break;
                        }
                    }
                }
            }
            return items;
        }
Exemple #58
0
        public InvItem(InvItem assetItem)
        {
            count = assetItem.count;
            tex = assetItem.tex;
            activeTex = assetItem.activeTex;
            carryOnStart = assetItem.carryOnStart;
            carryOnStartNotDefault = assetItem.carryOnStartNotDefault;
            carryOnStartID = assetItem.carryOnStartID;
            canCarryMultiple = assetItem.canCarryMultiple;
            label = assetItem.label;
            altLabel = assetItem.altLabel;
            id = assetItem.id;
            lineID = assetItem.lineID;
            useIconID = assetItem.useIconID;
            binID = assetItem.binID;
            useSeparateSlots = assetItem.useSeparateSlots;
            isEditing = false;
            recipeSlot = -1;

            overrideUseSyntax = assetItem.overrideUseSyntax;
            hotspotPrefix1 = assetItem.hotspotPrefix1;
            hotspotPrefix2 = assetItem.hotspotPrefix2;

            useActionList = assetItem.useActionList;
            lookActionList = assetItem.lookActionList;
            interactions = assetItem.interactions;
            combineActionList = assetItem.combineActionList;
            unhandledActionList = assetItem.unhandledActionList;
            unhandledCombineActionList = assetItem.unhandledCombineActionList;
            combineID = assetItem.combineID;
        }
Exemple #59
0
        private bool CheckCondition(InvItem _compareItem, GVar _compareVar)
        {
            if (_parameter == null)
            {
                ACDebug.LogWarning ("Cannot check state of variable since it cannot be found!");
                return false;
            }

            if (_parameter.parameterType == ParameterType.Boolean)
            {
                int fieldValue = _parameter.intValue;
                int compareValue = (int) boolValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.Integer)
            {
                int fieldValue = _parameter.intValue;
                int compareValue = intValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.val;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.Float)
            {
                float fieldValue = _parameter.floatValue;
                float compareValue = floatValue;
                if (_compareVar != null)
                {
                    compareValue = _compareVar.floatVal;
                }

                if (intCondition == IntCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.NotEqualTo)
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.LessThan)
                {
                    if (fieldValue < compareValue)
                    {
                        return true;
                    }
                }
                else if (intCondition == IntCondition.MoreThan)
                {
                    if (fieldValue > compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.String)
            {
                string fieldValue = _parameter.stringValue;
                string compareValue = AdvGame.ConvertTokens (stringValue);
                if (_compareVar != null)
                {
                    compareValue = _compareVar.textVal;
                }

                if (boolCondition == BoolCondition.EqualTo)
                {
                    if (fieldValue == compareValue)
                    {
                        return true;
                    }
                }
                else
                {
                    if (fieldValue != compareValue)
                    {
                        return true;
                    }
                }
            }

            else if (_parameter.parameterType == ParameterType.GameObject)
            {
                if ((compareObject != null && _parameter.gameObject == compareObject) ||
                    (compareObjectConstantID != 0 && _parameter.intValue == compareObjectConstantID))
                {
                    return true;
                }
                if (compareObject == null && _parameter.gameObject == null)
                {
                    return true;
                }
            }

            else if (_parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.LocalVariable)
            {
                if (_compareVar != null && _parameter.intValue == _compareVar.id)
                {
                    return true;
                }
            }

            else if (_parameter.parameterType == ParameterType.InventoryItem)
            {
                if (_compareItem != null && _parameter.intValue == _compareItem.id)
                {
                    return true;
                }
            }

            return false;
        }
Exemple #60
0
        public bool DoesHaveInventoryInteraction(InvItem invItem)
        {
            if (invItem != null)
            {
                foreach (int invID in combineID)
                {
                    if (invID == invItem.id)
                    {
                        return true;
                    }
                }
            }

            return false;
        }