protected override void AutoSize() { if (string.IsNullOrEmpty(label) && backgroundTexture) { GUIContent content = new GUIContent(backgroundTexture); AutoSize(content); } else { GUIContent content = new GUIContent(TranslateLabel(label, Options.GetLanguage())); AutoSize(content); } }
protected override void AutoSize() { if (label == "" && backgroundTexture != null) { GUIContent content = new GUIContent(backgroundTexture); AutoSize(content); } else { GUIContent content = new GUIContent(TranslateLabel(label, Options.GetLanguage())); AutoSize(content); } }
protected override void AutoSize() { int languageNumber = Options.GetLanguage(); if (appendState) { AutoSize(new GUIContent(TranslateLabel(label, languageNumber) + " : Off")); } else { AutoSize(new GUIContent(TranslateLabel(label, languageNumber))); } }
protected override void AutoSize() { if (displayType == AC_DisplayType.IconOnly && icon != null && icon.texture != null) { GUIContent content = new GUIContent(icon.texture); AutoSize(content); } else { GUIContent content = new GUIContent(TranslateLabel(label, Options.GetLanguage())); AutoSize(content); } }
protected override void AutoSize() { int languageNumber = Options.GetLanguage(); string _newLabel = (Application.isPlaying) ? newLabel : label; if (labelType == AC_LabelType.DialogueLine) { GUIContent content = new GUIContent(TranslateLabel(_newLabel, languageNumber)); #if UNITY_EDITOR if (!Application.isPlaying) { AutoSize(content); return; } #endif GUIStyle normalStyle = new GUIStyle(); normalStyle.font = font; normalStyle.fontSize = (int)(AdvGame.GetMainGameViewSize(true).x *fontScaleFactor / 100); UpdateSpeechLink(); if (speech != null) { string line = " " + speech.FullText + " "; content = new GUIContent(line); AutoSize(content); } } else if (labelType == AC_LabelType.ActiveSaveProfile) { GUIContent content = new GUIContent(GetLabel(0, 0)); AutoSize(content); } else if (string.IsNullOrEmpty(_newLabel) && backgroundTexture != null) { GUIContent content = new GUIContent(backgroundTexture); AutoSize(content); } else if (labelType == AC_LabelType.Normal) { GUIContent content = new GUIContent(TranslateLabel(_newLabel, languageNumber)); AutoSize(content); } else { GUIContent content = new GUIContent(_newLabel); AutoSize(content); } }
/** * <summary>Generates a label that represents the name of the parameter's value, if appropriate<summary> * <returns>A label that represents the name of the parameter's value<summary> */ public string GetLabel() { switch (parameterType) { case ParameterType.GameObject: if (gameObject != null) { Hotspot _hotspot = gameObject.GetComponent <Hotspot>(); if (_hotspot) { return(_hotspot.GetName(Options.GetLanguage())); } Char _char = gameObject.GetComponent <Char>(); if (_char) { return(_char.GetName(Options.GetLanguage())); } return(gameObject.name); } return(string.Empty); case ParameterType.InventoryItem: InvItem invItem = KickStarter.inventoryManager.GetItem(intValue); if (invItem != null) { return(invItem.GetLabel(Options.GetLanguage())); } return(GetSaveData()); case ParameterType.GlobalVariable: GVar gVar = KickStarter.variablesManager.GetVariable(intValue); if (gVar != null) { return(gVar.label); } return(GetSaveData()); case ParameterType.LocalVariable: GVar lVar = LocalVariables.GetVariable(intValue); if (lVar != null) { return(lVar.label); } return(GetSaveData()); default: return(GetSaveData()); } }
public override void OnMenuTurnOn(Menu menu) { PreDisplay(0, Options.GetLanguage(), false); #if ALLOW_MOVIETEXTURE if (localTexture != null) { MovieTexture movieTexture = localTexture as MovieTexture; if (movieTexture != null) { movieTexture.Play(); } } #endif }
protected override void AutoSize() { CursorIcon _icon = GetIconAtSlot(0); if (displayType == AC_DisplayType.IconOnly && _icon != null && _icon.texture != null) { GUIContent content = new GUIContent(_icon.texture); AutoSize(content); } else { GUIContent content = new GUIContent(TranslateLabel(GetLabel(0, Options.GetLanguage()), Options.GetLanguage())); AutoSize(content); } }
private void FixedUpdate() { if (element && setTextLabels) { int languageNumber = Options.GetLanguage(); if (GetComponent <GUIText>()) { GetComponent <GUIText>().text = GetLabel(languageNumber); } if (GetComponent <TextMesh>()) { GetComponent <TextMesh>().text = GetLabel(languageNumber); } } }
protected override void AutoSize() { int languageNumber = Options.GetLanguage(); if (labelType == AC_LabelType.DialogueLine) { GUIContent content = new GUIContent(TranslateLabel(label, languageNumber)); #if UNITY_EDITOR if (!Application.isPlaying) { AutoSize(content); return; } #endif GUIStyle normalStyle = new GUIStyle(); normalStyle.font = font; normalStyle.fontSize = (int)(AdvGame.GetMainGameViewSize().x *fontScaleFactor / 100); UpdateSpeechLink(); if (speech != null) { string line = " " + speech.log.fullText + " "; if (line.Length > 40) { line = line.Insert(line.Length / 2, " \n "); } content = new GUIContent(line); AutoSize(content); } } else if (labelType == AC_LabelType.ActiveSaveProfile) { GUIContent content = new GUIContent(GetLabel(0, 0)); AutoSize(content); } else if (label == "" && backgroundTexture != null) { GUIContent content = new GUIContent(backgroundTexture); AutoSize(content); } else { GUIContent content = new GUIContent(TranslateLabel(label, languageNumber)); AutoSize(content); } }
/** * <summary>Initialises a new Speech line.</summary> * <param name = "_speaker">The speaking character. If null, the line will be treated as narration</param> * <param name = "_text">The subtitle text to display</param> * <param name = "isBackground">True if the line should play in the background, and not interrupt any Actions or gameplay</param> * <param name = "lineID">The ID number of the line, if it is listed in the Speech Manager</param> * <param name = "noAnimation">True if the character should not play a talking animation</param> * <returns>The generated Speech line</returns> */ public Speech StartDialog(Char _speaker, string _text, bool isBackground = false, int lineID = -1, bool noAnimation = false) { if (!KickStarter.actionListManager.IsGameplayBlocked() && !KickStarter.stateHandler.IsInScriptedCutscene()) { // Force background if during gameplay isBackground = true; } // Get the language string _language = ""; int lanuageNumber = Options.GetLanguage(); if (lanuageNumber > 0) { // Not in original language, so pull translation in from Speech Manager _language = KickStarter.runtimeLanguages.Languages [lanuageNumber]; } // Remove speaker's previous line for (int i = 0; i < speechList.Count; i++) { if (speechList[i].GetSpeakingCharacter() == _speaker) { EndSpeech(i); i = 0; } } Speech speech = new Speech(_speaker, _text, lineID, _language, isBackground, noAnimation); speechList.Add(speech); KickStarter.runtimeVariables.AddToSpeechLog(speech.log); KickStarter.playerMenus.AssignSpeechToMenu(speech); if (speech.hasAudio) { if (KickStarter.speechManager.relegateBackgroundSpeechAudio) { EndBackgroundSpeechAudio(speech); } KickStarter.stateHandler.UpdateAllMaxVolumes(); } return(speech); }
protected void FixedUpdate() { if (element && setTextLabels) { int languageNumber = Options.GetLanguage(); #if ALLOW_LEGACY_UI if (_guiText != null) { _guiText.text = GetLabel(languageNumber); } #endif if (textMesh != null) { textMesh.text = GetLabel(languageNumber); } } }
private void FixedUpdate() { if (element && setTextLabels) { int languageNumber = Options.GetLanguage(); #if ALLOW_LEGACY_UI if (GetComponent <GUIText>()) { GetComponent <GUIText>().text = GetLabel(languageNumber); } #endif if (GetComponent <TextMesh>()) { GetComponent <TextMesh>().text = GetLabel(languageNumber); } } }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { if (isPlaying) { isPlaying = false; if (Application.isPlaying) { string messageText = speechPlayableData.messageText; int languageNumber = Options.GetLanguage(); if (languageNumber > 0) { // Not in original language, so pull translation in from Speech Manager messageText = KickStarter.runtimeLanguages.GetTranslation(messageText, speechPlayableData.lineID, languageNumber, AC_TextType.Speech); } if (speechTrackPlaybackMode == SpeechTrackPlaybackMode.ClipDuration) { messageText += "[hold]"; } #if AddressableIsPresent KickStarter.dialog.StartDialog(speaker, messageText, false, speechPlayableData.lineID, false, true, addressableAudioClip); #else KickStarter.dialog.StartDialog(speaker, messageText, false, speechPlayableData.lineID, false, true); #endif } #if UNITY_EDITOR else if (KickStarter.menuPreview) { Speech previewSpeech = new Speech(speaker, speechPlayableData.messageText); KickStarter.menuPreview.SetPreviewSpeech(previewSpeech, trackInstanceID); } #else else { ACDebug.Log("Playing speech line with track ID: " + trackInstanceID); } #endif } base.ProcessFrame(playable, info, playerData); }
override public float Run() { InvItem invItem = (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) ? KickStarter.runtimeInventory.LastSelectedItem : KickStarter.inventoryManager.GetItem(invID); if (invItem != null && runtimeVariable != null) { InvVar invVar = invItem.GetProperty(propertyID); if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item " + invItem.GetLabel(0)); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { if (invVar.type == VariableType.Float) { runtimeVariable.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { runtimeVariable.Vector3Value = invVar.Vector3Value; } else { runtimeVariable.IntegerValue = invVar.IntegerValue; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } } return(0); }
override public float Run() { GVar myVar = (varLocation == VariableLocation.Global) ? GlobalVariables.GetVariable(variableID) : LocalVariables.GetVariable(variableID, localVariables); InvItem invItem = (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) ? KickStarter.runtimeInventory.LastSelectedItem : KickStarter.inventoryManager.GetItem(invID); if (invItem != null && myVar != null) { InvVar invVar = invItem.GetProperty(propertyID); if (myVar.type == VariableType.String) { myVar.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (myVar.type == invVar.type) { if (invVar.type == VariableType.Float) { myVar.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { myVar.Vector3Value = invVar.Vector3Value; } else { myVar.IntegerValue = invVar.IntegerValue; } } else { ACDebug.LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + myVar.label + "'s value from '" + invVar.label + "' property because their types do not match."); } } return(0); }
/** * <summary>Generates a label that represents the name of the parameter's value, if the parameterType = ParameterType.GameObject<summary> * <returns>A label that represents the name of the parameter's value, if the parameterType = ParameterType.GameObject<summary> */ public string GetLabel() { if (parameterType == ParameterType.GameObject) { if (gameObject != null) { Hotspot _hotspot = gameObject.GetComponent <Hotspot>(); if (_hotspot) { return(_hotspot.GetName(Options.GetLanguage())); } Char _char = gameObject.GetComponent <Char>(); if (_char) { return(_char.GetName(Options.GetLanguage())); } return(gameObject.name); } return(""); } return(GetSaveData()); }
private void PerformSaveOrLoad() { ClearAllEvents(); if (saveHandling == SaveHandling.ContinueFromLastSave || saveHandling == SaveHandling.LoadGame) { EventManager.OnFinishLoading += OnComplete; EventManager.OnFailLoading += OnComplete; } else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame) { EventManager.OnFinishSaving += OnComplete; EventManager.OnFailSaving += OnComplete; } if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad) { KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad); } string newSaveLabel = ""; if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame)) { if (selectSaveType != SelectSaveType.Autosave) { GVar gVar = GlobalVariables.GetVariable(varID); if (gVar != null) { newSaveLabel = gVar.GetValue(Options.GetLanguage()); } else { ACDebug.LogWarning("Could not " + saveHandling.ToString() + " - no variable found."); return; } } } int i = Mathf.Max(0, saveIndex); if (saveHandling == SaveHandling.ContinueFromLastSave) { SaveSystem.ContinueGame(); return; } if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave) { if (selectSaveType == SelectSaveType.Autosave) { if (saveHandling == SaveHandling.LoadGame) { SaveSystem.LoadAutoSave(); return; } else { if (PlayerMenus.IsSavingLocked(this)) { ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Conversation is active, or saving has been manually locked."); OnComplete(); } else { SaveSystem.SaveAutoSave(); } return; } } else if (selectSaveType == SelectSaveType.SlotIndexFromVariable) { GVar gVar = GlobalVariables.GetVariable(slotVarID); if (gVar != null) { i = gVar.val; } else { ACDebug.LogWarning("Could not get save slot index - no variable found."); return; } } } if (menuName != "" && elementName != "") { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuSavesList) { MenuSavesList menuSavesList = (MenuSavesList)menuElement; i += menuSavesList.GetOffset(); } else { ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { ACDebug.LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString()); } if (saveHandling == SaveHandling.LoadGame) { SaveSystem.LoadGame(i, -1, false); } else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame) { if (PlayerMenus.IsSavingLocked(this)) { ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Conversation is active, or saving has been manually locked."); OnComplete(); } else { if (saveHandling == SaveHandling.OverwriteExistingSave) { SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel); } else if (saveHandling == SaveHandling.SaveNewGame) { SaveSystem.SaveNewGame(updateLabel, newSaveLabel); } } } }
public override float Run() { int runtimeInvID = -1; if (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) { if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance)) { runtimeInvID = KickStarter.runtimeInventory.SelectedInstance.ItemID; } } else { runtimeInvID = invID; } InvVar invVar = null; if (runtimeInvID >= 0) { InvInstance invInstance = (useLiveValues) ? KickStarter.runtimeInventory.GetInstance(runtimeInvID) : new InvInstance(KickStarter.inventoryManager.GetItem(runtimeInvID)); if (!InvInstance.IsValid(invInstance)) { if (useLiveValues) { LogWarning("Cannot find Inventory item with ID " + runtimeInvID + " in the Player's inventory"); } else { LogWarning("Cannot find Inventory item with ID " + runtimeInvID); } return(0f); } invVar = invInstance.GetProperty(propertyID); } if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item ID " + runtimeInvID); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.TextValue = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { int itemCount = (useLiveValues && multiplyByItemCount) ? KickStarter.runtimeInventory.GetCount(runtimeInvID) : 1; switch (invVar.type) { case VariableType.Float: runtimeVariable.FloatValue = invVar.FloatValue * (float)itemCount; break; case VariableType.Integer: runtimeVariable.IntegerValue = invVar.IntegerValue * itemCount; break; case VariableType.Vector3: runtimeVariable.Vector3Value = invVar.Vector3Value; break; default: runtimeVariable.IntegerValue = invVar.IntegerValue; break; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } return(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)); }
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)); } 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)); } 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.SetValue(_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.PopUp) { var.SetValue(intValue); } else if (var.type == VariableType.String) { string _value = ""; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens(stringValue); } 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 ((Options.GetLanguageName() == "Arabic" || Options.GetLanguageName() == "Hebrew") && _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 { Debug.LogWarning("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetValue(_value); } if (location == VariableLocation.Global) { var.Upload(); } KickStarter.actionListManager.VariableChanged(); }
public override float Run() { int runtimeInvID = -1; if (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) { if (KickStarter.runtimeInventory.SelectedItem != null) { runtimeInvID = KickStarter.runtimeInventory.SelectedItem.id; } } else { runtimeInvID = invID; } InvVar invVar = null; if (runtimeInvID >= 0) { if (multiplyByItemCount) { invVar = KickStarter.runtimeInventory.GetPropertyTotals(propertyID, runtimeInvID); } else { InvItem invItem = KickStarter.inventoryManager.GetItem(runtimeInvID); if (invItem != null) { invVar = invItem.GetProperty(propertyID); } } } if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item ID " + runtimeInvID); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { if (invVar.type == VariableType.Float) { runtimeVariable.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { runtimeVariable.Vector3Value = invVar.Vector3Value; } else { runtimeVariable.IntegerValue = invVar.IntegerValue; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } return(0); }
/** * <summary>Generates the animation data for lipsyncing a given Speech line.</summary> * <param name = "_lipSyncMode">The chosen method of lipsyncing (Off, FromSpeechText, ReadPamelaFile, ReadSapiFile, ReadPapagayoFile, FaceFX, Salsa2D)</param> * <param name = "lineNumber">The speech line's ID number</param> * <param name = "speakerName">The filename of the speaking character</param> * <param name = "language">The name of the current language</param> * <param name = "_message">The speech text</param< * <returns>A List of LipSyncShape structs that contain the lipsync animation data</returns> */ public List <LipSyncShape> GenerateLipSyncShapes(LipSyncMode _lipSyncMode, int lineNumber, string speakerName, string language = "", string _message = "") { List <LipSyncShape> lipSyncShapes = new List <LipSyncShape>(); lipSyncShapes.Add(new LipSyncShape(0, 0f, KickStarter.speechManager.lipSyncSpeed)); TextAsset textFile = null; if (_lipSyncMode == LipSyncMode.Salsa2D) { return(lipSyncShapes); } if (lineNumber > -1 && speakerName != "" && KickStarter.speechManager.searchAudioFiles && KickStarter.speechManager.UseFileBasedLipSyncing()) { if (KickStarter.speechManager.autoNameSpeechFiles) { string filename = "Lipsync/"; if (language != "" && KickStarter.speechManager.translateAudio) { // Not in original language filename += language + "/"; } if (KickStarter.speechManager.placeAudioInSubfolders) { filename += speakerName + "/"; } filename += speakerName + lineNumber; textFile = Resources.Load(filename) as TextAsset; if (textFile == null && KickStarter.speechManager.fallbackAudio && Options.GetLanguage() > 0) { filename = "Lipsync/"; if (KickStarter.speechManager.placeAudioInSubfolders) { filename += "/" + speakerName + "/"; } filename += speakerName + lineNumber; textFile = Resources.Load(filename) as TextAsset; } if (textFile == null) { ACDebug.LogWarning("Lipsync file '/Resources/" + filename + ".txt' not found."); } } else { UnityEngine.Object _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineNumber, Options.GetLanguage()); if (_object == null && KickStarter.speechManager.fallbackAudio && Options.GetLanguage() > 0) { _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineNumber, 0); } if (_object is TextAsset) { textFile = (TextAsset)KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineNumber, Options.GetLanguage()); } } } if (_lipSyncMode == LipSyncMode.ReadPamelaFile && textFile != null) { var splitFile = new string[] { "\r\n", "\r", "\n" }; var pamLines = textFile.text.Split(splitFile, System.StringSplitOptions.None); bool foundSpeech = false; float fps = 24f; foreach (string pamLine in pamLines) { if (!foundSpeech) { if (pamLine.Contains("framespersecond:")) { string[] pamLineArray = pamLine.Split(':'); float.TryParse(pamLineArray[1], out fps); } else if (pamLine.Contains("[Speech]")) { foundSpeech = true; } } else if (pamLine.Contains(":")) { string[] pamLineArray = pamLine.Split(':'); float timeIndex = 0f; float.TryParse(pamLineArray[0], out timeIndex); string searchText = pamLineArray[1].ToLower().Substring(0, pamLineArray[1].Length - 1); bool found = false; foreach (string phoneme in KickStarter.speechManager.phonemes) { string[] shapesArray = phoneme.ToLower().Split("/"[0]); if (!found) { foreach (string shape in shapesArray) { //if (shape == searchText) if (searchText.Contains(shape) && searchText.Length == shape.Length) { int frame = KickStarter.speechManager.phonemes.IndexOf(phoneme); lipSyncShapes.Add(new LipSyncShape(frame, timeIndex, KickStarter.speechManager.lipSyncSpeed, fps)); found = true; } } } } if (!found) { lipSyncShapes.Add(new LipSyncShape(0, timeIndex, KickStarter.speechManager.lipSyncSpeed, fps)); } } } } else if (_lipSyncMode == LipSyncMode.ReadSapiFile && textFile != null) { var splitFile = new string[] { "\r\n", "\r", "\n" }; var sapiLines = textFile.text.Split(splitFile, System.StringSplitOptions.None); foreach (string sapiLine in sapiLines) { if (sapiLine.StartsWith("phn ")) { string[] sapiLineArray = sapiLine.Split(' '); float timeIndex = 0f; float.TryParse(sapiLineArray[1], out timeIndex); string searchText = sapiLineArray[4].ToLower().Substring(0, sapiLineArray[4].Length - 1); bool found = false; foreach (string phoneme in KickStarter.speechManager.phonemes) { string[] shapesArray = phoneme.ToLower().Split("/"[0]); if (!found) { foreach (string shape in shapesArray) { if (shape == searchText) { int frame = KickStarter.speechManager.phonemes.IndexOf(phoneme); lipSyncShapes.Add(new LipSyncShape(frame, timeIndex, KickStarter.speechManager.lipSyncSpeed, 60f)); found = true; } } } } if (!found) { lipSyncShapes.Add(new LipSyncShape(0, timeIndex, KickStarter.speechManager.lipSyncSpeed, 60f)); } } } } else if (_lipSyncMode == LipSyncMode.ReadPapagayoFile && textFile != null) { var splitFile = new string[] { "\r\n", "\r", "\n" }; var papagoyoLines = textFile.text.Split(splitFile, System.StringSplitOptions.None); foreach (string papagoyoLine in papagoyoLines) { if (papagoyoLine != "" && !papagoyoLine.Contains("MohoSwitch")) { string[] papagoyoLineArray = papagoyoLine.Split(' '); if (papagoyoLineArray.Length == 2) { float timeIndex = 0f; if (float.TryParse(papagoyoLineArray[0], out timeIndex)) { string searchText = papagoyoLineArray[1].ToLower().Substring(0, papagoyoLineArray[1].Length); bool found = false; if (!searchText.Contains("rest") && !searchText.Contains("etc")) { foreach (string phoneme in KickStarter.speechManager.phonemes) { string[] shapesArray = phoneme.ToLower().Split("/"[0]); if (!found) { foreach (string shape in shapesArray) { if (shape == searchText) { int frame = KickStarter.speechManager.phonemes.IndexOf(phoneme); lipSyncShapes.Add(new LipSyncShape(frame, timeIndex, KickStarter.speechManager.lipSyncSpeed, 24f)); found = true; break; } } } } if (!found) { lipSyncShapes.Add(new LipSyncShape(0, timeIndex, KickStarter.speechManager.lipSyncSpeed, 24f)); // was 240 } } } } } } } else if (_lipSyncMode == LipSyncMode.FromSpeechText) { for (int i = 0; i < _message.Length; i++) { int maxSearch = Mathf.Min(5, _message.Length - i); for (int n = maxSearch; n > 0; n--) { string searchText = _message.Substring(i, n); searchText = searchText.ToLower(); foreach (string phoneme in KickStarter.speechManager.phonemes) { string[] shapesArray = phoneme.ToLower().Split("/"[0]); foreach (string shape in shapesArray) { if (shape == searchText) { int frame = KickStarter.speechManager.phonemes.IndexOf(phoneme); lipSyncShapes.Add(new LipSyncShape(frame, (float)i, KickStarter.speechManager.lipSyncSpeed)); i += n; n = Mathf.Min(5, _message.Length - i); break; } } } } lipSyncShapes.Add(new LipSyncShape(0, (float)i, KickStarter.speechManager.lipSyncSpeed)); } } if (lipSyncShapes.Count > 1) { lipSyncShapes.Sort(delegate(LipSyncShape a, LipSyncShape b) { return(a.timeIndex.CompareTo(b.timeIndex)); }); } return(lipSyncShapes); }
override public float Run() { if (_parameter == null) { ACDebug.LogWarning("Cannot set parameter value since it cannot be found!"); return(0f); } if (setParamMethod == SetParamMethod.CopiedFromGlobalVariable) { GVar gVar = GlobalVariables.GetVariable(globalVariableID); if (gVar != null) { if (_parameter.parameterType == ParameterType.Boolean || _parameter.parameterType == ParameterType.Integer) { _parameter.intValue = gVar.val; } else if (_parameter.parameterType == ParameterType.Float) { _parameter.floatValue = gVar.floatVal; } else if (_parameter.parameterType == ParameterType.Vector3) { _parameter.vector3Value = gVar.vector3Val; } else if (_parameter.parameterType == ParameterType.String) { _parameter.stringValue = GlobalVariables.GetStringValue(globalVariableID, true, Options.GetLanguage()); } } } else if (setParamMethod == SetParamMethod.EnteredHere) { if (_parameter.parameterType == ParameterType.Boolean || _parameter.parameterType == ParameterType.Integer || _parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.LocalVariable || _parameter.parameterType == ParameterType.InventoryItem) { _parameter.intValue = intValue; } else if (_parameter.parameterType == ParameterType.Float) { _parameter.floatValue = floatValue; } else if (_parameter.parameterType == ParameterType.String) { _parameter.stringValue = stringValue; } else if (_parameter.parameterType == ParameterType.GameObject) { _parameter.gameObject = gameobjectValue; _parameter.intValue = gameObjectConstantID; } else if (_parameter.parameterType == ParameterType.UnityObject) { _parameter.objectValue = unityObjectValue; } else if (_parameter.parameterType == ParameterType.Vector3) { _parameter.vector3Value = vector3Value; } } else if (setParamMethod == SetParamMethod.Random) { if (_parameter.parameterType == ParameterType.Boolean) { _parameter.intValue = Random.Range(0, 2); } else if (_parameter.parameterType == ParameterType.Integer) { _parameter.intValue = Random.Range(intValue, intValueMax + 1); } else if (_parameter.parameterType == ParameterType.Float) { _parameter.floatValue = Random.Range(floatValue, floatValueMax); } else { ACDebug.LogWarning("Parameters of type '" + _parameter.parameterType + "' cannot be set randomly."); } } else if (setParamMethod == SetParamMethod.CopiedFromParameter) { if (_parameterToCopy == null) { ACDebug.LogWarning("Cannot copy parameter value since it cannot be found!"); return(0f); } _parameter.CopyValues(_parameterToCopy); } return(0f); }
protected void PerformSaveOrLoad() { ClearAllEvents(); if (saveHandling == SaveHandling.ContinueFromLastSave || saveHandling == SaveHandling.LoadGame) { EventManager.OnFinishLoading += OnFinishLoading; EventManager.OnFailLoading += OnFail; } else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame) { EventManager.OnFinishSaving += OnFinishSaving; EventManager.OnFailSaving += OnFail; } if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad) { KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad); } string newSaveLabel = string.Empty; if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame)) { if (selectSaveType != SelectSaveType.Autosave) { GVar gVar = GlobalVariables.GetVariable(varID); if (gVar != null) { newSaveLabel = gVar.GetValue(Options.GetLanguage()); } else { LogWarning("Could not " + saveHandling.ToString() + " - no variable found."); return; } } } int i = saveIndex; if (saveHandling == SaveHandling.ContinueFromLastSave) { SaveSystem.ContinueGame(); return; } if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave) { if (selectSaveType == SelectSaveType.Autosave) { if (saveHandling == SaveHandling.LoadGame) { SaveSystem.LoadAutoSave(); return; } else { if (PlayerMenus.IsSavingLocked(this, true)) { OnComplete(); } else { SaveSystem.SaveAutoSave(); } return; } } else if (selectSaveType == SelectSaveType.SlotIndexFromVariable) { GVar gVar = GlobalVariables.GetVariable(slotVarID); if (gVar != null) { i = gVar.IntegerValue; } else { LogWarning("Could not get save slot index - no variable found."); return; } } } if (selectSaveType != SelectSaveType.Autosave && selectSaveType != SelectSaveType.SetSaveID) { if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(elementName)) { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuSavesList) { MenuSavesList menuSavesList = (MenuSavesList)menuElement; i += menuSavesList.GetOffset(); } else { LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString()); } } if (saveHandling == SaveHandling.LoadGame) { if (selectSaveType == SelectSaveType.SetSaveID) { SaveSystem.LoadGame(i); } else { SaveSystem.LoadGame(i, -1, false); } } else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame) { if (PlayerMenus.IsSavingLocked(this, true)) { OnComplete(); } else { if (saveHandling == SaveHandling.OverwriteExistingSave) { if (selectSaveType == SelectSaveType.SetSaveID) { SaveSystem.SaveGame(0, i, true, updateLabel, newSaveLabel); } else { SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel); } } else if (saveHandling == SaveHandling.SaveNewGame) { SaveSystem.SaveNewGame(updateLabel, newSaveLabel); } } } }
/** * <summary>The default Constructor.</summary> * <param name = "_speaker">The speaking character. If null, the line is considered a narration</param> * <param name = "_message">The subtitle text to display</param> * <param name = "lineID">The unique ID number of the line, as generated by the Speech Manager</param> * <param name = "_language">The currently-selected language</param> * <param name = "_isBackground">True if the line should play in the background, and not interrupt Actions or gameplay</param> * <param name = "_noAnimation">True if the speaking character should not play a talking animation</param> * <param name = "_runActionListInBackground">True if the ActionList that contains the call is set to Run In Background</param> */ public Speech(Char _speaker, string _message, int lineID, string _language, bool _isBackground, bool _noAnimation, bool _runActionListInBackground = false) { // Clear rich text boldTagIndex = italicTagIndex = sizeTagIndex = colorTagIndex = -1; closingTags = ""; log.Clear(); isBackground = _isBackground; runActionListInBackground = _runActionListInBackground; if (_speaker) { speaker = _speaker; speaker.isTalking = !_noAnimation; log.speakerName = _speaker.name; if (_speaker.GetComponent <Player>()) { if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow || !KickStarter.speechManager.usePlayerRealName) { log.speakerName = "Player"; } } if (_speaker.GetComponent <Hotspot>()) { if (_speaker.GetComponent <Hotspot>().hotspotName != "") { log.speakerName = _speaker.GetComponent <Hotspot>().hotspotName; } } _speaker.ClearExpression(); if (!_noAnimation) { if (KickStarter.speechManager.lipSyncMode == LipSyncMode.Off) { speaker.isLipSyncing = false; } else if (KickStarter.speechManager.lipSyncMode == LipSyncMode.Salsa2D || KickStarter.speechManager.lipSyncMode == LipSyncMode.FromSpeechText || KickStarter.speechManager.lipSyncMode == LipSyncMode.ReadPamelaFile || KickStarter.speechManager.lipSyncMode == LipSyncMode.ReadSapiFile || KickStarter.speechManager.lipSyncMode == LipSyncMode.ReadPapagayoFile) { speaker.StartLipSync(KickStarter.dialog.GenerateLipSyncShapes(KickStarter.speechManager.lipSyncMode, lineID, speaker.name, _language, _message)); } else if (KickStarter.speechManager.lipSyncMode == LipSyncMode.RogoLipSync) { RogoLipSyncIntegration.Play(_speaker, speaker.name, lineID, _language); } } } else { if (speaker) { speaker.isTalking = false; } speaker = null; log.speakerName = "Narrator"; } _message = DetermineGaps(_message); if (speechGaps.Count > 0) { gapIndex = 0; /*foreach (SpeechGap gap in speechGaps) * { * if (gap.expressionID < 0) * { * displayDuration += (float) gap.waitTime; * } * }*/ } else { gapIndex = -1; } if (lineID > -1) { log.lineID = lineID; } // Play sound and time displayDuration to it if (lineID > -1 && log.speakerName != "" && KickStarter.speechManager.searchAudioFiles) { AudioClip clipObj = null; if (KickStarter.speechManager.autoNameSpeechFiles) { string fullFilename = "Speech/"; string filename = KickStarter.speechManager.GetLineFilename(lineID); if (_language != "" && KickStarter.speechManager.translateAudio) { // Not in original language fullFilename += _language + "/"; } if (KickStarter.speechManager.placeAudioInSubfolders) { fullFilename += filename + "/"; } fullFilename += filename + lineID; clipObj = Resources.Load(fullFilename) as AudioClip; if (clipObj == null && KickStarter.speechManager.fallbackAudio && Options.GetLanguage() > 0) { fullFilename = "Speech/"; if (KickStarter.speechManager.placeAudioInSubfolders) { fullFilename += filename + "/"; } fullFilename += filename + lineID; clipObj = Resources.Load(fullFilename) as AudioClip; } if (clipObj == null) { ACDebug.Log("Cannot find audio file: " + fullFilename); } } else { clipObj = KickStarter.speechManager.GetLineCustomAudioClip(lineID, Options.GetLanguage()); if (clipObj == null && KickStarter.speechManager.fallbackAudio && Options.GetLanguage() > 0) { clipObj = KickStarter.speechManager.GetLineCustomAudioClip(lineID, 0); } } if (clipObj) { AudioSource audioSource = null; if (_speaker != null) { if (!_noAnimation) { if (KickStarter.speechManager.lipSyncMode == LipSyncMode.FaceFX) { FaceFXIntegration.Play(speaker, log.speakerName + lineID, clipObj); } } if (_speaker.speechAudioSource) { audioSource = _speaker.speechAudioSource; if (_speaker.speechAudioSource.GetComponent <Sound>()) { _speaker.speechAudioSource.GetComponent <Sound>().SetVolume(Options.optionsData.speechVolume); } else { _speaker.speechAudioSource.volume = Options.optionsData.speechVolume; } } else { ACDebug.LogWarning(_speaker.name + " has no audio source component!"); } } else if (KickStarter.player && KickStarter.player.speechAudioSource) { KickStarter.player.speechAudioSource.volume = Options.optionsData.speechVolume; audioSource = KickStarter.player.speechAudioSource; } else { audioSource = KickStarter.dialog.GetDefaultAudioSource(); } if (audioSource != null) { audioSource.clip = clipObj; audioSource.loop = false; audioSource.Play(); hasAudio = true; } displayDuration = clipObj.length; } else { displayDuration += KickStarter.speechManager.screenTimeFactor * GetLengthWithoutRichText(_message); displayDuration = Mathf.Max(displayDuration, KickStarter.speechManager.minimumDisplayTime); } } else { displayDuration += KickStarter.speechManager.screenTimeFactor * GetLengthWithoutRichText(_message); displayDuration = Mathf.Max(displayDuration, KickStarter.speechManager.minimumDisplayTime); } log.fullText = _message; KickStarter.eventManager.Call_OnStartSpeech(_speaker, log.fullText, lineID); if (!CanScroll()) { if (continueIndex > 0) { continueTime = (continueIndex / KickStarter.speechManager.textScrollSpeed); } if (speechGaps.Count > 0) { displayText = log.fullText.Substring(0, speechGaps[0].characterIndex); } else { displayText = log.fullText; } } else { displayText = ""; KickStarter.eventManager.Call_OnStartSpeechScroll(_speaker, log.fullText, lineID); } isAlive = true; isSkippable = true; pauseGap = false; endTime = displayDuration; minSkipTime = KickStarter.speechManager.skipThresholdTime; }
protected override void AutoSize() { GUIContent content = new GUIContent(TranslateLabel(label, Options.GetLanguage())); AutoSize(content); }
protected void SetVariable(GVar var, VariableLocation location, bool doSkip) { if (var == null) { return; } switch (var.type) { case 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 && !string.IsNullOrEmpty(parameterName)) { _value = animator.GetInteger(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case 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 && !string.IsNullOrEmpty(parameterName)) { _value = animator.GetFloat(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetFloatValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.Boolean: { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { _value = (int)boolValue; } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && !string.IsNullOrEmpty(parameterName)) { if (animator.GetBool(parameterName)) { _value = 1; } } } var.SetValue(_value, SetVarMethod.SetValue); break; } case VariableType.Vector3: { Vector3 newValue = vector3Value; if (setVarMethodVector == SetVarMethodVector.IncreaseByValue) { newValue += var.vector3Val; } var.SetVector3Value(newValue); break; } case VariableType.PopUp: { int _value = 0; if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else if (setVarMethod == SetVarMethod.SetAsRandom) { _value = var.GetNumPopUpValues(); } else { _value = Mathf.Clamp(intValue, 0, var.GetNumPopUpValues() - 1); } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.String: { string _value = string.Empty; 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 { LogWarning("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetStringValue(_value, lineID); break; } default: break; } var.Upload(location, runtimeVariables); KickStarter.actionListManager.VariableChanged(); }
protected override void AutoSize() { AutoSize(new GUIContent(TranslateLabel(label, Options.GetLanguage()) + " : Default option")); }
/** * <summary>Processes input entered by the player, and applies it to the text box (OnGUI-based Menus only).</summary> * <param name = "keycode">The keycode of the Event that recorded input</param> * <param name = "character">The character of the Event that recorded input</param> * <param name = "shift">If True, shift was held down</param> * <param name = "menuName">The name of the Menu that stores this element</param> */ public void CheckForInput(string keycode, string character, bool shift, string menuName) { if (uiInput != null) { return; } string input = keycode; if (inputType == AC_InputType.AllowSpecialCharacters) { if (!(input == "KeypadEnter" || input == "Return" || input == "Enter" || input == "Backspace")) { input = character; } } bool rightToLeft = KickStarter.runtimeLanguages.LanguageReadsRightToLeft(Options.GetLanguage()); isSelected = true; if (input == "Backspace") { if (label.Length > 1) { if (rightToLeft) { label = label.Substring(1, label.Length - 1); } else { label = label.Substring(0, label.Length - 1); } } else if (label.Length == 1) { label = ""; } } else if (input == "KeypadEnter" || input == "Return" || input == "Enter") { ProcessReturn(input, menuName); } else if ((inputType == AC_InputType.AlphaNumeric && (input.Length == 1 || input.Contains("Alpha"))) || (inputType == AC_InputType.NumbericOnly && input.Contains("Alpha")) || (inputType == AC_InputType.AlphaNumeric && allowSpaces && input == "Space") || (inputType == AC_InputType.AllowSpecialCharacters && (input.Length == 1 || input == "Space"))) { input = input.Replace("Alpha", ""); input = input.Replace("Space", " "); if (inputType != AC_InputType.AllowSpecialCharacters) { if (shift) { input = input.ToUpper(); } else { input = input.ToLower(); } } if (characterLimit == 1) { label = input; } else if (label.Length < characterLimit) { if (rightToLeft) { label = input + label; } else { label += input; } } } }