private void OnEnable()
 {
     if (AdvGame.GetReferences () && AdvGame.GetReferences ().settingsManager)
     {
         settingsManager = AdvGame.GetReferences ().settingsManager;
     }
 }
		override public bool CheckCondition ()
		{
			RuntimeInventory runtimeInventory = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <RuntimeInventory>();
			settingsManager = AdvGame.GetReferences ().settingsManager;
			int count = 0;
			
			if (settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory && setPlayer)
			{
				count = runtimeInventory.GetCount (invID, playerID);
			}
			else
			{
				count = runtimeInventory.GetCount (invID);
			}
			
			if (doCount)
			{
				if (intCondition == IntCondition.EqualTo)
				{
					if (count == intValue)
					{
						return true;
					}
				}
				
				else if (intCondition == IntCondition.NotEqualTo)
				{
					if (count != intValue)
					{
						return true;
					}
				}
				
				else if (intCondition == IntCondition.LessThan)
				{
					if (count < intValue)
					{
						return true;
					}
				}
				
				else if (intCondition == IntCondition.MoreThan)
				{
					if (count > intValue)
					{
						return true;
					}
				}
			}
			
			else if (count > 0)
			{
				return true;
			}
			
			return false;	
		}
		private void Awake ()
		{
			if (disableRenderer)
			{
				Hide ();
			}

			settingsManager = AdvGame.GetReferences ().settingsManager;
			sceneSettings = GameObject.FindWithTag (Tags.gameEngine).GetComponent <SceneSettings>();

			ResetHoles ();
		}
		private void Awake ()
		{
			if (AdvGame.GetReferences () && AdvGame.GetReferences ().settingsManager)
			{
				settingsManager = AdvGame.GetReferences ().settingsManager;
			}
			
			playerInput = this.GetComponent <PlayerInput>();
			playerInteraction = this.GetComponent <PlayerInteraction>();
			playerCursor = this.GetComponent <PlayerCursor>();
			sceneSettings = this.GetComponent <SceneSettings>();
			navigationManager = this.GetComponent <NavigationManager>();
		}
		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>();
		}
		override public float Run ()
		{
			RuntimeInventory runtimeInventory = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <RuntimeInventory>();
			
			if (runtimeInventory)
			{
				if (!setAmount)
				{
					amount = 1;
				}

				settingsManager = AdvGame.GetReferences ().settingsManager;

				if (settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory && setPlayer)
				{
					if (invAction == InvAction.Add)
					{
						runtimeInventory.Add (invID, amount, false, playerID);
					}
					else
					{
						runtimeInventory.Remove (invID, amount, setAmount, playerID);
					}
				}
				else
				{
					if (invAction == InvAction.Add)
					{
						runtimeInventory.Add (invID, amount, false, -1);
					}
					else
					{
						runtimeInventory.Remove (invID, amount, setAmount, -1);
					}
				}

				PlayerMenus.ResetInventoryBoxes ();
			}
			
			return 0f;
		}
		private void Awake ()
		{
			playerInput = this.GetComponent <PlayerInput>();
			playerCursor = this.GetComponent <PlayerCursor>();

			if (AdvGame.GetReferences () == null)
			{
				Debug.LogError ("A References file is required - please use the Adventure Creator window to create one.");
			}
			else
			{
				if (AdvGame.GetReferences ().settingsManager)
				{
					settingsManager = AdvGame.GetReferences ().settingsManager;
				}
				if (AdvGame.GetReferences ().cursorManager)
				{
					cursorManager = AdvGame.GetReferences ().cursorManager;
				}
			}
		}
		private void Awake ()
		{
			if (AdvGame.GetReferences () && AdvGame.GetReferences ().settingsManager && AdvGame.GetReferences ().cursorManager)
			{
				settingsManager = AdvGame.GetReferences ().settingsManager;
				cursorManager = AdvGame.GetReferences ().cursorManager;
				
			}
			
			if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
			{
				UpgradeSelf ();
			}
			
			if (GetComponent <Collider>())
			{
				_collider = GetComponent <Collider>();
			}
			else if (GetComponent <Collider2D>())
			{
				_collider2D = GetComponent <Collider2D>();
			}
		}
Exemple #9
0
        public override void OnInspectorGUI()
        {
            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 = (AC.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);
                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.hotspotDrawing == ScreenWorld.WorldSpace)
                {
                    _target.iconSortingLayer = EditorGUILayout.TextField("Icon sorting layer:", _target.iconSortingLayer);
                    _target.iconSortingOrder = EditorGUILayout.IntField("Icon sprite order:", _target.iconSortingOrder);
                }

                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 (SceneSettings.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);

                EditorGUILayout.BeginHorizontal();
                _target.interactiveBoundary = (InteractiveBoundary)EditorGUILayout.ObjectField("Interactive boundary:", _target.interactiveBoundary, typeof(InteractiveBoundary), true);
                if (_target.interactiveBoundary == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string prefabName = "InteractiveBoundary";
                        if (SceneSettings.IsUnity2D())
                        {
                            prefabName += "2D";
                        }
                        InteractiveBoundary newInteractiveBoundary = SceneManager.AddPrefab("Logic", prefabName, true, false, true).GetComponent <InteractiveBoundary>();
                        newInteractiveBoundary.gameObject.name   += (": " + _target.gameObject.name);
                        newInteractiveBoundary.transform.position = _target.transform.position;
                        _target.interactiveBoundary = newInteractiveBoundary;

                        UnityVersionHandler.PutInFolder(newInteractiveBoundary.gameObject, "_Hotspots");
                    }
                }
                EditorGUILayout.EndHorizontal();

                _target.drawGizmos = EditorGUILayout.Toggle("Draw yellow cube?", _target.drawGizmos);

                if (settingsManager != null && (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction || settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot || settingsManager.interactionMethod == AC_InteractionMethod.CustomScript))
                {
                    _target.oneClick = EditorGUILayout.Toggle("Single 'Use' Interaction?", _target.oneClick);

                    if (_target.oneClick && settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)
                    {
                        EditorGUILayout.HelpBox("The above property can be accessed by reading the Hotspot script's IsSingleInteraction() method.", MessageType.Info);
                    }
                }
                if (_target.oneClick || (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                {
                    if (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)
                    {
                    }
                    else
                    {
                        _target.doubleClickingHotspot = (DoubleClickingHotspot)EditorGUILayout.EnumPopup("Double-clicking:", _target.doubleClickingHotspot);
                    }
                }
                if (settingsManager != null && settingsManager.playerFacesHotspots)
                {
                    _target.playerTurnsHead = EditorGUILayout.Toggle("Players turn heads when active?", _target.playerTurnsHead);
                }

                EditorGUILayout.Space();

                UseInteractionGUI();

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

                EditorGUILayout.Space();
                InvInteractionGUI();

                EditorGUILayout.Space();
                UnhandledInvInteractionGUI();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
		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 ();
		}
		private Vector3 GetLookVector (SettingsManager settingsManager)
		{
			Vector3 lookVector = faceObject.transform.position - charToMove.transform.position;
			if (copyRotation)
			{
				lookVector = faceObject.transform.forward;
			}
			else if (settingsManager.ActInScreenSpace ())
			{
				lookVector = AdvGame.GetScreenDirection (charToMove.transform.position, faceObject.transform.position);
			}

			return lookVector;
		}
        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 ();
        }
Exemple #13
0
		public override void ShowGUI (List<ActionParameter> parameters)
		{
			if (settingsManager == null)
			{
				settingsManager = AdvGame.GetReferences ().settingsManager;
			}
			
			if (settingsManager == null)
			{
				return;
			}
			
			if (settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
			{
				EditorGUILayout.HelpBox ("This Action requires Player Switching to be allowed, as set in the Settings Manager.", MessageType.Info);
				return;
			}
			
			if (settingsManager.players.Count > 0)
			{
				playerIDParameterID = Action.ChooseParameterGUI ("New Player ID:", parameters, playerIDParameterID, ParameterType.Integer);
				if (playerIDParameterID == -1)
				{
					// Create a string List of the field's names (for the PopUp box)
					List<string> labelList = new List<string>();
					
					int i = 0;
					int playerNumber = -1;

					foreach (PlayerPrefab playerPrefab in settingsManager.players)
					{
						if (playerPrefab.playerOb != null)
						{
							labelList.Add (playerPrefab.playerOb.name);
						}
						else
						{
							labelList.Add ("(Undefined prefab)");
						}
						
						// If a player has been removed, make sure selected player is still valid
						if (playerPrefab.ID == playerID)
						{
							playerNumber = i;
						}
						
						i++;
					}
					
					if (playerNumber == -1)
					{
						// Wasn't found (item was possibly deleted), so revert to zero
						ACDebug.LogWarning ("Previously chosen Player no longer exists!");
						
						playerNumber = 0;
						playerID = 0;
					}
				
					playerNumber = EditorGUILayout.Popup ("New Player:", playerNumber, labelList.ToArray());
					playerID = settingsManager.players[playerNumber].ID;
				}

				if (AdvGame.GetReferences ().settingsManager == null || !AdvGame.GetReferences ().settingsManager.shareInventory)
				{
					keepInventory = EditorGUILayout.Toggle ("Transfer inventory?", keepInventory);
				}
				restorePreviousData = EditorGUILayout.Toggle ("Restore position?", restorePreviousData);
				if (restorePreviousData)
				{
					EditorGUILayout.BeginVertical (CustomStyles.thinBox);
					EditorGUILayout.LabelField ("If first time in game:", EditorStyles.boldLabel);
				}
				
				newPlayerPosition = (NewPlayerPosition) EditorGUILayout.EnumPopup ("New Player position:", newPlayerPosition);
				
				if (newPlayerPosition == NewPlayerPosition.ReplaceNPC)
				{
					newPlayerNPC = (NPC) EditorGUILayout.ObjectField ("NPC to be replaced:", newPlayerNPC, typeof (NPC), true);
					
					newPlayerNPC_ID = FieldToID <NPC> (newPlayerNPC, newPlayerNPC_ID);
					newPlayerNPC = IDToField <NPC> (newPlayerNPC, newPlayerNPC_ID, false);
				}
				else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
				{
					newPlayerMarker = (Marker) EditorGUILayout.ObjectField ("Marker to appear at:", newPlayerMarker, typeof (Marker), true);
					
					newPlayerMarker_ID = FieldToID <Marker> (newPlayerMarker, newPlayerMarker_ID);
					newPlayerMarker = IDToField <Marker> (newPlayerMarker, newPlayerMarker_ID, false);
				}
				else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
				{
					chooseNewSceneBy = (ChooseSceneBy) EditorGUILayout.EnumPopup ("Choose scene by:", chooseNewSceneBy);
					if (chooseNewSceneBy == ChooseSceneBy.Name)
					{
						newPlayerSceneName = EditorGUILayout.TextField ("Scene to appear in:", newPlayerSceneName);
					}
					else
					{
						newPlayerScene = EditorGUILayout.IntField ("Scene to appear in:", newPlayerScene);
					}

					newPlayerNPC = (NPC) EditorGUILayout.ObjectField ("NPC to be replaced:", newPlayerNPC, typeof (NPC), true);
					
					newPlayerNPC_ID = FieldToID <NPC> (newPlayerNPC, newPlayerNPC_ID);
					newPlayerNPC = IDToField <NPC> (newPlayerNPC, newPlayerNPC_ID, false);

					EditorGUILayout.HelpBox ("If the Player has an Associated NPC defined, it will be used if none is defined here.", MessageType.Info);
				}
				else if (newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
				{
					EditorGUILayout.HelpBox ("A Player's 'Associated NPC' is defined in the Player Inspector.", MessageType.Info);
				}

				if (restorePreviousData)
				{
					EditorGUILayout.EndVertical ();
				}

				if (newPlayerPosition == NewPlayerPosition.ReplaceNPC ||
					newPlayerPosition == NewPlayerPosition.AppearAtMarker ||
					newPlayerPosition == NewPlayerPosition.AppearInOtherScene ||
					newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
				{
					EditorGUILayout.Space ();
					oldPlayer = (OldPlayer) EditorGUILayout.EnumPopup ("Old Player:", oldPlayer);
					
					if (oldPlayer == OldPlayer.ReplaceWithNPC)
					{
						oldPlayerNPC = (NPC) EditorGUILayout.ObjectField ("NPC to replace old Player:", oldPlayerNPC, typeof (NPC), true);
						
						oldPlayerNPC_ID = FieldToID <NPC> (oldPlayerNPC, oldPlayerNPC_ID);
						oldPlayerNPC = IDToField <NPC> (oldPlayerNPC, oldPlayerNPC_ID, false);

						EditorGUILayout.HelpBox ("This NPC must be already be present in the scene - either within the scene file itself, or spawned at runtime with the 'Object: Add or remove' Action.", MessageType.Info);
					}
					else if (oldPlayer == OldPlayer.ReplaceWithAssociatedNPC)
					{
						EditorGUILayout.HelpBox ("A Player's 'Associated NPC' is defined in the Player Inspector.", MessageType.Info);
					}
				}
			}
			else
			{
				EditorGUILayout.LabelField ("No players exist!");
				playerID = -1;
			}

			alwaysSnapCamera = EditorGUILayout.Toggle ("Snap camera if shared?", alwaysSnapCamera);
			
			EditorGUILayout.Space ();
			
			AfterRunningOption ();
		}
Exemple #14
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);
            }
        }
