示例#1
0
		public void Awake ()
		{
			if (AdvGame.GetReferences () && AdvGame.GetReferences ().inventoryManager)
			{
				inventoryManager = AdvGame.GetReferences ().inventoryManager;
			}
		}
        public void OnEnable()
        {
            _target = (Container) target;

            if (AdvGame.GetReferences () && AdvGame.GetReferences ().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences ().inventoryManager;
            }
        }
		private void GetReferences ()
		{
			if (AdvGame.GetReferences ())
			{
				if (AdvGame.GetReferences ().inventoryManager)
				{
					inventoryManager = AdvGame.GetReferences ().inventoryManager;
				}
				if (AdvGame.GetReferences ().settingsManager)
				{
					settingsManager = AdvGame.GetReferences ().settingsManager;
				}
			}

			playerInteraction = GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInteraction>();
		}
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            checkNothing = EditorGUILayout.Toggle ("Check for none selected?", checkNothing);
            if (!checkNothing)
            {
                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;
                    int invNumber = 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!");
                            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;
                        }

                        AfterRunningOption ();
                    }
                    else
                    {
                        EditorGUILayout.HelpBox ("No inventory items exist!", MessageType.Info);
                        invID = -1;
                    }
                }
            }
        }
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            whatToHighlight = (WhatToHighlight) EditorGUILayout.EnumPopup ("What to highlight:", whatToHighlight);

            if (whatToHighlight == WhatToHighlight.SceneObject)
            {
                parameterID = Action.ChooseParameterGUI ("Object to highlight:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    highlightObject = null;
                }
                else
                {
                    highlightObject = (Highlight) EditorGUILayout.ObjectField ("Object to highlight:", highlightObject, typeof (Highlight), true);

                    constantID = FieldToID <Highlight> (highlightObject, constantID);
                    highlightObject = IDToField <Highlight> (highlightObject, constantID, false);
                }
            }
            else if (whatToHighlight == WhatToHighlight.InventoryItem)
            {
                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 (_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;
                        }
                        //
                    }

                    else
                    {
                        EditorGUILayout.HelpBox ("No inventory items exist!", MessageType.Info);
                        invID = -1;
                        invNumber = -1;
                    }
                }
            }

            highlightType = (HighlightType) EditorGUILayout.EnumPopup ("Highlight type:", highlightType);
            if (highlightType == HighlightType.Enable || highlightType == HighlightType.Disable)
            {
                isInstant = EditorGUILayout.Toggle ("Is instant?", isInstant);
            }

            AfterRunningOption ();
        }
		public override void OnInspectorGUI()
		{
			if (AdvGame.GetReferences () == null)
			{
				Debug.LogError ("A References file is required - please use the Adventure Creator window to create one.");
				EditorGUILayout.LabelField ("No References file found!");
			}
			else
			{
				if (AdvGame.GetReferences ().inventoryManager)
				{
					inventoryManager = AdvGame.GetReferences ().inventoryManager;
				}
				if (AdvGame.GetReferences ().cursorManager)
				{
					cursorManager = AdvGame.GetReferences ().cursorManager;
				}
				if (AdvGame.GetReferences ().settingsManager)
				{
					settingsManager = AdvGame.GetReferences ().settingsManager;
				}
				
				if (_target.lineID > -1)
				{
					EditorGUILayout.LabelField ("Speech Manager ID:", _target.lineID.ToString ());
				}
				
				_target.interactionSource = (InteractionSource) EditorGUILayout.EnumPopup ("Interaction source:", _target.interactionSource);
				_target.hotspotName = EditorGUILayout.TextField ("Label (if not name):", _target.hotspotName);
				_target.highlight = (Highlight) EditorGUILayout.ObjectField ("Object to highlight:", _target.highlight, typeof (Highlight), true);

				EditorGUILayout.BeginHorizontal ();
				_target.walkToMarker = (Marker) EditorGUILayout.ObjectField ("Walk-to marker:", _target.walkToMarker, typeof (Marker), true);

				if (_target.walkToMarker == null)
				{
					if (GUILayout.Button ("Auto-create", autoWidth))
					{
						string prefabName = "Marker";
						if (settingsManager && settingsManager.IsUnity2D ())
						{
							prefabName += "2D";
						}
						Marker newMarker = AdvGame.GetReferences ().sceneManager.AddPrefab ("Navigation", prefabName, true, false, true).GetComponent <Marker>();
						newMarker.gameObject.name += (": " + _target.gameObject.name);
						newMarker.transform.position = _target.transform.position;
						_target.walkToMarker = newMarker;
					}
				}
				EditorGUILayout.EndHorizontal ();

				_target.drawGizmos = EditorGUILayout.Toggle ("Draw yellow cube?", _target.drawGizmos);
				
				if (settingsManager != null && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive)
				{
					_target.oneClick = EditorGUILayout.Toggle ("Single 'Use' Interaction?", _target.oneClick);
				}
				EditorGUILayout.Space ();
				
				UseInteractionGUI ();
				
				if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
				{
					EditorGUILayout.Space ();
					LookInteractionGUI ();
				}
				
				EditorGUILayout.Space ();
				InvInteractionGUI ();
			}
			
			if (GUI.changed)
			{
				EditorUtility.SetDirty (_target);
			}
		}
        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 ();
        }
