예제 #1
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 ();
        }
예제 #2
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;
		}
        public static void Play(Char speaker, int lineID, string language)
        {
            if (speaker == null)
            {
                return;
            }

                        #if RogoLipSyncIsPresent
            if (lineID > -1 && speaker != null && KickStarter.speechManager.searchAudioFiles)
            {
                RogoDigital.Lipsync.LipSyncData lipSyncData = null;

                if (KickStarter.speechManager.autoNameSpeechFiles)
                {
                    string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, speaker, language, true);
                    lipSyncData = Resources.Load(fullName) as RogoDigital.Lipsync.LipSyncData;

                    if (lipSyncData == null && KickStarter.speechManager.fallbackAudio && Options.GetLanguage() > 0)
                    {
                        fullName    = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, speaker, string.Empty, true);
                        lipSyncData = Resources.Load(fullName) as RogoDigital.Lipsync.LipSyncData;
                    }

                    if (lipSyncData == null)
                    {
                        ACDebug.LogWarning("Lipsync file 'Resources/" + fullName + "' not found.");
                    }
                }
                else
                {
                    Object _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, Options.GetLanguage());
                    if (_object is RogoDigital.Lipsync.LipSyncData)
                    {
                        lipSyncData = (RogoDigital.Lipsync.LipSyncData)_object;
                    }

                    if (lipSyncData == null)
                    {
                        ACDebug.LogWarning("No LipSync data found for " + speaker.gameObject.name + ", line ID " + lineID);
                    }
                }

                if (lipSyncData != null)
                {
                    RogoDigital.Lipsync.LipSync[] lipSyncs = speaker.GetComponentsInChildren <RogoDigital.Lipsync.LipSync>();
                    if (lipSyncs != null && lipSyncs.Length > 0)
                    {
                        foreach (RogoDigital.Lipsync.LipSync lipSync in lipSyncs)
                        {
                            if (lipSync != null && lipSync.enabled)
                            {
                                lipSync.Play(lipSyncData);
                            }
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("No LipSync component found on " + speaker.gameObject.name + " gameobject.");
                    }
                }
            }
                        #else
            ACDebug.LogError("The 'RogoLipSyncIsPresent' preprocessor define must be declared in the Player Settings.");
                        #endif
        }
예제 #4
0
        /**
         * <summary>Gets the display label of a dialogue option.</summary>
         * <param name = "slot">The index number of the dialogue option to find</param>
         * <returns>The display label of the dialogue option</returns>
         */
        public string GetOptionName(int slot)
        {
            int i = ConvertSlotToOption(slot);

            if (i == -1)
            {
                i = 0;
            }
            return(KickStarter.runtimeLanguages.GetTranslation(options[i].label, options[i].lineID, Options.GetLanguage()));
        }
예제 #5
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>();
		}
예제 #6
0
		private void Start ()
		{
			stateHandler = GameObject.FindWithTag  (Tags.persistentEngine).GetComponent <StateHandler>();
			options = stateHandler.GetComponent <Options>();
		}
예제 #7
0
		private void SetVariable (GVar var, VariableLocation location, bool doSkip)
		{
			if (var == null)
			{
				return;
			}

			if (location == VariableLocation.Global)
			{
				var.Download ();
			}

			if (var.type == VariableType.Integer)
			{
				int _value = 0;

				if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere)
				{
					if (setVarMethod == SetVarMethod.Formula)
					{
						_value = (int) AdvGame.CalculateFormula (AdvGame.ConvertTokens (formula, Options.GetLanguage (), localVariables));
					}
					else
					{
						_value = intValue;
					}
				}
				else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter)
				{
					if (animator && parameterName != "")
					{
						_value = animator.GetInteger (parameterName);
						setVarMethod = SetVarMethod.SetValue;
					}	
				}

				if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip)
				{
					var.RestoreBackupValue ();
				}

				var.SetValue (_value, setVarMethod);

				if (doSkip)
				{
					var.BackupValue ();
				}
			}
			if (var.type == VariableType.Float)
			{
				float _value = 0;
				
				if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere)
				{
					if (setVarMethod == SetVarMethod.Formula)
					{
						_value = (float) AdvGame.CalculateFormula (AdvGame.ConvertTokens (formula, Options.GetLanguage (), localVariables));
					}
					else
					{
						_value = floatValue;
					}
				}
				else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter)
				{
					if (animator && parameterName != "")
					{
						_value = animator.GetFloat (parameterName);
						setVarMethod = SetVarMethod.SetValue;
					}	
				}

				if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip)
				{
					var.RestoreBackupValue ();
				}
				
				var.SetFloatValue (_value, setVarMethod);
				
				if (doSkip)
				{
					var.BackupValue ();
				}
			}
			else if (var.type == VariableType.Boolean)
			{
				int _value = 0;

				if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere)
				{
					_value = (int) boolValue;
				}
				else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter)
				{
					if (animator && parameterName != "")
					{
						if (animator.GetBool (parameterName))
						{
							_value = 1;
						}
					}
				}

				var.SetValue (_value, SetVarMethod.SetValue);
			}
			else if (var.type == VariableType.Vector3)
			{
				Vector3 newValue = vector3Value;
				if (setVarMethodVector == SetVarMethodVector.IncreaseByValue)
				{
					newValue += var.vector3Val;
				}

				var.SetVector3Value (newValue);
			}
			else if (var.type == VariableType.PopUp)
			{
				int _value = 0;
				
				if (setVarMethod == SetVarMethod.Formula)
				{
					_value = (int) AdvGame.CalculateFormula (AdvGame.ConvertTokens (formula, Options.GetLanguage (), localVariables));
				}
				else if (setVarMethod == SetVarMethod.SetAsRandom)
				{
					if (var.popUps != null)
					{
						_value = var.popUps.Length;
					}
				}
				else
				{
					_value = intValue;
				}

				if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip)
				{
					var.RestoreBackupValue ();
				}
				
				var.SetValue (_value, setVarMethod);
				
				if (doSkip)
				{
					var.BackupValue ();
				}
			}
			else if (var.type == VariableType.String)
			{
				string _value = "";

				if (setVarMethodString == SetVarMethodString.EnteredHere)
				{
					_value = AdvGame.ConvertTokens (stringValue, Options.GetLanguage (), localVariables);
				}
				else if (setVarMethodString == SetVarMethodString.SetAsMenuElementText)
				{
					MenuElement menuElement = PlayerMenus.GetElementWithName (menuName, elementName);
					if (menuElement != null)
					{
						if (menuElement is MenuInput)
						{
							MenuInput menuInput = (MenuInput) menuElement;
							_value = menuInput.GetContents ();

							if (KickStarter.runtimeLanguages.LanguageReadsRightToLeft (Options.GetLanguage ()) && _value.Length > 0)
							{
								// Invert
								char[] charArray = _value.ToCharArray ();
								_value = "";
								for (int i = charArray.Length-1; i >= 0; i --)
								{
									_value += charArray[i];
								}
							}
						}
						else
						{
							PlayerMenus.GetMenuWithName (menuName).Recalculate ();
							menuElement.PreDisplay (slotNumber, Options.GetLanguage (), false);
							_value = menuElement.GetLabel (slotNumber, Options.GetLanguage ());
						}
					}
					else
					{
						ACDebug.LogWarning ("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'");
					}
				}

				var.SetStringValue (_value, lineID);
			}

			if (location == VariableLocation.Global)
			{
				var.Upload ();
			}

			KickStarter.actionListManager.VariableChanged ();
		}
