Exemplo n.º 1
0
        private static bool SetPersistentEngine()
        {
            if (persistentEnginePrefab == null)
            {
                StateHandler stateHandler = UnityVersionHandler.GetKickStarterComponent <StateHandler>();

                if (stateHandler)
                {
                    persistentEnginePrefab = stateHandler.gameObject;
                }
                else
                {
                    GameObject newPersistentEngine = null;

                    try
                    {
                        newPersistentEngine      = (GameObject)Instantiate(Resources.Load(Resource.persistentEngine));
                        newPersistentEngine.name = AdvGame.GetName(Resource.persistentEngine);
                    }
                    catch (System.Exception e)
                    {
                        ACDebug.LogWarning("Could not create PersistentEngine - make sure " + Resource.persistentEngine + ", prefab is present in a Resources folder. Exception: " + e);
                    }

                    if (newPersistentEngine)
                    {
                                                #if UNITY_EDITOR
                        if (!TestPersistentEngine(newPersistentEngine))
                        {
                            return(false);
                        }
                                                #endif

                        persistentEnginePrefab = newPersistentEngine;

                        stateHandler = persistentEnginePrefab.GetComponent <StateHandler>();
                        stateHandler.Initialise();
                        return(true);
                    }
                }
            }

            if (stateHandler)
            {
                stateHandler.RegisterInitialConstantIDs();
            }
            return(true);
        }
Exemplo n.º 2
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;
            actionListAssetManagerComponent = 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;
            eventManagerComponent      = null;

            SetGameEngine();
        }
Exemplo n.º 3
0
		private void Start ()
		{
			if (GameObject.FindWithTag (Tags.persistentEngine) && GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>())
			{
				stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();
			}
			
			if (GameObject.FindWithTag (Tags.persistentEngine) && GameObject.FindWithTag (Tags.persistentEngine).GetComponent <RuntimeInventory>())
			{
				runtimeInventory = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <RuntimeInventory>();
			}
			
			if (GameObject.FindWithTag (Tags.persistentEngine) && GameObject.FindWithTag (Tags.persistentEngine).GetComponent <PlayerMenus>())
			{
				playerMenus = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <PlayerMenus>();
			}
		}
Exemplo n.º 4
0
		private void Start ()
		{
			if (GameObject.FindWithTag (Tags.persistentEngine) && GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>())
			{
				stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();
			}
			
			/*if (!useParameters)
			{
				foreach (Action action in actions)
				{
					if (action != null)
					{
						action.AssignValues (null);
					}
				}
			} */
		}
Exemplo n.º 5
0
        private static void SetPersistentEngine()
        {
            if (persistentEnginePrefab == null)
            {
                StateHandler stateHandler = UnityVersionHandler.GetKickStarterComponent <StateHandler>();
                if (stateHandler != null)
                {
                    persistentEnginePrefab = stateHandler.gameObject;
                }
                else
                {
                    try
                    {
                        persistentEnginePrefab      = (GameObject)Instantiate(Resources.Load(Resource.persistentEngine));
                        persistentEnginePrefab.name = AdvGame.GetName(Resource.persistentEngine);
                    }
                    catch { }

                    stateHandler = persistentEnginePrefab.GetComponent <StateHandler>();
                    stateHandler.OnAwake();
                }
            }
        }