Exemple #15
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            settingsManager = AdvGame.GetReferences().settingsManager;

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Global cursor settings", CustomStyles.subHeader);
            EditorGUILayout.Space();

            cursorRendering     = (CursorRendering)CustomGUILayout.EnumPopup("Cursor rendering:", cursorRendering, "AC.KickStarter.cursorManager.cursorRendering");
            forceCursorInEditor = CustomGUILayout.ToggleLeft("Always show system cursor in Editor?", forceCursorInEditor, "AC.KickStarter.cursorManager.forceCursorInEditor");
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Main cursor", CustomStyles.subHeader);
            EditorGUILayout.Space();

            cursorDisplay = (CursorDisplay)CustomGUILayout.EnumPopup("Display cursor:", cursorDisplay, "AC.KickStarter.cursorManager.cursorDisplay");
            if (cursorDisplay != CursorDisplay.Never)
            {
                allowMainCursor = CustomGUILayout.Toggle("Replace mouse cursor?", allowMainCursor, "AC.KickStarter.cursorManager.allowMainCursor");
                if (allowMainCursor || (settingsManager && settingsManager.inputMethod == InputMethod.KeyboardOrController))
                {
                    IconBaseGUI("Main cursor:", pointerIcon, "AC.KickStarter.cursorManager.pointerIcon");
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Walk settings", CustomStyles.subHeader);
            EditorGUILayout.Space();

            if (allowMainCursor)
            {
                allowWalkCursor = CustomGUILayout.Toggle("Provide walk cursor?", allowWalkCursor, "AC.KickStarter.cursorManager.allowWalkCursor");
                if (allowWalkCursor)
                {
                    if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                    {
                        EditorGUILayout.LabelField("Input button:", "Icon_Walk");
                    }
                    IconBaseGUI("Walk cursor:", walkIcon, "AC.KickStarter.cursorManager.walkIcon");
                    onlyWalkWhenOverNavMesh = CustomGUILayout.ToggleLeft("Only show 'Walk' Cursor when over NavMesh?", onlyWalkWhenOverNavMesh, "AC.KickStarter.cursorManager.onlyWalkWhenOverNavMesh");
                }
            }
            addWalkPrefix = CustomGUILayout.Toggle("Prefix cursor labels?", addWalkPrefix, "AC.KickStarter.cursorManager.addWalkPrefix");
            if (addWalkPrefix)
            {
                walkPrefix.label = CustomGUILayout.TextField("Walk prefix:", walkPrefix.label, "AC.KickStarter.cursorManager.walkPrefix");
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Hotspot settings", CustomStyles.subHeader);
            EditorGUILayout.Space();

            addHotspotPrefix = CustomGUILayout.Toggle("Prefix cursor labels?", addHotspotPrefix, "AC.KickStarter.cursorManager.addHotspotPrefix");
            IconBaseGUI("Mouse-over cursor:", mouseOverIcon, "AC.KickStarter.cursorManager.mouseOverIcon");
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Inventory cursor", CustomStyles.subHeader);
            EditorGUILayout.Space();

            inventoryHandling = (InventoryHandling)CustomGUILayout.EnumPopup("When inventory selected:", inventoryHandling, "AC.KickStarter.cursorManager.inventoryHandling");
            if (inventoryHandling != InventoryHandling.ChangeCursor)
            {
                onlyShowInventoryLabelOverHotspots = CustomGUILayout.ToggleLeft("Only show label when over Hotspots and Inventory?", onlyShowInventoryLabelOverHotspots, "AC.KickStarter.cursorManager.onlyShowInventoryLabelOverHotspots");
            }
            if (inventoryHandling != InventoryHandling.ChangeHotspotLabel)
            {
                inventoryCursorSize = CustomGUILayout.FloatField("Inventory cursor size:", inventoryCursorSize, "AC.KickStarter.cursorManager.inventoryCursorSize");
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Use syntax:", GUILayout.Width(100f));
            hotspotPrefix1.label = CustomGUILayout.TextField(hotspotPrefix1.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix1");
            EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f));
            hotspotPrefix2.label = CustomGUILayout.TextField(hotspotPrefix2.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix2");
            EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f));
            EditorGUILayout.EndHorizontal();
            if (AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.CanGiveItems())
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Give syntax:", GUILayout.Width(100f));
                hotspotPrefix3.label = CustomGUILayout.TextField(hotspotPrefix3.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix3");
                EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f));
                hotspotPrefix4.label = CustomGUILayout.TextField(hotspotPrefix4.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix4");
                EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f));
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Interaction icons", CustomStyles.subHeader);
            EditorGUILayout.Space();

            if (settingsManager == null || settingsManager.interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction)
            {
                allowInteractionCursor = CustomGUILayout.ToggleLeft("Change cursor based on Interaction?", allowInteractionCursor, "AC.KickStarter.cursorManager.allowInteractionCursor");
                if (allowInteractionCursor && (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                {
                    allowInteractionCursorForInventory = CustomGUILayout.ToggleLeft("Change when over Inventory items too?", allowInteractionCursorForInventory, "AC.KickStarter.cursorManager.allowInteractionCursorForInventory");
                }
                if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                {
                    cycleCursors            = CustomGUILayout.ToggleLeft("Cycle Interactions with right-click?", cycleCursors, "AC.KickStarter.cursorManager.cycleCursors");
                    onlyAnimateOverHotspots = CustomGUILayout.ToggleLeft("Only animate icons when over Hotspots?", onlyAnimateOverHotspots, "AC.KickStarter.cursorManager.onlyAnimateOverHotspots");
                }
            }

            IconsGUI();

            EditorGUILayout.Space();

            if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
            {
                LookIconGUI();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Cutscene cursor", CustomStyles.subHeader);
            EditorGUILayout.Space();

            IconBaseGUI("", waitIcon, "AC.KickStarter.cursorManager.waitIcon");
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);
            }
        }
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            Upgrade();

            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)
                    {
                        if (invID > 0)
                        {
                            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);
                    carryCondition = (CarryCondition)EditorGUILayout.EnumPopup("Carry condition:", carryCondition);

                    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();
        }
Exemple #17
0
        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;
            }

            invCheckType = (InvCheckType)EditorGUILayout.EnumPopup("Check to make:", invCheckType);
            if (invCheckType == InvCheckType.NumberOfItemsCarrying)
            {
                intCondition = (IntCondition)EditorGUILayout.EnumPopup("Count is:", intCondition);

                intValueParameterID = Action.ChooseParameterGUI(intCondition.ToString() + ":", parameters, intValueParameterID, ParameterType.Integer);
                if (intValueParameterID < 0)
                {
                    intValue = EditorGUILayout.IntField(intCondition.ToString() + ":", intValue);
                }

                if (inventoryManager != null && inventoryManager.bins != null && inventoryManager.bins.Count > 0)
                {
                    checkNumberInCategory = EditorGUILayout.Toggle("Check specific category?", checkNumberInCategory);
                    if (checkNumberInCategory)
                    {
                        int      categoryIndex = 0;
                        string[] popupList     = new string[inventoryManager.bins.Count];
                        for (int i = 0; i < inventoryManager.bins.Count; i++)
                        {
                            popupList[i] = inventoryManager.bins[i].label;

                            if (inventoryManager.bins[i].id == categoryIDToCheck)
                            {
                                categoryIndex = i;
                            }
                        }

                        categoryIndex     = EditorGUILayout.Popup("Limit to category:", categoryIndex, popupList);
                        categoryIDToCheck = inventoryManager.bins[categoryIndex].id;
                    }
                }

                SetPlayerGUI();
                return;
            }

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

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

                        if (doCount)
                        {
                            intCondition        = (IntCondition)EditorGUILayout.EnumPopup("Count is:", intCondition);
                            intValueParameterID = Action.ChooseParameterGUI(intCondition.ToString() + ":", parameters, intValueParameterID, ParameterType.Integer);
                            if (intValueParameterID < 0)
                            {
                                intValue = EditorGUILayout.IntField(intCondition.ToString() + ":", intValue);

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

                    SetPlayerGUI();
                }
                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);
            }
        }
Exemple #18
0
        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)
            {
                // 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);
            }
        }
