override public void ShowGUI (List<ActionParameter> parameters)
		{
			selectType = (InventorySelectType) EditorGUILayout.EnumPopup ("Select type:", selectType);
			if (selectType == InventorySelectType.DeselectActive)
			{
				return;
			}

			if (!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 (parameterID == -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)
					{
						Debug.LogWarning ("Previously chosen item no longer exists!");
						invNumber = 0;
						invID = 0;
					}

					//
					parameterID = Action.ChooseParameterGUI ("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
					if (parameterID >= 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;
					}
					//
			
					giveToPlayer = EditorGUILayout.Toggle ("Add if not held?", giveToPlayer);
					
					AfterRunningOption ();
				}
		
				else
				{
					EditorGUILayout.HelpBox ("No inventory items exist!", MessageType.Info);
					invID = -1;
					invNumber = -1;
				}
			}
		}
예제 #2
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            selectType = (InventorySelectType)EditorGUILayout.EnumPopup("Select type:", selectType);
            if (selectType == InventorySelectType.DeselectActive)
            {
                AfterRunningOption();
                return;
            }

            if (!inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }
            if (!settingsManager)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            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 (parameterID == -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)
                    {
                        ACDebug.LogWarning("Previously chosen item no longer exists!");
                        invNumber = 0;
                        invID     = 0;
                    }

                    parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                    if (parameterID >= 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;
                    }

                    giveToPlayer = EditorGUILayout.Toggle("Add if not held?", giveToPlayer);

                    if (settingsManager && settingsManager.CanGiveItems())
                    {
                        selectItemMode = (SelectItemMode)EditorGUILayout.EnumPopup("Select item mode:", selectItemMode);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                    invID     = -1;
                    invNumber = -1;
                }
            }
            AfterRunningOption();
        }