Exemplo n.º 6
0
		override public float Run ()
		{
			if (speechManager == null)
			{
				speechManager = AdvGame.GetReferences ().speechManager;
			}
			if (speechManager == null)
			{
				Debug.Log ("No Speech Manager present");
				return 0f;
			}

			dialog = GameObject.FindWithTag(Tags.gameEngine).GetComponent <Dialog>();
			stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();

			if (dialog && stateHandler)
			{
				if (!isRunning)
				{
					stopAction = false;
					isRunning = true;
					splitDelay = false;
					splitNumber = 0;
					
					endTime = Time.time + StartSpeech ();

					if (isBackground)
					{
						isRunning = false;
						return 0f;
					}
					return defaultPauseTime;
				}
				else
				{
					if (stopAction)
					{
						isRunning = false;
						return 0;
					}

					if (!dialog.isMessageAlive)
					{
						if (speechManager.separateLines)
						{
							if (!splitDelay)
							{
								// Begin pause if more lines are present
								splitNumber ++;
								string[] textArray = messageText.Split ('\n');
								if (textArray.Length > splitNumber)
								{
									// Still got more to go, so pause for a moment
									splitDelay = true;
									return speechManager.separateLinePause;
								}
								// else finished
							}
							else
							{
								// Show next line
								splitDelay = false;
								endTime = Time.time + StartSpeech ();
								return defaultPauseTime;
							}
						}

						if (waitTimeOffset <= 0f)
						{
							isRunning = false;
							return 0f;
						}
						else
						{
							stopAction = true;
							return waitTimeOffset;
						}
					}
					else
					{
						if (speechManager.displayForever || dialog.pauseGap)
						{
							return defaultPauseTime;
						}

						if (speechManager.separateLines)
						{
							return defaultPauseTime;
						}

						if (!dialog.HasPausing ())
						{
							// Ignore this if we're using [wait] tokens
							if (Time.time < endTime)
							{
								return defaultPauseTime;
							}
							else
							{
								isRunning = false;
								return 0f;
							}
						}
					}
				}
			}
			
			return 0f;
		}
		private void OnDestroy ()
		{
			playerInput = null;
			stateHandler = null;
			runtimeInventory = null;
		}
Exemplo n.º 8
0
		private void Start ()
		{
			stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();
		}
Exemplo n.º 9
0
		private void OnDestroy ()
		{
			playerInput = null;
			stateHandler = null;
		}
Exemplo n.º 10
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 ();
        }
Exemplo n.º 11
0
		private void OnDestroy ()
		{
			actionListManager = null;
			stateHandler = null;
		}
Exemplo n.º 12
0
		private void OnDestroy ()
		{
			actionListManager = null;
			dialog = null;
			playerInput = null;
			playerInteraction = null;
			menuSystem = null;
			stateHandler = null;
			options = null;
			menus = null;
			runtimeInventory = null;
			settingsManager = null;
			cursorManager = null;
			speechManager = null;
			menuManager = null;
			sceneSettings = null;
		}
Exemplo n.º 13
0
		private void GetReferences ()
		{
			settingsManager = AdvGame.GetReferences ().settingsManager;
			if (settingsManager.IsInLoadingScene ())
			{
				return;
			}
			
			speechManager = AdvGame.GetReferences ().speechManager;
			cursorManager = AdvGame.GetReferences ().cursorManager;
			menuManager = AdvGame.GetReferences ().menuManager;
			
			playerCursor = GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerCursor>();
			actionListManager = playerCursor.GetComponent <ActionListManager>();
			playerInput = playerCursor.GetComponent <PlayerInput>();
			playerInteraction = playerCursor.GetComponent <PlayerInteraction>();
			menuSystem = playerCursor.GetComponent <MenuSystem>();
			dialog = playerCursor.GetComponent <Dialog>();
			sceneSettings = playerCursor.GetComponent <SceneSettings>();
			
			stateHandler = this.GetComponent <StateHandler>();
			options = this.GetComponent <Options>();
			runtimeInventory = this.GetComponent <RuntimeInventory>();
		}
Exemplo n.º 14
0
		private void OnDestroy ()
		{
			stateHandler = null;
			runtimeInventory = null;
			settingsManager = null;
			actionListManager = null;
			playerInteraction = null;
		}
Exemplo n.º 15
0
		private void Start ()
		{
			if (GameObject.FindWithTag (Tags.persistentEngine))
			{
				if (GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>())
				{
					stateHandler = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <StateHandler>();
				}
				
				if (GameObject.FindWithTag (Tags.persistentEngine).GetComponent <RuntimeInventory>())
				{
					runtimeInventory = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <RuntimeInventory>();
				}
			}
			
			if (settingsManager.movementMethod == MovementMethod.UltimateFPS)
			{
				UltimateFPSIntegration.SetCameraState (cursorIsLocked);
			}
			
			if (settingsManager.offsetTouchCursor)
			{
				mousePosition = xboxCursor;
			}
		}
Exemplo n.º 16
0
		private void OnDestroy ()
		{
			stateHandler = null;
			runtimeInventory = null;
			playerInput = null;
			playerInteraction = null;
			playerMenus = null;
		}