Exemple #19
0
        public void OnAwake()
        {
            ClearVariables();

            // Test for key imports
            References references = (References)Resources.Load(Resource.references);

            if (references)
            {
                SceneManager     sceneManager     = AdvGame.GetReferences().sceneManager;
                SettingsManager  settingsManager  = AdvGame.GetReferences().settingsManager;
                ActionsManager   actionsManager   = AdvGame.GetReferences().actionsManager;
                InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager;
                VariablesManager variablesManager = AdvGame.GetReferences().variablesManager;
                SpeechManager    speechManager    = AdvGame.GetReferences().speechManager;
                CursorManager    cursorManager    = AdvGame.GetReferences().cursorManager;
                MenuManager      menuManager      = AdvGame.GetReferences().menuManager;

                if (sceneManager == null)
                {
                    ACDebug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard");
                }

                if (settingsManager == null)
                {
                    ACDebug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard");
                }
                else
                {
                    if (settingsManager.IsInLoadingScene())
                    {
                        ACDebug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene.");
                        SetPersistentEngine();
                        return;
                    }

                    // Unity 5.3 has a bug whereby a modified Player prefab is placed in the scene when editing, but not visible
                    // This causes the Player to not load properly, so try to detect this remnant and delete it!
                    GameObject existingPlayer = GameObject.FindGameObjectWithTag(Tags.player);
                    if (existingPlayer != null)
                    {
                        if (settingsManager.GetDefaultPlayer() != null && existingPlayer.name == (settingsManager.GetDefaultPlayer().name + "(Clone)"))
                        {
                            DestroyImmediate(GameObject.FindGameObjectWithTag(Tags.player));
                            ACDebug.LogWarning("Player clone found in scene - this may have been hidden by a Unity bug, and has been destroyed.");
                        }
                    }

                    if (!GameObject.FindGameObjectWithTag(Tags.player))
                    {
                        KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity);
                    }
                    else
                    {
                        KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>();

                        if (sceneChanger == null || sceneChanger.GetPlayerOnTransition() == null)
                        {
                            // New local player
                            if (KickStarter.playerPrefab != null)
                            {
                                KickStarter.playerPrefab.Initialise();
                            }
                        }

                        AssignLocalPlayer();
                    }
                }

                if (actionsManager == null)
                {
                    ACDebug.LogError("No Actions Manager found - please set one using the main Adventure Creator window");
                }

                if (inventoryManager == null)
                {
                    ACDebug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window");
                }

                if (variablesManager == null)
                {
                    ACDebug.LogError("No Variables Manager found - please set one using the main Adventure Creator window");
                }

                if (speechManager == null)
                {
                    ACDebug.LogError("No Speech Manager found - please set one using the main Adventure Creator window");
                }

                if (cursorManager == null)
                {
                    ACDebug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window");
                }

                if (menuManager == null)
                {
                    ACDebug.LogError("No Menu Manager found - please set one using the main Adventure Creator window");
                }

                if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None)
                {
                    ACDebug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder");
                }
            }
            else
            {
                ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window");
            }

            SetPersistentEngine();

            if (persistentEnginePrefab == null)
            {
                ACDebug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine");
            }
            else
            {
                if (persistentEnginePrefab.GetComponent <Options>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no Options component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached.");
                }
                if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached.");
                }
                if (persistentEnginePrefab.GetComponent <StateHandler>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached.");
                }
                if (persistentEnginePrefab.GetComponent <SceneChanger>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached.");
                }
                if (persistentEnginePrefab.GetComponent <SaveSystem>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached.");
                }
                if (persistentEnginePrefab.GetComponent <LevelStorage>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeLanguages>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeLanguages component attached.");
                }
                if (persistentEnginePrefab.GetComponent <ActionListAssetManager>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no ActionListAssetManager component attached.");
                }
            }

            if (GameObject.FindWithTag(Tags.mainCamera) == null)
            {
                ACDebug.LogWarning("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one.");
            }
            else
            {
                if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null &&
                    GameObject.FindWithTag(Tags.mainCamera).GetComponentInParent <MainCamera>() == null)
                {
                    ACDebug.LogError("MainCamera has no MainCamera component.");
                }
            }

            if (this.GetComponent <MenuSystem>() == null)
            {
                ACDebug.LogError(this.name + " has no MenuSystem component attached.");
            }
            if (this.GetComponent <Dialog>() == null)
            {
                ACDebug.LogError(this.name + " has no Dialog component attached.");
            }
            if (this.GetComponent <PlayerInput>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerInput component attached.");
            }
            if (this.GetComponent <PlayerInteraction>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerInteraction component attached.");
            }
            if (this.GetComponent <PlayerMovement>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerMovement component attached.");
            }
            if (this.GetComponent <PlayerCursor>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerCursor component attached.");
            }
            if (this.GetComponent <PlayerQTE>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerQTE component attached.");
            }
            if (this.GetComponent <SceneSettings>() == null)
            {
                ACDebug.LogError(this.name + " has no SceneSettings component attached.");
            }
            else
            {
                if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null)
                {
                    // No NavMesh, are there Characters in the scene?
                    AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[];
                    if (allChars.Length > 0)
                    {
                        ACDebug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager.");
                    }
                }

                if (this.GetComponent <SceneSettings>().defaultPlayerStart == null)
                {
                    if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.GetDefaultPlayer() != null)
                    {
                        ACDebug.LogWarning("No default PlayerStart set.  The game may not be able to begin if one is not defined - please choose one using the Scene Manager.");
                    }
                }
            }
            if (this.GetComponent <NavigationManager>() == null)
            {
                ACDebug.LogError(this.name + " has no NavigationManager component attached.");
            }
            if (this.GetComponent <ActionListManager>() == null)
            {
                ACDebug.LogError(this.name + " has no ActionListManager component attached.");
            }
            if (this.GetComponent <EventManager>() == null)
            {
                ACDebug.LogError(this.name + " has no EventManager component attached.");
            }
        }
Exemple #20
0
        /**
         * <summary>Removes the current Player from the scene, and re-instantiates the correct Player prefab.</summary>
         * <param name = "ref_player">The new Player prefab to instantiate</param>
         * <param name = "ID">The ID number to assign the new Player</param>
         * <param name = "resetReferences">If True, then any references to the Player prefab in other AC scripts will be updated</param>
         * <param name = "_rotation">The new Player's rotation</param>
         * <param name = "keepInventory">If True, then the inventory items of the previous player (if there is one) will be transferred onto the new one, replacing any items held by the new one.</param>
         */
        public static void ResetPlayer(Player ref_player, int ID, bool resetReferences, Quaternion _rotation, bool keepInventory = false)
        {
            // Delete current player(s)
            if (GameObject.FindGameObjectsWithTag(Tags.player) != null)
            {
                foreach (GameObject playerOb in GameObject.FindGameObjectsWithTag(Tags.player))
                {
                    if (playerOb != null)
                    {
                        if (playerOb.GetComponent <Player>())
                        {
                            playerOb.GetComponent <Player>().ReleaseHeldObjects();
                        }
                        DestroyImmediate(playerOb);
                    }
                }
            }

            // Load new player
            if (ref_player)
            {
                SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

                Player newPlayer = (Player)Instantiate(ref_player, Vector3.zero, _rotation);
                newPlayer.ID   = ID;
                newPlayer.name = ref_player.name;
                playerPrefab   = newPlayer;
                DontDestroyOnLoad(newPlayer);

                if (KickStarter.runtimeInventory)
                {
                    KickStarter.runtimeInventory.SetNull();
                    KickStarter.runtimeInventory.RemoveRecipes();

                    // Clear inventory
                    if (settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory)
                    {
                        if (!keepInventory)
                        {
                            KickStarter.runtimeInventory.localItems.Clear();
                        }
                    }

                    if (KickStarter.saveSystem != null && KickStarter.saveSystem.DoesPlayerDataExist(ID, false))
                    {
                        bool loadNewInventory = !settingsManager.shareInventory;
                        if (settingsManager.playerSwitching == PlayerSwitching.DoNotAllow || (!settingsManager.shareInventory && keepInventory))
                        {
                            loadNewInventory = false;
                        }
                        saveSystem.AssignPlayerData(ID, loadNewInventory);
                    }

                    // Menus
                    foreach (AC.Menu menu in PlayerMenus.GetMenus())
                    {
                        foreach (MenuElement element in menu.elements)
                        {
                            if (element is MenuInventoryBox)
                            {
                                MenuInventoryBox invBox = (MenuInventoryBox)element;
                                invBox.ResetOffset();
                            }
                        }
                    }
                }

                newPlayer.Initialise();
                KickStarter.eventManager.Call_OnSetPlayer(newPlayer);
            }

            // Reset player references
            if (resetReferences)
            {
                KickStarter.playerMovement.AssignFPCamera();
                KickStarter.stateHandler.IgnoreNavMeshCollisions();
                KickStarter.stateHandler.GatherObjects(false);
                KickStarter.stateHandler.UpdateAllMaxVolumes();
                _Camera[] cameras = FindObjectsOfType(typeof(_Camera)) as _Camera[];
                foreach (_Camera camera in cameras)
                {
                    camera.ResetTarget();
                }
            }
        }
Exemple #21
0
        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 != 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;
                        }
                        if (_item.id == invIDReplace)
                        {
                            replaceInvNumber = i;
                        }

                        i++;
                    }

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

                    if (invAction == InvAction.Replace && replaceInvNumber == -1)
                    {
                        if (invIDReplace != 0)
                        {
                            LogWarning("Previously chosen item no longer exists!");
                        }
                        replaceInvNumber = 0;
                        invIDReplace     = 0;
                    }

                    invAction = (InvAction)EditorGUILayout.EnumPopup("Method:", invAction);

                    string label = "Item to add:";
                    if (invAction == InvAction.Remove)
                    {
                        label = "Item to remove:";

                        removeLast = EditorGUILayout.Toggle("Remove last-selected?", removeLast);
                        if (removeLast)
                        {
                            setAmount = false;
                            AfterRunningOption();
                            return;
                        }
                    }

                    parameterID = Action.ChooseParameterGUI(label, parameters, parameterID, ParameterType.InventoryItem);
                    if (parameterID >= 0)
                    {
                        invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                        invID     = -1;
                    }
                    else
                    {
                        invNumber = EditorGUILayout.Popup(label, invNumber, labelList.ToArray());
                        invID     = inventoryManager.items[invNumber].id;
                    }

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

                        if (setAmount)
                        {
                            string _label = (invAction == InvAction.Remove) ? "Reduce count by:" : "Increase count by:";

                            amountParameterID = Action.ChooseParameterGUI(_label, parameters, amountParameterID, ParameterType.Integer);
                            if (amountParameterID < 0)
                            {
                                amount = EditorGUILayout.IntField(_label, amount);
                            }
                        }
                    }

                    if (invAction == InvAction.Replace)
                    {
                        replaceParameterID = Action.ChooseParameterGUI("Item to remove:", parameters, replaceParameterID, ParameterType.InventoryItem);
                        if (replaceParameterID >= 0)
                        {
                            replaceInvNumber = Mathf.Min(replaceInvNumber, inventoryManager.items.Count - 1);
                            invIDReplace     = -1;
                        }
                        else
                        {
                            replaceInvNumber = EditorGUILayout.Popup("Item to remove:", replaceInvNumber, labelList.ToArray());
                            invIDReplace     = inventoryManager.items[replaceInvNumber].id;
                        }
                    }
                    else if (invAction == InvAction.Add)
                    {
                        addToFront = EditorGUILayout.Toggle("Add to front?", addToFront);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                    invID            = -1;
                    invNumber        = -1;
                    invIDReplace     = -1;
                    replaceInvNumber = -1;
                }

                if (settingsManager != null && settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory && invAction != InvAction.Replace)
                {
                    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();
        }
 private void OnEnable()
 {
     _target = (DetectHotspots) target;
     settingsManager = AdvGame.GetReferences ().settingsManager;
 }
