private bool loadDeckFromMemory(string deckName) { JsonDeck deck; bool loadSuccess = false; if (playerDeck) { loadSuccess = SaveAndLoadJson.loadStruct(SaveAndLoadJson.getBaseFilePath(playerDecks, deckName), out deck); } else { loadSuccess = SaveAndLoadJson.loadStruct(SaveAndLoadJson.getResourcePath(baddyDecks, deckName), out deck); } if (!loadSuccess) { if (!SaveAndLoadJson.loadStruct(SaveAndLoadJson.getResourcePath(baddyDecks, "errorDeck"), out deck)) { return(false); } } //get card class types from names Type[] cardClasses = new Type[deck.cardTypeName.Length]; for (int i = 0; i < deck.cardTypeName.Length; i++) { cardClasses[i] = Type.GetType(deck.cardTypeName[i]); } addCardsToDeck(cardClasses); return(loadSuccess); }
public void loadDeck(string deckName) { clearDeck(); //TODO add confirmation screen when loading/exiting deck editor JsonDeck deckLoad; if(SaveAndLoadJson.loadStruct( getDeckPath() + "/" + deckName, out deckLoad) == false) { Debug.LogError("selected deck does not exist in " + getDeckPath()); return; } Card c = null; object obj; for(int i = 0; i < deckLoad.cardTypeName.Length; i++) { obj = Activator.CreateInstance(Type.GetType(deckLoad.cardTypeName[i])); if(obj != null) { if(obj is Card) { c = (Card)obj; addCardToDeck(c); continue; } } Debug.LogError("card " + deckLoad.cardTypeName[i]+ " could not be loaded\n" + "check that the card class with that name exists"); } this.deckName.text = deckName; }
private void loadSoundLevels() { SoundLevelsDiskSave loadedLevels; bool fileExists = SaveAndLoadJson.loadStruct(soundFilePath(), out loadedLevels); if (fileExists) { setMusicVolume(loadedLevels.musicLevel); setSfxVolume(loadedLevels.sfxLevel); } }