// Called at initialization, create a key/value structure for CardData, the key being the English name (user-friendly) // This is done to avoid calling Localize too often, I don't know how expensive this method is. // Also useful to lowercase the card's name, since our art files could be store on a case-ignorant filesystem public void IndexCardData() { // Logger.LogInfo("indexing card data"); AllGameData agd = ProviderManager.SaveManager.GetAllGameData(); List <CardData> themDatas = AccessTools.Field(typeof(AllGameData), "cardDatas").GetValue(agd) as List <CardData>; for (int i = 0; i < themDatas.Count; i++) { var key = themDatas[i].GetNameEnglish().ToLower(); if (!this.cardDataByEnglishNames.ContainsKey(key)) { // Some cards have multiple instances with the same name, such as Blazing Bolts // So we're going to store a list of CardData for each name // Logger.LogInfo($"{i}: indexing card data for '{key}'"); var cdl = new List <CardData>(); cdl.Add(themDatas[i]); this.cardDataByEnglishNames.Add(key, cdl); } else { // Logger.LogInfo($"{i}: indexing alternate card data for '{key}'"); this.cardDataByEnglishNames[key].Add(themDatas[i]); } } // Logger.LogInfo($"indexed: {this.cardDataByEnglishNames.Count} cards"); }
public void NewProviderAvailable(IProvider newProvider) { //Get Reference to SaveManager when Initialized if (DepInjector.MapProvider <SaveManager>(newProvider, ref this.currentSave)) { //Subscribe to receive Deck Notifications currentSave.AddDeckNotifications(this); data = currentSave.GetAllGameData(); this.Logger.LogInfo("SaveManager Initialized"); InitializeCardDataBase(); this.Logger.LogInfo("Relic Manager Initialized"); InitializeRelicDataBase(); IsInit = false; } //Get Reference to GameStateManager When Initialized if (DepInjector.MapProvider <GameStateManager>(newProvider, ref this.Game)) { //Subscribe listener to Signal Game.runStartedSignal.AddListener(GameStartedListener); } if (DepInjector.MapProvider <RelicManager>(newProvider, ref this.relicManager)) { relicManager.AddRelicNotifications(this); } }
private void SerializeFromTmpArrays() { allData = new AllGameData(game, players, enemies, quests, pickUps, pickUpsSpells, doors, isGameStarted); using (FileStream fs = new FileStream(Application.persistentDataPath + "\\Saves\\fastSave.dat", FileMode.Create)) { new BinaryFormatter().Serialize(fs, allData); } //Debug.Log(Application.persistentDataPath + "\\fastSave.dat"); }
private void DeserializeToTmpArrays() { using (FileStream fs = new FileStream(Application.persistentDataPath + "\\Saves\\fastSave.dat", FileMode.Open)) { allData = (AllGameData) new BinaryFormatter().Deserialize(fs); } }