Exemple #23
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            settingsManager = AdvGame.GetReferences().settingsManager;

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSettings = CustomGUILayout.ToggleHeader(showSettings, "Global cursor settings");
            if (showSettings)
            {
                cursorRendering = (CursorRendering)CustomGUILayout.EnumPopup("Cursor rendering:", cursorRendering, "AC.KickStarter.cursorManager.cursorRendering", "The rendering method of all cursors");
                if (cursorRendering == CursorRendering.Software)
                {
                    lockSystemCursor = CustomGUILayout.ToggleLeft("Lock system cursor when locking AC cursor?", lockSystemCursor, "AC.KickStarter.cursorManager.lockSystemCursor", "If True, the system cursor will be locked when the AC cursor is");
                }
                forceCursorInEditor = CustomGUILayout.ToggleLeft("Always show system cursor in Editor?", forceCursorInEditor, "AC.KickStarter.cursorManager.forceCursorInEditor");

                if (cursorRendering == CursorRendering.Software)
                {
                    keepCursorWithinScreen = CustomGUILayout.ToggleLeft("Always keep cursor within screen boundary?", keepCursorWithinScreen, "AC.KickStarter.cursorManager.keepCursorWithinScreen", "If True, then the cursor will always be kept within the boundary of the game window");
                }
                else
                {
                    keepCursorWithinScreen = CustomGUILayout.ToggleLeft("Always keep perceived cursor within screen boundary?", keepCursorWithinScreen, "AC.KickStarter.cursorManager.keepCursorWithinScreen", "If True, then the cursor will always be kept within the boundary of the game window");
                }

                                #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
                confineSystemCursor = CustomGUILayout.ToggleLeft("Confine system cursor to game window?", confineSystemCursor, "AC.KickStarter.cursorManager.confineSystemCursor", "If True, then the system cursor will be confined to the game window");
                                #endif

                hideCursorWhenDraggingMoveables = CustomGUILayout.ToggleLeft("Hide cursor when manipulating Draggables?", hideCursorWhenDraggingMoveables, "AC.KickStarter.cursorManager.hideCursorWhenDraggingMoveables", "If True, the cursor will be hidden when manipulating Draggable objects");
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showMainCursor = CustomGUILayout.ToggleHeader(showMainCursor, "Main cursor settings");
            if (showMainCursor)
            {
                cursorDisplay = (CursorDisplay)CustomGUILayout.EnumPopup("Display cursor:", cursorDisplay, "AC.KickStarter.cursorManager.cursorDisplay", "The rule that defines when the main cursor is shown");
                if (cursorDisplay != CursorDisplay.Never)
                {
                    allowMainCursor = CustomGUILayout.Toggle("Replace mouse cursor?", allowMainCursor, "AC.KickStarter.cursorManager.allowMainCursor", "If True, then the system's default hardware cursor will replaced with a custom one");
                    if (allowMainCursor || (settingsManager && settingsManager.inputMethod == InputMethod.KeyboardOrController))
                    {
                        IconBaseGUI("", pointerIcon, "AC.KickStarter.cursorManager.pointerIcon", "The game's default cursor", false);
                    }
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showWalkCursor = CustomGUILayout.ToggleHeader(showWalkCursor, "Walk cursor");
            if (showWalkCursor)
            {
                if (allowMainCursor)
                {
                    allowWalkCursor = CustomGUILayout.Toggle("Provide walk cursor?", allowWalkCursor, "AC.KickStarter.cursorManager.allowWalkCursor", "If True, then a separate cursor will display when in 'walk mode'");
                    if (allowWalkCursor)
                    {
                        if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && allowIconInput)
                        {
                            EditorGUILayout.LabelField("Input button:", "Icon_Walk");
                        }
                        IconBaseGUI("", walkIcon, "AC.KickStarter.cursorManager.walkIcon", "The cursor when in 'walk mode'");
                        onlyWalkWhenOverNavMesh = CustomGUILayout.ToggleLeft("Only show 'Walk' Cursor when over NavMesh?", onlyWalkWhenOverNavMesh, "AC.KickStarter.cursorManager.onlyWalkWhenOverNavMesh", "If True, then the walk cursor will only show when the cursor is hovering over a NavMesh");
                    }
                }
                addWalkPrefix = CustomGUILayout.Toggle("Prefix cursor labels?", addWalkPrefix, "AC.KickStarter.cursorManager.addWalkPrefix", "If True, then a prefix can be added to the Hotspot label when in 'walk mode'");
                if (addWalkPrefix)
                {
                    walkPrefix.label = CustomGUILayout.TextField("Walk prefix:", walkPrefix.label, "AC.KickStarter.cursorManager.walkPrefix");
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showHotspotCursor = CustomGUILayout.ToggleHeader(showHotspotCursor, "Hotspot cursor");
            if (showHotspotCursor)
            {
                addHotspotPrefix = CustomGUILayout.Toggle("Prefix cursor labels?", addHotspotPrefix, "AC.KickStarter.cursorManager.addHotspotPrefix", "If True, then the Cursor's interaction verb will prefix the Hotspot label when hovering over Hotspots");
                IconBaseGUI("", mouseOverIcon, "AC.KickStarter.cursorManager.mouseOverIcon");
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showInventoryCursor = CustomGUILayout.ToggleHeader(showInventoryCursor, "Inventory cursor");
            if (showInventoryCursor)
            {
                inventoryHandling = (InventoryHandling)CustomGUILayout.EnumPopup("When inventory selected:", inventoryHandling, "AC.KickStarter.cursorManager.inventoryHandling", "What happens to the cursor when an inventory item is selected");
                if (inventoryHandling != InventoryHandling.ChangeCursor)
                {
                    onlyShowInventoryLabelOverHotspots = CustomGUILayout.ToggleLeft("Only show label when over Hotspots and Inventory?", onlyShowInventoryLabelOverHotspots, "AC.KickStarter.cursorManager.onlyShowInventoryLabelOverHotspots", "If True, then Hotspot labels will not show when an inventory item is selected unless the cursor is over another inventory item or a Hotspot");
                }
                if (inventoryHandling != InventoryHandling.ChangeHotspotLabel)
                {
                    inventoryCursorSize = CustomGUILayout.FloatField("Inventory cursor size:", inventoryCursorSize, "AC.KickStarter.cursorManager.inventoryCursorSize", "The size of selected inventory item graphics when used as a cursor");
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Use syntax:", GUILayout.Width(100f));
                hotspotPrefix1.label = CustomGUILayout.TextField(hotspotPrefix1.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix1");
                EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f));
                hotspotPrefix2.label = CustomGUILayout.TextField(hotspotPrefix2.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix2");
                EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f));
                EditorGUILayout.EndHorizontal();
                if (AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.CanGiveItems())
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Give syntax:", GUILayout.Width(100f));
                    hotspotPrefix3.label = CustomGUILayout.TextField(hotspotPrefix3.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix3");
                    EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f));
                    hotspotPrefix4.label = CustomGUILayout.TextField(hotspotPrefix4.label, GUILayout.MaxWidth(80f), "AC.KickStarter.cursorManager.hotspotPrefix4");
                    EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f));
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showInteractionIcons = CustomGUILayout.ToggleHeader(showInteractionIcons, "Interaction icons");
            if (showInteractionIcons)
            {
                if (settingsManager == null || settingsManager.interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    allowInteractionCursor = CustomGUILayout.ToggleLeft("Change cursor based on Interaction?", allowInteractionCursor, "AC.KickStarter.cursorManager.allowInteractionCursor", "If True, then the cursor will be controlled by the current Interaction when hovering over a Hotspot");
                    if (allowInteractionCursor && (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                    {
                        allowInteractionCursorForInventory = CustomGUILayout.ToggleLeft("Change when over Inventory items too?", allowInteractionCursorForInventory, "AC.KickStarter.cursorManager.allowInteractionCursorForInventory", "If True, then the cursor will be controlled by the current Interaction when hovering over an inventory item (see InvItem)");
                    }
                    if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                    {
                        cycleCursors            = CustomGUILayout.ToggleLeft("Cycle Interactions with right-click?", cycleCursors, "AC.KickStarter.cursorManager.cycleCursors", "If True, then cursor modes can by clicked by right-clicking");
                        allowIconInput          = CustomGUILayout.ToggleLeft("Set Interaction with specific inputs?", allowIconInput, "AC.KickStarter.cursorManager.allowIconInput", "then the player can switch the active icon by invoking a specific input");
                        onlyAnimateOverHotspots = CustomGUILayout.ToggleLeft("Only animate icons when over Hotspots?", onlyAnimateOverHotspots, "AC.KickStarter.cursorManager.onlyAnimateOverHotspots", "If True, then animated cursors will only animate if the cursor is over a Hotspot");
                    }
                }

                IconsGUI();

                EditorGUILayout.Space();

                if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                {
                    LookIconGUI();
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showCutsceneCursor = CustomGUILayout.ToggleHeader(showCutsceneCursor, "Cutscene cursor");
            if (showCutsceneCursor)
            {
                IconBaseGUI("", waitIcon, "AC.KickStarter.cursorManager.waitIcon", "The cursor while the game is running a gameplay-blocking cutscene");
            }
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);
            }
        }
Exemple #24
0
        private void Finish()
        {
            if (!references)
            {
                GetReferences();
            }

            if (!references)
            {
                return;
            }

            string managerPath = gameName + "/Managers";

            try
            {
                System.IO.Directory.CreateDirectory(Application.dataPath + "/" + managerPath);
            }
            catch (System.Exception e)
            {
                ACDebug.LogError("Wizard aborted - Could not create directory: " + Application.dataPath + "/" + managerPath + ". Please make sure the Assets direcrory is writeable, and that the intended game name contains no special characters.");
                Debug.LogException(e, this);
                pageNumber--;
                return;
            }

            try
            {
                ShowProgress(0f);

                SceneManager newSceneManager = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
                references.sceneManager = newSceneManager;

                ShowProgress(0.1f);

                SettingsManager newSettingsManager = CustomAssetUtility.CreateAsset <SettingsManager> ("SettingsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager");

                newSettingsManager.saveFileName            = gameName;
                newSettingsManager.separateEditorSaveFiles = true;
                newSettingsManager.cameraPerspective       = cameraPerspective;
                newSettingsManager.movingTurning           = movingTurning;
                newSettingsManager.movementMethod          = movementMethod;
                newSettingsManager.inputMethod             = inputMethod;
                newSettingsManager.interactionMethod       = interactionMethod;
                newSettingsManager.hotspotDetection        = hotspotDetection;
                if (cameraPerspective == CameraPerspective.TwoPointFiveD)
                {
                    newSettingsManager.forceAspectRatio = true;
                }
                references.settingsManager = newSettingsManager;

                ShowProgress(0.2f);

                ActionsManager newActionsManager = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
                ActionsManager defaultActionsManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager;
                if (defaultActionsManager != null)
                {
                    newActionsManager.defaultClass     = defaultActionsManager.defaultClass;
                    newActionsManager.defaultClassName = defaultActionsManager.defaultClassName;
                }
                references.actionsManager = newActionsManager;
                AdventureCreator.RefreshActions();

                ShowProgress(0.3f);

                VariablesManager newVariablesManager = CustomAssetUtility.CreateAsset <VariablesManager> ("VariablesManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager");
                references.variablesManager = newVariablesManager;

                ShowProgress(0.4f);

                InventoryManager newInventoryManager = CustomAssetUtility.CreateAsset <InventoryManager> ("InventoryManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager");
                references.inventoryManager = newInventoryManager;

                ShowProgress(0.5f);

                SpeechManager newSpeechManager = CustomAssetUtility.CreateAsset <SpeechManager> ("SpeechManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager");
                newSpeechManager.ClearLanguages();
                references.speechManager = newSpeechManager;

                ShowProgress(0.6f);

                CursorManager newCursorManager = CustomAssetUtility.CreateAsset <CursorManager> ("CursorManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager");
                references.cursorManager = newCursorManager;

                ShowProgress(0.7f);

                MenuManager newMenuManager = CustomAssetUtility.CreateAsset <MenuManager> ("MenuManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager");
                references.menuManager = (MenuManager)newMenuManager;

                CursorManager defaultCursorManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_CursorManager.asset", typeof(CursorManager)) as CursorManager;
                if (wizardMenu == WizardMenu.Blank)
                {
                    if (defaultCursorManager != null)
                    {
                        CursorIcon useIcon = new CursorIcon();
                        useIcon.Copy(defaultCursorManager.cursorIcons[0], false);
                        newCursorManager.cursorIcons.Add(useIcon);
                        EditorUtility.SetDirty(newCursorManager);
                    }
                }
                else
                {
                    if (defaultCursorManager != null)
                    {
                        foreach (CursorIcon defaultIcon in defaultCursorManager.cursorIcons)
                        {
                            CursorIcon newIcon = new CursorIcon();
                            newIcon.Copy(defaultIcon, false);
                            newCursorManager.cursorIcons.Add(newIcon);
                        }

                        CursorIconBase pointerIcon = new CursorIconBase();
                        pointerIcon.Copy(defaultCursorManager.pointerIcon);
                        newCursorManager.pointerIcon = pointerIcon;

                        newCursorManager.lookCursor_ID = defaultCursorManager.lookCursor_ID;
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_CursorManager asset to copy from!");
                    }

                    newCursorManager.allowMainCursor = true;
                    EditorUtility.SetDirty(newCursorManager);

                    MenuManager defaultMenuManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_MenuManager.asset", typeof(MenuManager)) as MenuManager;
                    if (defaultMenuManager != null)
                    {
                                                #if UNITY_EDITOR
                        newMenuManager.drawOutlines = defaultMenuManager.drawOutlines;
                        newMenuManager.drawInEditor = defaultMenuManager.drawInEditor;
                                                #endif
                        newMenuManager.pauseTexture = defaultMenuManager.pauseTexture;

                        if (wizardMenu != WizardMenu.Blank)
                        {
                            System.IO.Directory.CreateDirectory(Application.dataPath + "/" + gameName + "/UI");
                        }

                        foreach (Menu defaultMenu in defaultMenuManager.menus)
                        {
                            float progress = (float)defaultMenuManager.menus.IndexOf(defaultMenu) / (float)defaultMenuManager.menus.Count;
                            ShowProgress((progress * 0.3f) + 0.7f);

                            Menu newMenu = ScriptableObject.CreateInstance <Menu>();
                            newMenu.Copy(defaultMenu, true, true);
                            newMenu.Recalculate();

                            if (wizardMenu == WizardMenu.DefaultAC)
                            {
                                newMenu.menuSource = MenuSource.AdventureCreator;
                            }
                            else if (wizardMenu == WizardMenu.DefaultUnityUI)
                            {
                                newMenu.menuSource = MenuSource.UnityUiPrefab;
                            }

                            if (newMenu.pauseWhenEnabled)
                            {
                                bool autoSelectUI = (inputMethod == InputMethod.KeyboardOrController);
                                newMenu.autoSelectFirstVisibleElement = autoSelectUI;
                            }

                            if (defaultMenu.PrefabCanvas)
                            {
                                string oldPath = AssetDatabase.GetAssetPath(defaultMenu.PrefabCanvas.gameObject);
                                string newPath = "Assets/" + gameName + "/UI/" + defaultMenu.PrefabCanvas.name + ".prefab";

                                if (AssetDatabase.CopyAsset(oldPath, newPath))
                                {
                                    AssetDatabase.ImportAsset(newPath);
                                    GameObject canvasObNewPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(newPath, typeof(GameObject));
                                    newMenu.PrefabCanvas = canvasObNewPrefab.GetComponent <Canvas>();
                                }
                                else
                                {
                                    newMenu.PrefabCanvas = null;
                                    ACDebug.LogWarning("Could not copy asset " + oldPath + " to " + newPath, defaultMenu.PrefabCanvas.gameObject);
                                }
                                newMenu.rectTransform = null;
                            }

                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                if (newElement != null)
                                {
                                    AssetDatabase.AddObjectToAsset(newElement, newMenuManager);
                                    newElement.hideFlags = HideFlags.HideInHierarchy;
                                }
                                else
                                {
                                    ACDebug.LogWarning("Null element found in " + newMenu.title + " - the interface may not be set up correctly.");
                                }
                            }

                            if (newMenu != null)
                            {
                                AssetDatabase.AddObjectToAsset(newMenu, newMenuManager);
                                newMenu.hideFlags = HideFlags.HideInHierarchy;

                                newMenuManager.menus.Add(newMenu);
                            }
                            else
                            {
                                ACDebug.LogWarning("Unable to create new Menu from original '" + defaultMenu.title + "'");
                            }
                        }

                        EditorUtility.SetDirty(newMenuManager);

                        if (newSpeechManager != null)
                        {
                            newSpeechManager.previewMenuName = "Subtitles";
                            EditorUtility.SetDirty(newSpeechManager);
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_MenuManager asset to copy from!");
                    }
                }

                EditorUtility.ClearProgressBar();
                ManagerPackage newManagerPackage = CreateManagerPackage(gameName, newSceneManager, newSettingsManager, newActionsManager, newVariablesManager, newInventoryManager, newSpeechManager, newCursorManager, newMenuManager);

                AssetDatabase.SaveAssets();

                if (newManagerPackage == null || !newManagerPackage.IsFullyAssigned())
                {
                    EditorUtility.DisplayDialog("Wizard failed", "The New Game Wizard failed to generate a new 'Manager Package' file with all eight Managers assigned. Check your '/Assets/" + gameName + "/Managers' directory - the Managers may have been created, and just need assigning in the ManagerPackage asset Inspector, found in '/Assets/" + gameName + "'.", "OK");
                }
                else if (GameObject.FindObjectOfType <KickStarter>() == null)
                {
                    bool initScene = EditorUtility.DisplayDialog("Organise scene?", "Process complete.  Would you like to organise the scene objects to begin working?  This can be done at any time within the Scene Manager.", "Yes", "No");
                    if (initScene)
                    {
                        newSceneManager.InitialiseObjects();
                    }
                }
            }
            catch (System.Exception e)
            {
                ACDebug.LogWarning("Could not create Manager. Does the subdirectory " + managerPath + " exist?");
                Debug.LogException(e, this);
                pageNumber--;
            }
        }
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            if (!sideIcon)
            {
                sideIcon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D));
            }

            if (AdvGame.GetReferences ())
            {
                if (AdvGame.GetReferences ().settingsManager)
                {
                    settingsManager = AdvGame.GetReferences ().settingsManager;
                }
                if (AdvGame.GetReferences ().cursorManager)
                {
                    cursorManager = AdvGame.GetReferences ().cursorManager;
                }
            }

            EditorGUILayout.Space ();
            GUILayout.BeginHorizontal ();
            if (GUILayout.Toggle (showItems, "Items", "toolbarbutton"))
            {
                SetTab (0);
            }
            if (GUILayout.Toggle (showBins, "Categories", "toolbarbutton"))
            {
                SetTab (1);
            }
            if (GUILayout.Toggle (showCrafting, "Crafting", "toolbarbutton"))
            {
                SetTab (2);
            }
            GUILayout.EndHorizontal ();
            EditorGUILayout.Space ();

            if (showBins)
            {
                BinsGUI ();
            }
            else if (showCrafting)
            {
                CraftingGUI ();
            }
            else if (showItems)
            {
                ItemsGUI ();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty (this);
            }
        }