예제 #8
0
		public void SetMaxVolume ()
		{
			maxVolume = relativeVolume;
			
			if (GameObject.FindWithTag (Tags.persistentEngine) && GameObject.FindWithTag (Tags.persistentEngine).GetComponent <Options>())
			{
				options = GameObject.FindWithTag (Tags.persistentEngine).GetComponent <Options>();
			}
			
			if (options && options.optionsData != null && soundType != SoundType.Other)
			{
				if (soundType == SoundType.Music)
				{
					maxVolume *= options.optionsData.musicVolume;
				}
				else if (soundType == SoundType.SFX)
				{
					maxVolume *= options.optionsData.sfxVolume;
				}
			}

			if (!isFading)
			{
				audioSource.volume = maxVolume;
			}
		}
예제 #9
0
		/**
		 * <summary>Gets the display label of a dialogue option.</summary>
		 * <param name = "slot">The index number of the dialogue option to find</param>
		 * <returns>The display label of the dialogue option</returns>
		 */
		public string GetOptionName (int slot)
		{
			int i = ConvertSlotToOption (slot);
			if (i == -1)
			{
				i = 0;
			}

			string translatedLine = KickStarter.runtimeLanguages.GetTranslation (options[i].label, options[i].lineID, Options.GetLanguage ());
			return AdvGame.ConvertTokens (translatedLine);
		}
예제 #10
0
        override public ActionEnd End(List <AC.Action> actions)
        {
            int actualNumber = 0;

            if (saveCheck == SaveCheck.NumberOfSaveGames)
            {
                actualNumber = KickStarter.saveSystem.GetNumSaves(includeAutoSaves);
            }
            else if (saveCheck == SaveCheck.NumberOfProfiles)
            {
                actualNumber = KickStarter.options.GetNumProfiles();
            }
            else if (saveCheck == SaveCheck.IsSlotEmpty)
            {
                return(ProcessResult(!SaveSystem.DoesSaveExist(intValue, intValue, !checkByElementIndex), actions));
            }
            else if (saveCheck == SaveCheck.DoesProfileExist)
            {
                if (checkByElementIndex)
                {
                    int  i             = Mathf.Max(0, intValue);
                    bool includeActive = true;
                    if (menuName != "" && elementName != "")
                    {
                        MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                        if (menuElement != null && menuElement is MenuProfilesList)
                        {
                            MenuProfilesList menuProfilesList = (MenuProfilesList)menuElement;

                            if (menuProfilesList.fixedOption)
                            {
                                ACDebug.LogWarning("Cannot refer to ProfilesLst " + elementName + " in Menu " + menuName + ", as it lists a fixed profile ID only!");
                                return(ProcessResult(false, actions));
                            }

                            i            += menuProfilesList.GetOffset();
                            includeActive = menuProfilesList.showActive;
                        }
                        else
                        {
                            ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'.");
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("No ProfilesList element referenced when trying to delete profile slot " + i.ToString());
                    }

                    bool result = KickStarter.options.DoesProfileExist(i, includeActive);
                    return(ProcessResult(result, actions));
                }
                else
                {
                    // intValue is the profile ID
                    bool result = Options.DoesProfileIDExist(intValue);
                    return(ProcessResult(result, actions));
                }
            }
            else if (saveCheck == SaveCheck.DoesProfileNameExist)
            {
                bool result = false;

                GVar gVar = GlobalVariables.GetVariable(profileVarID);
                if (gVar != null)
                {
                    string profileName = gVar.textVal;
                    result = KickStarter.options.DoesProfileExist(profileName);
                }
                else
                {
                    ACDebug.LogWarning("Could not check for profile name - no variable found.");
                }

                return(ProcessResult(result, actions));
            }
            else if (saveCheck == SaveCheck.IsSavingPossible)
            {
                return(ProcessResult(!PlayerMenus.IsSavingLocked(this), actions));
            }

            return(ProcessResult(CheckCondition(actualNumber), actions));
        }