public void OnSubmit() { string name = nameField.text; Debug.Log("Captain: " + name); PlayerAccountManager pam = PlayerAccountManager.GetInstance(); // Initialize a new player and save it. pam.InitializeNewPlayer(name); pam.SavePlayer(pam.CurrSaveSlot); // Close all the screens and then start loading List <AssetLoadRequestTO> requests = new List <AssetLoadRequestTO>(); AssetLoadRequestTO baseData = AssetLoadRequestTO.CreateMetadataAssetRequest(GameConstants.METADATA_BASE_FILE); requests.Add(baseData); AssetLoadRequestTO ep1 = AssetLoadRequestTO.CreateConversationRequest(GameConstants.EP01); requests.Add(ep1); // load the map csv file. //AssetLoadRequestTO map = AssetLoadRequestTO.CreateMapDataRequest(GameConstants.MAP_1); //requests.Add(map); EventController.GetInstance().RegisterForEvent( EventTypeEnum.AssetsLoadMultipleComplete, OnLoadCompleteEvent); AssetLoader.GetInstance().LoadAssets(requests); }
public void PreloadPortraits() { portraitSprites.Clear(); // Unload the unnecessary assets Resources.UnloadUnusedAssets(); List <AssetLoadRequestTO> requests = new List <AssetLoadRequestTO>(); // Go through all of the nodes and make a list of sheets we need to load. List <ConversationNode> nodes = currConv.nodes; List <string> sheetsToLoad = new List <string>(); for (int i = 0, count = nodes.Count; i < count; i++) { ConversationNode node = nodes[i]; string sheetName = node.spriteSheet; if (!sheetsToLoad.Contains(sheetName)) { sheetsToLoad.Add(sheetName); AssetLoadRequestTO to = AssetLoadRequestTO.CreateSpriteSheetAssetRequest(sheetName); to.callback = OnSpriteSheetLoaded; requests.Add(to); } } sheetsToLoad.Clear(); sheetsToLoad = null; AssetLoader.GetInstance().LoadAssets(requests); }
private void LoadMusic() { AssetLoadRequestTO to = AssetLoadRequestTO.CreateMusicAssetRequest(GameConstants.SONG_TITLE); to.callback = OnMusicLoaded; AssetLoader.GetInstance().LoadAsset(to); }
/// <summary> /// From the TO return a fresh MapData /// </summary> public static MapData FromTO(AssetLoadRequestTO to) { TextAsset textAsset = (TextAsset)to.loadedObject; string[,] tileMapLayout = RawToStringArray(textAsset.text); return(new MapData(tileMapLayout)); }
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); }
public void LoadMetadataFromTO(AssetLoadRequestTO to) { TextAsset textAsset = to.loadedObject as TextAsset; Map = JsonUtility.FromJson <MetadataMap>(textAsset.text); // Debug out all the units parsed into the metadata map Debug.Log(Map.ToString()); }
public void LoadDialogFromTO(AssetLoadRequestTO to) { TextAsset textAsset = (TextAsset)to.loadedObject; StringBuilder sb = new StringBuilder(); sb.Append("{ "); sb.Append("\"nodes\":"); sb.Append(textAsset.text); sb.Append("}"); Conversation conv = JsonUtility.FromJson <Conversation>(sb.ToString()); conv.uid = textAsset.name; // Set this new conversation to the current. currConv = conv; }
public void LoadMapByUID(string uid) { MapInfoVO vo = MetaDataManager.GetInstance().Map.GetVO <MapInfoVO>(uid); List <AssetLoadRequestTO> requests = new List <AssetLoadRequestTO>(); AssetLoadRequestTO mapCSV = AssetLoadRequestTO.CreateMapDataRequest(vo.tileMapCSV); requests.Add(mapCSV); AssetLoadRequestTO mat = AssetLoadRequestTO.CreateMapMaterialRequest(vo.material); requests.Add(mat); EventController.GetInstance().RegisterForEvent( EventTypeEnum.AssetsLoadMultipleComplete, OnLoadCompleteEvent); AssetLoader.GetInstance().LoadAssets(requests); }
// Use this for initialization public void Start() { MusicController.GetInstance().Initialize(); SoundEffectController.GetInstance().Initialize(); List <AssetLoadRequestTO> preloadAssets = new List <AssetLoadRequestTO>(); // Preload some button sound effects AssetLoadRequestTO btnSFX = AssetLoadRequestTO.CreateSoundEffectAssetRequest(GameConstants.SND_BUTTON); preloadAssets.Add(btnSFX); AssetLoadRequestTO escSFX = AssetLoadRequestTO.CreateSoundEffectAssetRequest(GameConstants.SND_MENU); preloadAssets.Add(escSFX); AssetLoader.GetInstance().LoadAssets(preloadAssets); }
/// <summary> /// Upon the sprite sheet being loaded, load all the portrait sprites into /// </summary> /// <param name="to"></param> private void OnSpriteSheetLoaded(AssetLoadRequestTO to) { StringBuilder log = new StringBuilder(); log.Append("Portraits Loaded: \n"); Object[] sprites = to.loadObjectList; for (int i = 0, count = sprites.Length; i < count; i++) { Sprite portrait = sprites[i] as Sprite; if (portrait == null) { continue; } portraitSprites[portrait.name] = portrait; log.Append(portrait.name + "\n"); } Debug.Log(log.ToString()); }
public void LoadCurrMapMaterialFromTO(AssetLoadRequestTO to) { currMapMaterial = (Material)to.loadedObject; }
public void LoadSoundEffectFromTO(AssetLoadRequestTO to) { AudioClip clip = (AudioClip)to.loadedObject; clipMap[clip.name] = clip; }
public void LoadMusicFromTO(AssetLoadRequestTO to) { AudioClip clip = (AudioClip)to.loadedObject; musicMap[clip.name] = clip; }
private void OnMusicLoaded(AssetLoadRequestTO to) { MusicController.GetInstance().TransitionToNewSong(GameConstants.SONG_TITLE); }