Exemple #26
0
        private ManagerPackage CreateManagerPackage(string folder, SceneManager sceneManager, SettingsManager settingsManager, ActionsManager actionsManager, VariablesManager variablesManager, InventoryManager inventoryManager, SpeechManager speechManager, CursorManager cursorManager, MenuManager menuManager)
        {
            ManagerPackage managerPackage = CustomAssetUtility.CreateAsset <ManagerPackage> ("ManagerPackage", folder);

            AssetDatabase.RenameAsset("Assets/" + folder + "/ManagerPackage.asset", folder + "_ManagerPackage");

            managerPackage.sceneManager     = sceneManager;
            managerPackage.settingsManager  = settingsManager;
            managerPackage.actionsManager   = actionsManager;
            managerPackage.variablesManager = variablesManager;

            managerPackage.inventoryManager = inventoryManager;
            managerPackage.speechManager    = speechManager;
            managerPackage.cursorManager    = cursorManager;
            managerPackage.menuManager      = menuManager;

            managerPackage.AssignManagers();
            EditorUtility.SetDirty(managerPackage);
            AssetDatabase.SaveAssets();

            AdventureCreator.Init();

            return(managerPackage);
        }
Exemple #27
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);
            }
        }
Exemple #28
0
        override public void ShowGUI()
        {
            if (!settingsManager)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            if (!settingsManager)
            {
                return;
            }

            if (settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
            {
                EditorGUILayout.HelpBox("This Action requires Player Switching to be allowed, as set in the Settings Manager.", MessageType.Info);
                return;
            }

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

            int i = 0;

            playerNumber = -1;

            if (settingsManager.players.Count > 0)
            {
                foreach (PlayerPrefab playerPrefab in settingsManager.players)
                {
                    if (playerPrefab.playerOb != null)
                    {
                        labelList.Add(playerPrefab.playerOb.name);
                    }
                    else
                    {
                        labelList.Add("(Undefined prefab)");
                    }

                    // If a player has been removed, make sure selected player is still valid
                    if (playerPrefab.ID == playerID)
                    {
                        playerNumber = i;
                    }

                    i++;
                }

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

                    playerNumber = 0;
                    playerID     = 0;
                }

                playerNumber = EditorGUILayout.Popup("Current Player is:", playerNumber, labelList.ToArray());
                playerID     = settingsManager.players[playerNumber].ID;
            }

            else
            {
                EditorGUILayout.LabelField("No players exist!");
                playerID     = -1;
                playerNumber = -1;
            }
        }
		private void OnDestroy ()
		{
			firstPersonCamera = null;
			playerInput = null;
			settingsManager = null;
			sceneSettings = null;
			playerMenus = null;
			navigationManager = null;
		}
		public void SetCorrectRotation ()
		{
			if (settingsManager == null)
			{
				settingsManager = AdvGame.GetReferences ().settingsManager;
			}

			if (_camera == null)
			{
				_camera = GetComponent <Camera>();
			}

			if (settingsManager != null)
			{
				if (settingsManager.IsTopDown ())
				{
					transform.rotation = Quaternion.Euler (90f, 0, 0);
					return;
				}

				if (settingsManager.IsUnity2D ())
				{
					_camera.orthographic = true;
				}
			}

			transform.rotation = Quaternion.Euler (0, 0, 0);
		}
		private void OnDestroy ()
		{
			settingsManager = null;
		}
        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);
            }
        }
		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()
        {
            if (!settingsManager)
            {
                settingsManager = AdvGame.GetReferences ().settingsManager;
            }

            if (!settingsManager)
            {
                return;
            }

            if (settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
            {
                EditorGUILayout.HelpBox ("This Action requires Player Switching to be allowed, as set in the Settings Manager.", MessageType.Info);
                return;
            }

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

            int i = 0;
            playerNumber = -1;

            if (settingsManager.players.Count > 0)
            {
                foreach (PlayerPrefab playerPrefab in settingsManager.players)
                {
                    if (playerPrefab.playerOb != null)
                    {
                        labelList.Add (playerPrefab.playerOb.name);
                    }
                    else
                    {
                        labelList.Add ("(Undefined prefab)");
                    }

                    // If a player has been removed, make sure selected player is still valid
                    if (playerPrefab.ID == playerID)
                    {
                        playerNumber = i;
                    }

                    i++;
                }

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

                    playerNumber = 0;
                    playerID = 0;
                }

                playerNumber = EditorGUILayout.Popup ("Current Player is:", playerNumber, labelList.ToArray());
                playerID = settingsManager.players[playerNumber].ID;
            }

            else
            {
                EditorGUILayout.LabelField ("No players exist!");
                playerID = -1;
                playerNumber = -1;
            }
        }
		override public float Run ()
		{
			if (!settingsManager)
			{
				settingsManager = AdvGame.GetReferences ().settingsManager;
			}

			if (settingsManager && settingsManager.playerSwitching == PlayerSwitching.Allow)
			{
				if (settingsManager.players.Count > 0 && settingsManager.players.Count > playerNumber && playerNumber > -1)
				{
					if (KickStarter.player.ID == playerID)
					{
						Debug.Log ("Cannot switch player - already controlling the desired prefab.");
						return 0f;
					}

					if (settingsManager.players[playerNumber].playerOb != null)
					{
						SaveSystem saveSystem = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <SaveSystem>();
						saveSystem.SaveCurrentPlayerData ();

						Vector3 oldPlayerPosition = KickStarter.player.transform.position;
						Quaternion oldPlayerRotation = KickStarter.player.transform.rotation;
						Vector3 oldPlayerScale = KickStarter.player.transform.localScale;

						if (oldPlayer == OldPlayer.ReplaceWithNPC && oldPlayerNPC != null &&
						    (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.AppearAtMarker))
						{
							oldPlayerNPC.transform.position = oldPlayerPosition;
							oldPlayerNPC.transform.rotation = oldPlayerRotation;
							oldPlayerNPC.transform.localScale = oldPlayerScale;
						}

						Quaternion newRotation = Quaternion.identity;
						if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
						{
							newRotation = oldPlayerRotation;
						}
						else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC && newPlayerNPC)
						{
							newRotation = newPlayerNPC.transform.rotation;
						}
						else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker && newPlayerMarker)
						{
							newRotation = newPlayerMarker.transform.rotation;
						}

						KickStarter.ResetPlayer (settingsManager.players[playerNumber].playerOb, playerID, true, newRotation);
						Player newPlayer = KickStarter.player;

						int sceneToLoad = Application.loadedLevel;
						if (restorePreviousData && saveSystem.DoesPlayerDataExist (playerID, true))
						{
							sceneToLoad = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <SaveSystem>().GetPlayerScene (playerID);

							if (sceneToLoad != Application.loadedLevel)
							{
								saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
								GameObject.FindWithTag (Tags.persistentEngine).GetComponent <SceneChanger>().ChangeScene ("", sceneToLoad, true);
							}
						}
						else
						{
							if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
							{
								newPlayer.Teleport (oldPlayerPosition);
								newPlayer.SetRotation (oldPlayerRotation);
								newPlayer.transform.localScale = oldPlayerScale;
							}
							else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC)
							{
								if (newPlayerNPC)
								{
									newPlayer.Teleport (newPlayerNPC.transform.position);
									newPlayer.SetRotation (newPlayerNPC.transform.rotation);
									newPlayer.transform.localScale = newPlayerNPC.transform.localScale;

									newPlayerNPC.transform.position += new Vector3 (100f, -100f, 100f);
								}
							}
							else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
							{
								if (newPlayerMarker)
								{
									newPlayer.Teleport (newPlayerMarker.transform.position);
									newPlayer.SetRotation (newPlayerMarker.transform.rotation);
									newPlayer.transform.localScale = newPlayerMarker.transform.localScale;
								}
							}
							else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
							{
								if (chooseNewSceneBy == ChooseSceneBy.Name && newPlayerSceneName == Application.loadedLevelName)
								{}
								else if (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == Application.loadedLevel)
								{}
								else
								{
									GameObject.FindWithTag (Tags.persistentEngine).GetComponent <SceneChanger>().ChangeScene (AdvGame.GetSceneName (chooseNewSceneBy, newPlayerSceneName), newPlayerScene, true);
								}
							}
						}

						MainCamera mainCamera = KickStarter.mainCamera;
						if (mainCamera.attachedCamera)
						{
							mainCamera.attachedCamera.MoveCameraInstant ();
						}

						AssetLoader.UnloadAssets ();
					}
					else
					{
						Debug.LogWarning ("Cannot switch player - no player prefabs is defined.");
					}
				}
			}

			return 0f;
		}
