Esempio n. 1
0
        public void ClickContainer(MouseState _mouseState, int _slot, Container container)
        {
            if (container == null || KickStarter.runtimeInventory == null) return;

            KickStarter.runtimeInventory.SetFont (font, GetFontSize (), fontColor, textEffects);

            if (_mouseState == MouseState.SingleClick)
            {
                if (KickStarter.runtimeInventory.selectedItem == null)
                {
                    if (container.items.Count > (_slot+offset) && container.items [_slot+offset] != null)
                    {
                        ContainerItem containerItem = container.items [_slot + offset];
                        KickStarter.runtimeInventory.Add (containerItem.linkedID, containerItem.count, selectItemsAfterTaking, -1);
                        container.items.Remove (containerItem);
                    }
                }
                else
                {
                    // Placing an item inside the container
                    container.InsertAt (KickStarter.runtimeInventory.selectedItem, _slot+offset);
                    KickStarter.runtimeInventory.Remove (KickStarter.runtimeInventory.selectedItem);
                }
            }

            else if (_mouseState == MouseState.RightClick)
            {
                if (KickStarter.runtimeInventory.selectedItem != null)
                {
                    KickStarter.runtimeInventory.SetNull ();
                }
            }
        }
        public override void AssignValues(List<ActionParameter> parameters)
        {
            container = AssignFile <Container> (parameters, parameterID, constantID, container);

            if (useActive)
            {
                container = KickStarter.playerInput.activeContainer;
            }
        }
        public void OnEnable()
        {
            _target = (Container) target;

            if (AdvGame.GetReferences () && AdvGame.GetReferences ().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences ().inventoryManager;
            }
        }
		override public void AssignValues (List<ActionParameter> parameters)
		{
			container = AssignFile <Container> (parameters, parameterID, constantID, container);
			invID = AssignInvItemID (parameters, invParameterID, invID);

			if (useActive)
			{
				container = GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInput>().activeContainer;
			}
		}
Esempio n. 5
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            if (AdvGame.GetReferences ().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences ().inventoryManager;
            }

            if (inventoryManager)
            {
                // Create a string List of the field's names (for the PopUp box)
                List<string> labelList = new List<string>();

                int i = 0;
                if (invParameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add (_item.label);
                        // If an item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        // Wasn't found (item was possibly deleted), so revert to zero
                        ACDebug.LogWarning ("Previously chosen item no longer exists!");

                        invNumber = 0;
                        invID = 0;
                    }

                    useActive = EditorGUILayout.Toggle ("Affect active container?", useActive);
                    if (!useActive)
                    {
                        parameterID = Action.ChooseParameterGUI ("Container:", parameters, parameterID, ParameterType.GameObject);
                        if (parameterID >= 0)
                        {
                            constantID = 0;
                            container = null;
                        }
                        else
                        {
                            container = (Container) EditorGUILayout.ObjectField ("Container:", container, typeof (Container), true);

                            constantID = FieldToID <Container> (container, constantID);
                            container = IDToField <Container> (container, constantID, false);
                        }

                    }

                    //
                    invParameterID = Action.ChooseParameterGUI ("Item to check:", parameters, invParameterID, ParameterType.InventoryItem);
                    if (invParameterID >= 0)
                    {
                        invNumber = Mathf.Min (invNumber, inventoryManager.items.Count-1);
                        invID = -1;
                    }
                    else
                    {
                        invNumber = EditorGUILayout.Popup ("Item to check:", invNumber, labelList.ToArray());
                        invID = inventoryManager.items[invNumber].id;
                    }
                    //

                    if (inventoryManager.items[invNumber].canCarryMultiple)
                    {
                        doCount = EditorGUILayout.Toggle ("Query count?", doCount);

                        if (doCount)
                        {
                            EditorGUILayout.BeginHorizontal ("");
                                EditorGUILayout.LabelField ("Count is:", GUILayout.MaxWidth (70));
                                intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition);
                                intValue = EditorGUILayout.IntField (intValue);

                                if (intValue < 1)
                                {
                                    intValue = 1;
                                }
                            EditorGUILayout.EndHorizontal ();
                        }
                    }
                    else
                    {
                        doCount = false;
                    }
                }

                else
                {
                    EditorGUILayout.LabelField ("No inventory items exist!");
                    invID = -1;
                    invNumber = -1;
                }
            }
        }
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            if (AdvGame.GetReferences ().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences ().inventoryManager;
            }

            if (inventoryManager)
            {
                // Create a string List of the field's names (for the PopUp box)
                List<string> labelList = new List<string>();

                int i = 0;
                if (invParameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add (_item.label);

                        // If a item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        ACDebug.LogWarning ("Previously chosen item no longer exists!");
                        invNumber = 0;
                        invID = 0;
                    }

                    useActive = EditorGUILayout.Toggle ("Affect active container?", useActive);
                    if (!useActive)
                    {
                        parameterID = Action.ChooseParameterGUI ("Container:", parameters, parameterID, ParameterType.GameObject);
                        if (parameterID >= 0)
                        {
                            constantID = 0;
                            container = null;
                        }
                        else
                        {
                            container = (Container) EditorGUILayout.ObjectField ("Container:", container, typeof (Container), true);

                            constantID = FieldToID <Container> (container, constantID);
                            container = IDToField <Container> (container, constantID, false);
                        }
                    }

                    containerAction = (ContainerAction) EditorGUILayout.EnumPopup ("Method:", containerAction);

                    if (containerAction == ContainerAction.RemoveAll)
                    {
                        transferToPlayer = EditorGUILayout.Toggle ("Transfer to Player?", transferToPlayer);
                    }
                    else
                    {
                        //
                        invParameterID = Action.ChooseParameterGUI ("Inventory item:", parameters, invParameterID, ParameterType.InventoryItem);
                        if (invParameterID >= 0)
                        {
                            invNumber = Mathf.Min (invNumber, inventoryManager.items.Count-1);
                            invID = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup ("Inventory item:", invNumber, labelList.ToArray());
                            invID = inventoryManager.items[invNumber].id;
                        }
                        //

                        if (containerAction == ContainerAction.Remove)
                        {
                            transferToPlayer = EditorGUILayout.Toggle ("Transfer to Player?", transferToPlayer);
                        }

                        if (inventoryManager.items[invNumber].canCarryMultiple)
                        {
                            setAmount = EditorGUILayout.Toggle ("Set amount?", setAmount);

                            if (setAmount)
                            {
                                if (containerAction == ContainerAction.Add)
                                {
                                    amount = EditorGUILayout.IntField ("Increase count by:", amount);
                                }
                                else if (containerAction == ContainerAction.Remove)
                                {
                                    amount = EditorGUILayout.IntField ("Reduce count by:", amount);
                                }
                            }
                        }
                    }

                    AfterRunningOption ();
                }

                else
                {
                    EditorGUILayout.LabelField ("No inventory items exist!");
                    invID = -1;
                    invNumber = -1;
                }
            }
        }
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            useActive = EditorGUILayout.Toggle ("Affect active container?", useActive);
            if (!useActive)
            {
                parameterID = Action.ChooseParameterGUI ("Container:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    container = null;
                }
                else
                {
                    container = (Container) EditorGUILayout.ObjectField ("Container:", container, typeof (Container), true);

                    constantID = FieldToID <Container> (container, constantID);
                    container = IDToField <Container> (container, constantID, false);
                }
            }
        }