示例#8
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 string SetLabel()
        {
            if (!inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences ().inventoryManager;
            }

            if (inventoryManager)
            {
                return (" (" + inventoryManager.GetLabel (invID) + ")");
            }

            return "";
        }
        public override string SetLabel()
        {
            string labelAdd = "";
            string labelItem = "";

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

            if (inventoryManager)
            {
                if (inventoryManager.items.Count > 0)
                {
                    if (invNumber > -1)
                    {
                        labelItem = " " + inventoryManager.items[invNumber].label;
                    }
                }
            }

            if (containerAction == ContainerAction.Add)
            {
                labelAdd = " (Add" + labelItem + ")";
            }
            else if (containerAction == ContainerAction.Remove)
            {
                labelAdd = " (Remove" + labelItem + ")";
            }
            else if (containerAction == ContainerAction.RemoveAll)
            {
                labelAdd = " (Remove all)";
            }

            return labelAdd;
        }
示例#11
0
        public override void OnInspectorGUI()
        {
            if (!sideIcon)
            {
                sideIcon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D));
            }

            if (AdvGame.GetReferences () == null)
            {
                ACDebug.LogError ("A References file is required - please use the Adventure Creator window to create one.");
                EditorGUILayout.LabelField ("No References file found!");
            }
            else
            {
                if (AdvGame.GetReferences ().inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences ().inventoryManager;
                }
                if (AdvGame.GetReferences ().cursorManager)
                {
                    cursorManager = AdvGame.GetReferences ().cursorManager;
                }
                if (AdvGame.GetReferences ().settingsManager)
                {
                    settingsManager = AdvGame.GetReferences ().settingsManager;
                }

                if (Application.isPlaying)
                {
                    if (_target.gameObject.layer != LayerMask.NameToLayer (settingsManager.hotspotLayer))
                    {
                        EditorGUILayout.HelpBox ("Current state: OFF", MessageType.Info);
                    }
                }

                if (_target.lineID > -1)
                {
                    EditorGUILayout.LabelField ("Speech Manager ID:", _target.lineID.ToString ());
                }

                _target.interactionSource = (InteractionSource) EditorGUILayout.EnumPopup ("Interaction source:", _target.interactionSource);
                _target.hotspotName = EditorGUILayout.TextField ("Label (if not name):", _target.hotspotName);
                _target.highlight = (Highlight) EditorGUILayout.ObjectField ("Object to highlight:", _target.highlight, typeof (Highlight), true);

                EditorGUILayout.BeginHorizontal ();
                _target.centrePoint = (Transform) EditorGUILayout.ObjectField ("Centre point (override):", _target.centrePoint, typeof (Transform), true);

                if (_target.centrePoint == null)
                {
                    if (GUILayout.Button ("Create", autoWidth))
                    {
                        string prefabName = "Hotspot centre: " + _target.gameObject.name;
                        GameObject go = SceneManager.AddPrefab ("Navigation", "HotspotCentre", true, false, false);
                        go.name = prefabName;
                        go.transform.position = _target.transform.position;
                        _target.centrePoint = go.transform;
                        if (GameObject.Find ("_Markers"))
                        {
                            go.transform.parent = GameObject.Find ("_Markers").transform;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal ();

                EditorGUILayout.BeginHorizontal ();
                _target.walkToMarker = (Marker) EditorGUILayout.ObjectField ("Walk-to marker:", _target.walkToMarker, typeof (Marker), true);

                if (_target.walkToMarker == null)
                {
                    if (GUILayout.Button ("Create", autoWidth))
                    {
                        string prefabName = "Marker";
                        if (settingsManager && settingsManager.IsUnity2D ())
                        {
                            prefabName += "2D";
                        }
                        Marker newMarker = SceneManager.AddPrefab ("Navigation", prefabName, true, false, true).GetComponent <Marker>();
                        newMarker.gameObject.name += (": " + _target.gameObject.name);
                        newMarker.transform.position = _target.transform.position;
                        _target.walkToMarker = newMarker;
                    }
                }
                EditorGUILayout.EndHorizontal ();

                _target.limitToCamera = (_Camera) EditorGUILayout.ObjectField ("Limit to camera:", _target.limitToCamera, typeof (_Camera), true);
                _target.drawGizmos = EditorGUILayout.Toggle ("Draw yellow cube?", _target.drawGizmos);

                if (settingsManager != null && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive)
                {
                    _target.oneClick = EditorGUILayout.Toggle ("Single 'Use' Interaction?", _target.oneClick);
                }
                if (_target.oneClick || (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                {
                    _target.doubleClickingHotspot = (DoubleClickingHotspot) EditorGUILayout.EnumPopup ("Double-clicking:", _target.doubleClickingHotspot);
                }

                EditorGUILayout.Space ();

                UseInteractionGUI ();

                if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                {
                    EditorGUILayout.Space ();
                    LookInteractionGUI ();
                }

                EditorGUILayout.Space ();
                InvInteractionGUI ();

                EditorGUILayout.Space ();
                UnhandledInvInteractionGUI ();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty (_target);
            }
        }
示例#12
0
        /**
         * <summary>Unsets the values of all script variables, so that they can be re-assigned to the correct scene if multiple scenes are open.</summary>
         */
        public void ClearVariables()
        {
            playerPrefab = null;
            mainCameraPrefab = null;
            persistentEnginePrefab = null;
            gameEnginePrefab = null;

            // Managers
            sceneManagerPrefab = null;
            settingsManagerPrefab = null;
            actionsManagerPrefab = null;
            variablesManagerPrefab = null;
            inventoryManagerPrefab = null;
            speechManagerPrefab = null;
            cursorManagerPrefab = null;
            menuManagerPrefab = null;

            // PersistentEngine components
            optionsComponent = null;
            runtimeInventoryComponent = null;
            runtimeVariablesComponent = null;
            playerMenusComponent = null;
            stateHandlerComponent = null;
            sceneChangerComponent = null;
            saveSystemComponent = null;
            levelStorageComponent = null;
            runtimeLanguagesComponent = null;

            // GameEngine components
            menuSystemComponent = null;
            dialogComponent = null;
            playerInputComponent = null;
            playerInteractionComponent = null;
            playerMovementComponent = null;
            playerCursorComponent = null;
            playerQTEComponent = null;
            sceneSettingsComponent = null;
            navigationManagerComponent = null;
            actionListManagerComponent = null;
            localVariablesComponent = null;
            menuPreviewComponent = null;

            SetGameEngine ();
        }
        public override string SetLabel()
        {
            string labelAdd = "";
            string labelItem = "";

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

            if (inventoryManager)
            {
                labelItem = " " + inventoryManager.GetLabel (invID);
            }

            if (invAction == InvAction.Remove)
            {
                labelAdd = " (Remove" + labelItem + ")";
            }
            else
            {
                labelAdd = " (Add" + labelItem + ")";
            }

            return labelAdd;
        }
示例#14
0
		private void OnDestroy ()
		{
			inventoryManager = null;
		}
		override public void ShowGUI (List<ActionParameter> parameters)
		{
			if (inventoryManager == null && AdvGame.GetReferences ().inventoryManager)
			{
				inventoryManager = AdvGame.GetReferences ().inventoryManager;
			}
			if (settingsManager == null && AdvGame.GetReferences ().settingsManager)
			{
				settingsManager = AdvGame.GetReferences ().settingsManager;
			}
			
			if (inventoryManager != null)
			{
				// 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 a item has been removed, make sure selected variable is still valid
						if (_item.id == invID)
						{
							invNumber = i;
						}
						
						i++;
					}
					
					if (invNumber == -1)
					{
						Debug.Log ("Previously chosen item no longer exists!");
						invNumber = 0;
						invID = 0;
					}
					
					invAction = (InvAction) EditorGUILayout.EnumPopup ("Add or remove:", invAction);

					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;
					}

					if (inventoryManager.items[invNumber].canCarryMultiple)
					{
						setAmount = EditorGUILayout.Toggle ("Set amount?", setAmount);
					
						if (setAmount)
						{
							if (invAction == InvAction.Add)
							{
								amount = EditorGUILayout.IntField ("Increase count by:", amount);
							}
							else
							{
								amount = EditorGUILayout.IntField ("Reduce count by:", amount);
							}
						}
					}
				}
				else
				{
					EditorGUILayout.HelpBox ("No inventory items exist!", MessageType.Info);
					invID = -1;
					invNumber = -1;
				}

				if (settingsManager != null && settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory)
				{
					EditorGUILayout.Space ();

					setPlayer = EditorGUILayout.Toggle ("Affect specific player?", setPlayer);
					if (setPlayer)
					{
						ChoosePlayerGUI ();
					}
				}
				else
				{
					setPlayer = false;
				}
			}
			else
			{
				EditorGUILayout.HelpBox ("An Inventory Manager must be assigned for this Action to work", MessageType.Warning);
			}

			AfterRunningOption ();
		}
        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;
                }
            }
        }
		override public string SetLabel ()
		{
			string labelAdd = "";
			string labelItem = "";

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

			if (inventoryManager)
			{
				if (inventoryManager.items.Count > 0 && invNumber >= 0 && inventoryManager.items.Count > invNumber)
				{
					labelItem = " " + inventoryManager.items[invNumber].label;
				}
			}
			
			if (invAction == InvAction.Add)
			{
				labelAdd = " (Add" + labelItem + ")";
			}
			else
			{
				labelAdd = " (Remove" + labelItem + ")";
			}
		
			return labelAdd;
		}