Exemple #36
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Affect Player?", isPlayer);
            if (!isPlayer)
            {
                charToMoveParameterID = Action.ChooseParameterGUI("Character to turn:", parameters, charToMoveParameterID, ParameterType.GameObject);
                if (charToMoveParameterID >= 0)
                {
                    charToMoveID = 0;
                    charToMove   = null;
                }
                else
                {
                    charToMove = (Char)EditorGUILayout.ObjectField("Character to turn:", charToMove, typeof(Char), true);

                    charToMoveID = FieldToID <Char> (charToMove, charToMoveID);
                    charToMove   = IDToField <Char> (charToMove, charToMoveID, false);
                }
            }
            else
            {
                facePlayer = false;
            }

            faceType = (CharFaceType)EditorGUILayout.EnumPopup("Face with:", faceType);

            if (!isPlayer)
            {
                facePlayer = EditorGUILayout.Toggle("Face player?", facePlayer);
            }
            else
            {
                SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;
                if (faceType == CharFaceType.Body && settingsManager && settingsManager.IsInFirstPerson())
                {
                    lookUpDown = EditorGUILayout.Toggle("Affect head pitch?", lookUpDown);
                }
            }

            if (faceType == CharFaceType.Head)
            {
                stopLooking = EditorGUILayout.Toggle("Stop looking?", stopLooking);
            }

            if (facePlayer || (faceType == CharFaceType.Head && stopLooking))
            {
            }
            else
            {
                faceObjectParameterID = Action.ChooseParameterGUI("Object to face:", parameters, faceObjectParameterID, ParameterType.GameObject);
                if (faceObjectParameterID >= 0)
                {
                    faceObjectID = 0;
                    faceObject   = null;
                }
                else
                {
                    faceObject = (GameObject)EditorGUILayout.ObjectField("Object to face:", faceObject, typeof(GameObject), true);

                    faceObjectID = FieldToID(faceObject, faceObjectID);
                    faceObject   = IDToField(faceObject, faceObjectID, false);
                }
            }

            if (faceType == CharFaceType.Body)
            {
                copyRotation = EditorGUILayout.Toggle("Use object's rotation?", copyRotation);
            }
            else if (faceType == CharFaceType.Head && !stopLooking)
            {
                if (facePlayer || (faceObject != null && faceObject.GetComponent <Char>()))
                {
                    lookAtHead = EditorGUILayout.Toggle("Look at character's head?", lookAtHead);
                }
                else if (faceObjectParameterID >= 0)
                {
                    lookAtHead = EditorGUILayout.Toggle("If a character, look at head?", lookAtHead);
                }
            }

            isInstant = EditorGUILayout.Toggle("Is instant?", isInstant);
            if (!isInstant)
            {
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }
		public bool IsCorrectRotation ()
		{
			if (settingsManager == null)
			{
				settingsManager = AdvGame.GetReferences ().settingsManager;
			}

			if (settingsManager != null && settingsManager.IsTopDown ())
			{
				if (transform.rotation == Quaternion.Euler (90f, 0, 0))
				{
					return true;
				}

				return false;
			}

			if (transform.rotation == Quaternion.Euler (0, 0, 0))
			{
				return true;
			}

			return false;
		}
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            settingsManager = AdvGame.GetReferences().settingsManager;

            cursorRendering = (CursorRendering) EditorGUILayout.EnumPopup ("Cursor rendering:", cursorRendering);
            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
            EditorGUILayout.LabelField ("Main cursor", EditorStyles.boldLabel);
            cursorDisplay = (CursorDisplay) EditorGUILayout.EnumPopup ("Display cursor:", cursorDisplay);
            if (cursorDisplay != CursorDisplay.Never)
            {
                allowMainCursor = EditorGUILayout.Toggle ("Replace mouse cursor?", allowMainCursor);
                if (allowMainCursor || (settingsManager && settingsManager.inputMethod == InputMethod.KeyboardOrController))
                {
                    IconBaseGUI ("Main cursor:", pointerIcon);
                }
            }
            EditorGUILayout.EndVertical ();

            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
            EditorGUILayout.LabelField ("Walk settings", EditorStyles.boldLabel);
            if (allowMainCursor)
            {
                allowWalkCursor = EditorGUILayout.Toggle ("Provide walk cursor?", allowWalkCursor);
                if (allowWalkCursor)
                {
                    if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                    {
                        EditorGUILayout.LabelField ("Input button:", "Icon_Walk");
                    }
                    IconBaseGUI ("Walk cursor:", walkIcon);
                    onlyWalkWhenOverNavMesh = EditorGUILayout.ToggleLeft ("Only show 'Walk' Cursor when over NavMesh?", onlyWalkWhenOverNavMesh);
                }
            }
            addWalkPrefix = EditorGUILayout.Toggle ("Prefix cursor labels?", addWalkPrefix);
            if (addWalkPrefix)
            {
                walkPrefix.label = EditorGUILayout.TextField ("Walk prefix:", walkPrefix.label);
            }
            EditorGUILayout.EndVertical ();

            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
                EditorGUILayout.LabelField ("Hotspot settings", EditorStyles.boldLabel);
                addHotspotPrefix = EditorGUILayout.Toggle ("Prefix cursor labels?", addHotspotPrefix);
                IconBaseGUI ("Mouse-over cursor:", mouseOverIcon);
            EditorGUILayout.EndVertical ();

            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
                EditorGUILayout.LabelField ("Inventory cursor", EditorStyles.boldLabel);
                inventoryHandling = (InventoryHandling) EditorGUILayout.EnumPopup ("When inventory selected:", inventoryHandling);
                if (inventoryHandling != InventoryHandling.ChangeCursor)
                {
                    onlyShowInventoryLabelOverHotspots = EditorGUILayout.ToggleLeft ("Only show label when over Hotspots and Inventory?", onlyShowInventoryLabelOverHotspots);
                }
                if (inventoryHandling != InventoryHandling.ChangeHotspotLabel)
                {
                    inventoryCursorSize = EditorGUILayout.FloatField ("Inventory cursor size:", inventoryCursorSize);
                }
                EditorGUILayout.BeginHorizontal ();
                    EditorGUILayout.LabelField ("Use syntax:", GUILayout.Width (100f));
                    hotspotPrefix1.label = EditorGUILayout.TextField (hotspotPrefix1.label, GUILayout.MaxWidth (80f));
                    EditorGUILayout.LabelField ("(item)", GUILayout.MaxWidth (40f));
                    hotspotPrefix2.label = EditorGUILayout.TextField (hotspotPrefix2.label, GUILayout.MaxWidth (80f));
                    EditorGUILayout.LabelField ("(hotspot)", GUILayout.MaxWidth (55f));
                EditorGUILayout.EndHorizontal ();
                if (AdvGame.GetReferences ().settingsManager && AdvGame.GetReferences ().settingsManager.CanGiveItems ())
                {
                    EditorGUILayout.BeginHorizontal ();
                        EditorGUILayout.LabelField ("Give syntax:", GUILayout.Width (100f));
                        hotspotPrefix3.label = EditorGUILayout.TextField (hotspotPrefix3.label, GUILayout.MaxWidth (80f));
                        EditorGUILayout.LabelField ("(item)", GUILayout.MaxWidth (40f));
                        hotspotPrefix4.label = EditorGUILayout.TextField (hotspotPrefix4.label, GUILayout.MaxWidth (80f));
                        EditorGUILayout.LabelField ("(hotspot)", GUILayout.MaxWidth (55f));
                    EditorGUILayout.EndHorizontal ();
                }
            EditorGUILayout.EndVertical ();

            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
                EditorGUILayout.LabelField ("Interaction icons", EditorStyles.boldLabel);

                if (settingsManager == null || settingsManager.interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    allowInteractionCursor = EditorGUILayout.ToggleLeft ("Change cursor based on Interaction?", allowInteractionCursor);
                    if (allowInteractionCursor && (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                    {
                        allowInteractionCursorForInventory = EditorGUILayout.ToggleLeft ("Change when over Inventory items too?", allowInteractionCursorForInventory);
                    }
                    if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                    {
                        cycleCursors = EditorGUILayout.ToggleLeft ("Cycle Interactions with right-click?", cycleCursors);
                    }
                }

                IconsGUI ();

                EditorGUILayout.Space ();

                if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                {
                    LookIconGUI ();
                }
            EditorGUILayout.EndVertical ();

            EditorGUILayout.Space ();

            EditorGUILayout.BeginVertical ("Button");
                IconBaseGUI ("Wait cursor", waitIcon);
            EditorGUILayout.EndVertical ();

            if (GUI.changed)
            {
                EditorUtility.SetDirty (this);
            }
        }
		protected override void Awake ()
		{
			originalPosition = new Vector2 (transform.position.x, transform.position.y);
			base.Awake ();
			settingsManager = AdvGame.GetReferences ().settingsManager;
		}
Exemple #40
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 void ShowGUI ()
		{
			if (!sideIcon)
			{
				sideIcon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D));
			}

			if (AdvGame.GetReferences ())
			{
				if (AdvGame.GetReferences ().settingsManager)
				{
					settingsManager = AdvGame.GetReferences ().settingsManager;
				}
				if (AdvGame.GetReferences ().cursorManager)
				{
					cursorManager = AdvGame.GetReferences ().cursorManager;
				}
			}

			BinsGUI ();

			if (settingsManager == null || settingsManager.interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction || (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && settingsManager.inventoryInteractions == InventoryInteractions.Single))
			{
				EditorGUILayout.Space ();
				EditorGUILayout.LabelField ("Unhandled events", EditorStyles.boldLabel);
				unhandledCombine = (ActionListAsset) EditorGUILayout.ObjectField ("Combine:", unhandledCombine, typeof (ActionListAsset), false);
				unhandledHotspot = (ActionListAsset) EditorGUILayout.ObjectField ("Use on hotspot:", unhandledHotspot, typeof (ActionListAsset), false);
			}

			List<string> binList = new List<string>();
			foreach (InvBin bin in bins)
			{
				binList.Add (bin.label);
			}
			
			EditorGUILayout.Space ();
			CreateItemsGUI ();
			EditorGUILayout.Space ();

			if (selectedItem != null && items.Contains (selectedItem))
			{
				EditorGUILayout.LabelField ("Inventory item '" + selectedItem.label + "' properties", EditorStyles.boldLabel);

				EditorGUILayout.BeginVertical("Button");
					selectedItem.label = EditorGUILayout.TextField ("Name:", selectedItem.label);
					selectedItem.altLabel = EditorGUILayout.TextField ("Label (if not name):", selectedItem.altLabel);

					EditorGUILayout.BeginHorizontal ();
						EditorGUILayout.LabelField ("Category:", GUILayout.Width (146f));
						if (bins.Count > 0)
						{
							binNumber = GetBinSlot (selectedItem.binID);
							binNumber = EditorGUILayout.Popup (binNumber, binList.ToArray());
							selectedItem.binID = bins[binNumber].id;
						}
						else
						{
							selectedItem.binID = -1;
							EditorGUILayout.LabelField ("No categories defined!", EditorStyles.miniLabel, GUILayout.Width (146f));
						}
					EditorGUILayout.EndHorizontal ();	

					selectedItem.tex = (Texture2D) EditorGUILayout.ObjectField ("Texture:", selectedItem.tex, typeof (Texture2D), false);

					if (settingsManager && (settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive || settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot || (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && settingsManager.inventoryInteractions == InventoryInteractions.Single)))
					{
						selectedItem.activeTex = (Texture2D) EditorGUILayout.ObjectField ("Active texture:", selectedItem.activeTex, typeof (Texture2D), false);
					}

					selectedItem.carryOnStart = EditorGUILayout.Toggle ("Carry on start?", selectedItem.carryOnStart);
					selectedItem.canCarryMultiple = EditorGUILayout.Toggle ("Can carry multiple?", selectedItem.canCarryMultiple);
					if (selectedItem.canCarryMultiple)
					{
						selectedItem.useSeparateSlots = EditorGUILayout.Toggle ("Place in separate slots?", selectedItem.useSeparateSlots);
					}
					if (selectedItem.carryOnStart && selectedItem.canCarryMultiple)
					{
						selectedItem.count = EditorGUILayout.IntField ("Quantity on start:", selectedItem.count);
					}
					else
					{
						selectedItem.count = 1;
					}

					EditorGUILayout.Space ();
					EditorGUILayout.LabelField ("Standard interactions", EditorStyles.boldLabel);
					if (settingsManager && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && settingsManager.inventoryInteractions == InventoryInteractions.Multiple && AdvGame.GetReferences ().cursorManager)
					{
						CursorManager cursorManager = AdvGame.GetReferences ().cursorManager;

						List<string> iconList = new List<string>();
						foreach (CursorIcon icon in cursorManager.cursorIcons)
						{
							iconList.Add (icon.label);
						}

						if (cursorManager.cursorIcons.Count > 0)
						{
							foreach (InvInteraction interaction in selectedItem.interactions)
							{
								EditorGUILayout.BeginHorizontal ();
								invNumber = GetIconSlot (interaction.icon.id);
								invNumber = EditorGUILayout.Popup (invNumber, iconList.ToArray());
								interaction.icon = cursorManager.cursorIcons[invNumber];

								interaction.actionList = (ActionListAsset) EditorGUILayout.ObjectField (interaction.actionList, typeof (ActionListAsset), false);
								
								if (GUILayout.Button (deleteContent, EditorStyles.miniButtonRight, buttonWidth))
								{
									Undo.RecordObject (this, "Delete interaction");
									selectedItem.interactions.Remove (interaction);
									break;
								}
								EditorGUILayout.EndHorizontal ();
							}
						}
						else
						{
							EditorGUILayout.HelpBox ("No interaction icons defined - please use the Cursor Manager", MessageType.Warning);
						}
						if (GUILayout.Button ("Add interaction"))
						{
							Undo.RecordObject (this, "Add new interaction");
							selectedItem.interactions.Add (new InvInteraction (cursorManager.cursorIcons[0]));
						}
					}
					else
					{
						selectedItem.useActionList = (ActionListAsset) EditorGUILayout.ObjectField ("Use:", selectedItem.useActionList, typeof (ActionListAsset), false);
						if (cursorManager && cursorManager.allowInteractionCursorForInventory && cursorManager.cursorIcons.Count > 0)
						{
							int useCursor_int = cursorManager.GetIntFromID (selectedItem.useIconID);
							useCursor_int = EditorGUILayout.Popup ("Use cursor icon:", useCursor_int, cursorManager.GetLabelsArray (useCursor_int));
							selectedItem.useIconID = cursorManager.cursorIcons[useCursor_int].id;
						}
						else
						{
							selectedItem.useIconID = 0;
						}
						selectedItem.lookActionList = (ActionListAsset) EditorGUILayout.ObjectField ("Examine:", selectedItem.lookActionList, typeof (ActionListAsset), false);
						selectedItem.unhandledActionList = (ActionListAsset) EditorGUILayout.ObjectField ("Unhandled use on Hotspot:", selectedItem.unhandledActionList, typeof (ActionListAsset), false);
						selectedItem.unhandledCombineActionList = (ActionListAsset) EditorGUILayout.ObjectField ("Unhandled combine:", selectedItem.unhandledCombineActionList, typeof (ActionListAsset), false);
					}
					
					EditorGUILayout.Space ();
					EditorGUILayout.LabelField ("Combine interactions", EditorStyles.boldLabel);
					for (int i=0; i<selectedItem.combineActionList.Count; i++)
					{
						EditorGUILayout.BeginHorizontal ();
							invNumber = GetArraySlot (selectedItem.combineID[i]);
							invNumber = EditorGUILayout.Popup (invNumber, GetLabelList ());
							selectedItem.combineID[i] = items[invNumber].id;
						
							selectedItem.combineActionList[i] = (ActionListAsset) EditorGUILayout.ObjectField (selectedItem.combineActionList[i], typeof (ActionListAsset), false);
						
							if (GUILayout.Button (deleteContent, EditorStyles.miniButtonRight, buttonWidth))
							{
								Undo.RecordObject (this, "Delete combine event");
								selectedItem.combineActionList.RemoveAt (i);
								selectedItem.combineID.RemoveAt (i);
								break;
							}
						EditorGUILayout.EndHorizontal ();
					}
					if (GUILayout.Button ("Add combine event"))
					{
						Undo.RecordObject (this, "Add new combine event");
						selectedItem.combineActionList.Add (null);
						selectedItem.combineID.Add (0);
					}
					
				EditorGUILayout.EndVertical();
				EditorGUILayout.Space ();
			}

			CraftingGUI ();
			
			if (GUI.changed)
			{
				EditorUtility.SetDirty (this);
			}
		}
