/// <summary> /// Iterate through the space delimited string to figure out what /// parameter modifiers need to be applied after viewing a conversation node /// </summary> private void ProcessParams() { // Split it up string[] paramSplit = displayBody.Split(PARAM_DELIM.ToCharArray()); displayBody = paramSplit[0]; // If we don't enough pieces that means we don't have have a param mod if (paramSplit.Length < 2) { return; } paramMods = new List <ConversationParamModifier>(); // Iterate through the pieces try to parse the param mods for (int i = 1, count = paramSplit.Length; i < count; i++) { string rawPMod = paramSplit[i]; if (string.IsNullOrEmpty(rawPMod)) { continue; } ConversationParamModifier pMod = new ConversationParamModifier(rawPMod); paramMods.Add(pMod); } }
public void PreloadMusic() { List <AssetLoadRequestTO> requests = new List <AssetLoadRequestTO>(); List <string> songsToLoad = new List <string>(); List <ConversationNode> nodes = currConv.nodes; // Iterate through the conversation nodes and check to see if we need to // preload any new songs for (int i = 0, count = nodes.Count; i < count; i++) { ConversationNode node = nodes[i]; List <ConversationParamModifier> paramMods = node.paramMods; // if there are no param modifiers then no need to preload any music if (paramMods == null) { continue; } // iterate through the param mods and check for songs to preload for (int j = 0, jCount = paramMods.Count; j < jCount; j++) { ConversationParamModifier mod = paramMods[j]; // Not a music parameter then skip it if (!ParameterModifierUtils.IsMusicParameter(mod.paramName)) { continue; } string songName = mod.strValue; // If it's an empty fade out music param then skip if (string.IsNullOrEmpty(songName)) { continue; } // If we already queued it up to load then no need to double add it. if (songsToLoad.Contains(songName)) { continue; } // We got a new song to load so create a new TO requests.Add(AssetLoadRequestTO.CreateMusicAssetRequest(songName)); songsToLoad.Add(songName); } } songsToLoad.Clear(); songsToLoad = null; AssetLoader.GetInstance().LoadAssets(requests); }
private void ApplyParamModifiers(ConversationNode node) { if (node.paramMods == null || node.paramMods.Count < 1) { return; } PlayerAccountManager pm = PlayerAccountManager.GetInstance(); Player player = pm.GetPlayer(); for (int i = 0, count = node.paramMods.Count; i < count; i++) { ConversationParamModifier mod = node.paramMods[i]; // If it's a music parameter then play the transition if (ParameterModifierUtils.IsMusicParameter(mod.paramName)) { if (mod.paramName == MusicController.DIALOG_PARAM_MUSIC_FADEIN) { MusicController.GetInstance().TransitionToNewSong(mod.strValue); } if (mod.paramName == MusicController.DIALOG_PARAM_MUSIC_FADEOUT) { MusicController.GetInstance().FadeOutCurrentSong(); } continue; } if (ParameterModifierUtils.IsScreenParameter(mod.paramName)) { if (mod.paramName == PMOD_SCREEN_QUEUE) { GameObject MainMenu = GameObject.Find(GameConstants.UI_MAIN_MENU); GameObject screen = UIFactory.CreateScreen(mod.strValue, MainMenu); ScreenQueueManager.GetInstance().QueueScreen(screen); } continue; } if (ParameterModifierUtils.IsMapParameter(mod.paramName)) { // Preload a map if (mod.paramName == PMOD_MAP_PRELOAD) { MapController.GetInstance().LoadMapByUID(mod.strValue); } if (mod.paramName == PMOD_MAP_SHOW) { MapController.GetInstance().ShowMap(); } continue; } // Set the string or integer to the given value. if (mod.action == ConversationParamModifier.ModifierActionType.Set) { if (mod.type == ConversationParamModifier.ModifierType.Integer) { player.SetValue <int>(mod.paramName, mod.intValue); } else { player.SetValue <string>(mod.paramName, mod.strValue); } continue; } if (mod.action == ConversationParamModifier.ModifierActionType.Increment) { player.IncrementValue(mod.paramName, mod.intValue); continue; } if (mod.action == ConversationParamModifier.ModifierActionType.Decrement) { player.IncrementValue(mod.paramName, -mod.intValue); continue; } } // Save the player progress at this point. pm.AutoSavePlayerToCurrentSlot(); }