示例#18
0
        public override string SetLabel()
        {
            if (!inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences ().inventoryManager;
            }

            if (inventoryManager)
            {
                if (inventoryManager.items.Count > 0 && inventoryManager.items.Count > invNumber && invNumber > -1)
                {
                    return (" (" + inventoryManager.items[invNumber].label + ")");
                }
            }

            return "";
        }
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            if (inventoryManager == null && AdvGame.GetReferences ().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences ().inventoryManager;
            }
            if (settingsManager == null && AdvGame.GetReferences ().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)
                    {
                        // Wasn't found (item was possibly deleted), so revert to zero
                        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;
                    }
                    //

                    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;
                    }

                    if (settingsManager != null && settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory)
                    {
                        EditorGUILayout.Space ();

                        setPlayer = EditorGUILayout.Toggle ("Check specific player?", setPlayer);
                        if (setPlayer)
                        {
                            ChoosePlayerGUI ();
                        }
                    }
                    else
                    {
                        setPlayer = false;
                    }
                }
                else
                {
                    EditorGUILayout.LabelField ("No inventory items exist!");
                    invID = -1;
                    invNumber = -1;
                }
            }
            else
            {
                EditorGUILayout.HelpBox ("An Inventory Manager must be assigned for this Action to work", MessageType.Warning);
            }
        }
		private void OnEnable ()
		{
			inventoryManager = null;
		}