Exemple #42
0
        public override string SetLabel()
        {
            if (!settingsManager)
            {
                settingsManager = AdvGame.GetReferences ().settingsManager;
            }

            if (settingsManager && settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (settingsManager.players.Count > 0 && settingsManager.players.Count > playerNumber && playerNumber > -1)
                {
                    if (settingsManager.players[playerNumber].playerOb != null)
                    {
                        return " (" + settingsManager.players[playerNumber].playerOb.name + ")";
                    }
                    else
                    {
                        return (" (Undefined prefab");
                    }
                }
            }

            return "";
        }
Exemple #43
0
        public override void ShowGUI()
        {
            if (!settingsManager)
            {
                settingsManager = AdvGame.GetReferences ().settingsManager;
            }

            if (!settingsManager)
            {
                return;
            }

            if (settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
            {
                EditorGUILayout.HelpBox ("This Action requires Player Switching to be allowed, as set in the Settings Manager.", MessageType.Info);
                return;
            }

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

            int i = 0;
            playerNumber = -1;

            if (settingsManager.players.Count > 0)
            {
                foreach (PlayerPrefab playerPrefab in settingsManager.players)
                {
                    if (playerPrefab.playerOb != null)
                    {
                        labelList.Add (playerPrefab.playerOb.name);
                    }
                    else
                    {
                        labelList.Add ("(Undefined prefab)");
                    }

                    // If a player has been removed, make sure selected player is still valid
                    if (playerPrefab.ID == playerID)
                    {
                        playerNumber = i;
                    }

                    i++;
                }

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

                    playerNumber = 0;
                    playerID = 0;
                }

                playerNumber = EditorGUILayout.Popup ("New Player:", playerNumber, labelList.ToArray());
                playerID = settingsManager.players[playerNumber].ID;

                if (AdvGame.GetReferences ().settingsManager == null || !AdvGame.GetReferences ().settingsManager.shareInventory)
                {
                    keepInventory = EditorGUILayout.Toggle ("Transfer inventory?", keepInventory);
                }
                restorePreviousData = EditorGUILayout.Toggle ("Restore position?", restorePreviousData);
                if (restorePreviousData)
                {
                    EditorGUILayout.LabelField ("If first time in game:", EditorStyles.boldLabel);
                }

                newPlayerPosition = (NewPlayerPosition) EditorGUILayout.EnumPopup ("New Player position:", newPlayerPosition);

                if (newPlayerPosition == NewPlayerPosition.ReplaceNPC)
                {
                    newPlayerNPC = (NPC) EditorGUILayout.ObjectField ("NPC to be replaced:", newPlayerNPC, typeof (NPC), true);

                    newPlayerNPC_ID = FieldToID <NPC> (newPlayerNPC, newPlayerNPC_ID);
                    newPlayerNPC = IDToField <NPC> (newPlayerNPC, newPlayerNPC_ID, false);
                }
                else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                {
                    newPlayerMarker = (Marker) EditorGUILayout.ObjectField ("Marker to appear at:", newPlayerMarker, typeof (Marker), true);

                    newPlayerMarker_ID = FieldToID <Marker> (newPlayerMarker, newPlayerMarker_ID);
                    newPlayerMarker = IDToField <Marker> (newPlayerMarker, newPlayerMarker_ID, false);
                }
                else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
                {
                    chooseNewSceneBy = (ChooseSceneBy) EditorGUILayout.EnumPopup ("Choose scene by:", chooseNewSceneBy);
                    if (chooseNewSceneBy == ChooseSceneBy.Name)
                    {
                        newPlayerSceneName = EditorGUILayout.TextField ("Scene to appear in:", newPlayerSceneName);
                    }
                    else
                    {
                        newPlayerScene = EditorGUILayout.IntField ("Scene to appear in:", newPlayerScene);
                    }
                }

                if (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                {
                    EditorGUILayout.Space ();
                    oldPlayer = (OldPlayer) EditorGUILayout.EnumPopup ("Old Player", oldPlayer);

                    if (oldPlayer == OldPlayer.ReplaceWithNPC)
                    {
                        oldPlayerNPC = (NPC) EditorGUILayout.ObjectField ("NPC to replace old Player:", oldPlayerNPC, typeof (NPC), true);

                        oldPlayerNPC_ID = FieldToID <NPC> (oldPlayerNPC, oldPlayerNPC_ID);
                        oldPlayerNPC = IDToField <NPC> (oldPlayerNPC, oldPlayerNPC_ID, false);
                    }
                }
            }

            else
            {
                EditorGUILayout.LabelField ("No players exist!");
                playerID = -1;
                playerNumber = -1;
            }

            EditorGUILayout.Space ();

            AfterRunningOption ();
        }
		private void GetReferences ()
		{
			settingsManager = AdvGame.GetReferences ().settingsManager;
		}
		public void ShowGUI ()
		{
			settingsManager = AdvGame.GetReferences().settingsManager;

			cursorRendering = (CursorRendering) EditorGUILayout.EnumPopup ("Cursor rendering:", cursorRendering);
			EditorGUILayout.Space ();
			
			EditorGUILayout.BeginVertical ("Button");
				EditorGUILayout.LabelField ("Main cursor", EditorStyles.boldLabel);
				cursorDisplay = (CursorDisplay) EditorGUILayout.EnumPopup ("Display cursor:", cursorDisplay);
				allowMainCursor = EditorGUILayout.Toggle ("Replace mouse cursor?", allowMainCursor);
				if (allowMainCursor || (settingsManager && settingsManager.inputMethod == InputMethod.KeyboardOrController))
				{
					IconBaseGUI ("Main cursor:", pointerIcon);
					IconBaseGUI ("Walk cursor (optional):", walkIcon);
					onlyWalkWhenOverNavMesh = EditorGUILayout.ToggleLeft ("Only show 'Walk' Cursor when over NavMesh?", onlyWalkWhenOverNavMesh);
				}
			EditorGUILayout.EndVertical ();
			
			EditorGUILayout.Space ();

			EditorGUILayout.BeginVertical ("Button");
				EditorGUILayout.LabelField ("Hotspot settings", EditorStyles.boldLabel);
				addHotspotPrefix = EditorGUILayout.Toggle ("Prefix cursor labels?", addHotspotPrefix);
				IconBaseGUI ("Mouse-over cursor:", mouseOverIcon);
			EditorGUILayout.EndVertical ();

			EditorGUILayout.Space ();
			
			EditorGUILayout.BeginVertical ("Button");
				EditorGUILayout.LabelField ("Inventory cursor", EditorStyles.boldLabel);
				if ((settingsManager && settingsManager.interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction) ||
			    (settingsManager && settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingCursorAndClickingHotspot))
				{
					inventoryHandling = (InventoryHandling) EditorGUILayout.EnumPopup ("When inventory selected:", inventoryHandling);
					if (inventoryHandling == InventoryHandling.ChangeCursor || inventoryHandling == InventoryHandling.ChangeCursorAndHotspotLabel)
					{
						inventoryCursorSize = EditorGUILayout.FloatField ("Inventory cursor size:", inventoryCursorSize);
					}
				}
				EditorGUILayout.BeginHorizontal ();
					EditorGUILayout.LabelField ("Syntax:", GUILayout.Width (60f));
					hotspotPrefix1.label = EditorGUILayout.TextField (hotspotPrefix1.label, GUILayout.MaxWidth (80f));
					EditorGUILayout.LabelField ("(item)", GUILayout.MaxWidth (40f));

					hotspotPrefix2.label = EditorGUILayout.TextField (hotspotPrefix2.label, GUILayout.MaxWidth (80f));
					EditorGUILayout.LabelField ("(hotspot)", GUILayout.MaxWidth (55f));
				EditorGUILayout.EndHorizontal ();
			EditorGUILayout.EndVertical ();
			
			EditorGUILayout.Space ();
			
			EditorGUILayout.BeginVertical ("Button");
				EditorGUILayout.LabelField ("Interaction icons", EditorStyles.boldLabel);
				
				if (settingsManager == null || settingsManager.interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction)
				{
					allowInteractionCursor = EditorGUILayout.BeginToggleGroup ("Change cursor when over Hotspots?", allowInteractionCursor);
						if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
						{
							cycleCursors = EditorGUILayout.Toggle ("Cycle with right click?", cycleCursors);
						}
						if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
						{
							allowInteractionCursorForInventory = EditorGUILayout.Toggle ("Change for inventory too?", allowInteractionCursorForInventory);
						}
					EditorGUILayout.EndToggleGroup ();
				}
				
				IconsGUI ();
			
				EditorGUILayout.Space ();
			
				if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
				{
					LookIconGUI ();
				}
			EditorGUILayout.EndVertical ();

			EditorGUILayout.Space ();

			EditorGUILayout.BeginVertical ("Button");
				IconBaseGUI ("Wait cursor", waitIcon);
			EditorGUILayout.EndVertical ();

			if (GUI.changed)
			{
				EditorUtility.SetDirty (this);
			}
		}
Exemple #46
0
        protected int ChoosePlayerGUI(int _playerID)
        {
            SettingsManager settingsManager = KickStarter.settingsManager;

            if (settingsManager == null || settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
            {
                return(_playerID);
            }

            List <string> labelList = new List <string> ();

            int i            = 0;
            int playerNumber = 0;

            labelList.Add("Active Player");

            foreach (PlayerPrefab playerPrefab in settingsManager.players)
            {
                if (playerPrefab.playerOb != null)
                {
                    labelList.Add(playerPrefab.ID.ToString() + ": " + playerPrefab.playerOb.name);
                }
                else
                {
                    labelList.Add(playerPrefab.ID.ToString() + ": " + "(Undefined prefab)");
                }

                if (playerPrefab.ID == _playerID)
                {
                    // Found match
                    playerNumber = i + 1;
                }

                i++;
            }

            if (_playerID >= 0)
            {
                if (playerNumber == 0)
                {
                    // Wasn't found (item was possibly deleted), so revert to zero
                    if (_playerID > 0)
                    {
                        Debug.LogWarning("Previously chosen Player no longer exists!");
                    }
                    playerNumber = 0;
                }
            }

            playerNumber = EditorGUILayout.Popup("Player:", playerNumber, labelList.ToArray());

            if (playerNumber > 0)
            {
                _playerID = settingsManager.players[playerNumber - 1].ID;
            }
            else
            {
                _playerID = -1;
            }

            return(_playerID);
        }