Esempio n. 8
0
        public void TransferLocalToContainer(Container _container, InvItem _item, int _index)
        {
            if (_item != null && localItems.Contains (_item))
            {
                localItems [localItems.IndexOf (_item)] = null;
                localItems = ReorderItems (localItems);
                localItems = RemoveEmptySlots (localItems);

                SetNull ();
            }
        }
Esempio n. 9
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            if (AdvGame.GetReferences().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }

            if (inventoryManager)
            {
                // Create a string List of the field's names (for the PopUp box)
                List <string> labelList = new List <string>();

                int i = 0;
                if (invParameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add(_item.label);
                        // If an item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        // Wasn't found (item was possibly deleted), so revert to zero
                        ACDebug.LogWarning("Previously chosen item no longer exists!");

                        invNumber = 0;
                        invID     = 0;
                    }

                    useActive = EditorGUILayout.Toggle("Affect active container?", useActive);
                    if (!useActive)
                    {
                        parameterID = Action.ChooseParameterGUI("Container:", parameters, parameterID, ParameterType.GameObject);
                        if (parameterID >= 0)
                        {
                            constantID = 0;
                            container  = null;
                        }
                        else
                        {
                            container = (Container)EditorGUILayout.ObjectField("Container:", container, typeof(Container), true);

                            constantID = FieldToID <Container> (container, constantID);
                            container  = IDToField <Container> (container, constantID, false);
                        }
                    }

                    //
                    invParameterID = Action.ChooseParameterGUI("Item to check:", parameters, invParameterID, ParameterType.InventoryItem);
                    if (invParameterID >= 0)
                    {
                        invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                        invID     = -1;
                    }
                    else
                    {
                        invNumber = EditorGUILayout.Popup("Item to check:", invNumber, labelList.ToArray());
                        invID     = inventoryManager.items[invNumber].id;
                    }
                    //

                    if (inventoryManager.items[invNumber].canCarryMultiple)
                    {
                        doCount = EditorGUILayout.Toggle("Query count?", doCount);

                        if (doCount)
                        {
                            EditorGUILayout.BeginHorizontal("");
                            EditorGUILayout.LabelField("Count is:", GUILayout.MaxWidth(70));
                            intCondition = (IntCondition)EditorGUILayout.EnumPopup(intCondition);
                            intValue     = EditorGUILayout.IntField(intValue);

                            if (intValue < 1)
                            {
                                intValue = 1;
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        doCount = false;
                    }
                }

                else
                {
                    EditorGUILayout.LabelField("No inventory items exist!");
                    invID     = -1;
                    invNumber = -1;
                }
            }
        }