public void MergeDataTo(MainProgress destProgress) { if (this != destProgress) { MergeDexTo(destProgress); } foreach (CharData charData in CharsToStore) { destProgress.ActiveTeam.Assembly.Add(new Character(charData, ActiveTeam, new Loc(), Dir8.Down)); } CharsToStore.Clear(); destProgress.ActiveTeam.StoreItems(ItemsToStore); ItemsToStore.Clear(); //just add storage values for (int ii = 0; ii < StorageToStore.Length; ii++) { destProgress.ActiveTeam.Storage[ii] += StorageToStore[ii]; StorageToStore[ii] = 0; } //put the money in the bank destProgress.ActiveTeam.Bank += MoneyToStore; MoneyToStore = 0; }
public void MergeDataTo(MainProgress destProgress) { if (this != destProgress) { MergeDexTo(destProgress); } foreach (CharData charData in CharsToStore) { Character chara = new Character(charData, ActiveTeam); AITactic tactic = DataManager.Instance.GetAITactic(0); chara.Tactic = new AITactic(tactic); destProgress.ActiveTeam.Assembly.Add(chara); } CharsToStore.Clear(); destProgress.ActiveTeam.StoreItems(ItemsToStore); ItemsToStore.Clear(); //just add storage values for (int ii = 0; ii < StorageToStore.Length; ii++) { destProgress.ActiveTeam.Storage[ii] += StorageToStore[ii]; StorageToStore[ii] = 0; } //put the money in the bank destProgress.ActiveTeam.Bank += MoneyToStore; MoneyToStore = 0; }
public override IEnumerator <YieldInstruction> EndGame(ResultType result, ZoneLoc nextArea, bool display, bool fanfare) { bool recorded = DataManager.Instance.RecordingReplay; //if lose, end the play, display plaque, and go to title if (result != ResultType.Cleared) { if (GameManager.Instance.CurrentScene == GroundScene.Instance) { Location = ZoneManager.Instance.CurrentGround.GetSingleLineName(); } else if (GameManager.Instance.CurrentScene == DungeonScene.Instance) { Location = ZoneManager.Instance.CurrentMap.GetSingleLineName(); } Outcome = result; DataManager.Instance.MsgLog.Clear(); //end the game with a recorded ending string recordFile = DataManager.Instance.EndPlay(this, null); MenuBase.Transparent = false; //save to the main file GameState state = DataManager.Instance.LoadMainGameState(); List <int> newRecruits = new List <int>(); if (state != null) { newRecruits = MergeDexTo(state.Save); DataManager.Instance.SaveGameState(state); } if (recorded && display) { GameProgress ending = DataManager.Instance.GetRecord(Data.DataManager.REPLAY_PATH + recordFile); if (fanfare) { if (result != ResultType.Cleared) { GameManager.Instance.Fanfare("Fanfare/MissionFail"); } else { GameManager.Instance.Fanfare("Fanfare/MissionClear"); } } else { GameManager.Instance.SE("Menu/Skip"); } FinalResultsMenu menu = new FinalResultsMenu(ending); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(menu))); Dictionary <int, List <RecordHeaderData> > scores = RecordHeaderData.LoadHighScores(); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new ScoreMenu(scores, ZoneManager.Instance.CurrentZoneID, DataManager.REPLAY_PATH + recordFile)))); } if (newRecruits.Count > 0) { yield return(new WaitForFrames(10)); GameManager.Instance.Fanfare("Fanfare/NewArea"); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("DLG_NEW_CHARS")))); } yield return(new WaitForFrames(20)); GameManager.Instance.SceneOutcome = GameManager.Instance.RestartToTitle(); } else { int completedZone = ZoneManager.Instance.CurrentZoneID; MidAdventure = true; ClearDungeonItems(); // if there isn't a next area, end the play, display the plaque, return to title screen //GameManager.Instance.Fanfare("Fanfare/MissionClear"); Location = ZoneManager.Instance.CurrentZone.Name.ToLocal(); Outcome = result; DataManager.Instance.MsgLog.Clear(); //end the game with a recorded ending string recordFile = DataManager.Instance.EndPlay(this, null); MenuBase.Transparent = false; //save to the main file GameState state = DataManager.Instance.LoadMainGameState(); if (state != null) { MergeDexTo(state.Save); state.Save.DungeonUnlocks[completedZone] = UnlockState.Completed; DataManager.Instance.SaveGameState(state); } if (recorded) { GameProgress ending = DataManager.Instance.GetRecord(DataManager.REPLAY_PATH + recordFile); if (fanfare) { if (result != ResultType.Cleared) { GameManager.Instance.Fanfare("Fanfare/MissionFail"); } else { GameManager.Instance.Fanfare("Fanfare/MissionClear"); } } else { GameManager.Instance.SE("Menu/Skip"); } FinalResultsMenu menu = new FinalResultsMenu(ending); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(menu))); Dictionary <int, List <RecordHeaderData> > scores = RecordHeaderData.LoadHighScores(); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new ScoreMenu(scores, ZoneManager.Instance.CurrentZoneID, DataManager.REPLAY_PATH + recordFile)))); } //ask to transfer if the dungeon records progress, and it is NOT a seeded run. if (state != null && Stakes != DungeonStakes.None && !Seeded) { bool allowTransfer = false; QuestionDialog question = MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_TRANSFER_ASK"), () => { allowTransfer = true; }, () => { }); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(question))); if (allowTransfer) { MainProgress mainSave = state.Save as MainProgress; //put the new recruits into assembly foreach (Character character in ActiveTeam.Players) { if (!(character.Dead && DataManager.Instance.GetSkin(character.BaseForm.Skin).Challenge)) { mainSave.CharsToStore.Add(new CharData(character)); } } foreach (Character character in ActiveTeam.Assembly) { if (!(character.Dead && DataManager.Instance.GetSkin(character.BaseForm.Skin).Challenge)) { mainSave.CharsToStore.Add(new CharData(character)); } } //put the new items into the storage foreach (InvItem item in ActiveTeam.EnumerateInv()) { mainSave.ItemsToStore.Add(item); } foreach (InvItem item in ActiveTeam.BoxStorage) { mainSave.ItemsToStore.Add(item); } mainSave.StorageToStore = ActiveTeam.Storage; mainSave.MoneyToStore = state.Save.ActiveTeam.Money + state.Save.ActiveTeam.Bank; } DataManager.Instance.SaveGameState(state); if (allowTransfer) { yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("DLG_TRANSFER_COMPLETE")))); } } yield return(new WaitForFrames(20)); } }
public override IEnumerator <YieldInstruction> EndGame(ResultType result, ZoneLoc nextArea, bool display, bool fanfare) { Outcome = result; bool recorded = DataManager.Instance.RecordingReplay; string recordFile = null; if (result == ResultType.Rescue) { Location = ZoneManager.Instance.CurrentZone.Name.ToLocal(); DataManager.Instance.MsgLog.Clear(); //end the game with a recorded ending recordFile = DataManager.Instance.EndPlay(this, StartDate); SOSMail sos = Rescue.SOS; string dateRescued = String.Format("{0:yyyy-MM-dd}", DateTime.Now); ReplayData replay = DataManager.Instance.LoadReplay(DataManager.REPLAY_PATH + recordFile, false); AOKMail aok = new AOKMail(sos, DataManager.Instance.Save, dateRescued, replay); GeneratedAOK = DataManager.SaveRescueMail(DataManager.RESCUE_OUT_PATH + DataManager.AOK_PATH, aok, false); string deletePath = DataManager.FindRescueMail(DataManager.RESCUE_IN_PATH + DataManager.SOS_PATH, sos, sos.Extension); if (deletePath != null) { File.Delete(deletePath); } if (nextArea.IsValid()) // if an exit is specified, go to the exit. { NextDest = nextArea; } else { NextDest = new ZoneLoc(1, new SegLoc(-1, 1)); } } else if (result != ResultType.Cleared) { if (GameManager.Instance.CurrentScene == GroundScene.Instance) { Location = ZoneManager.Instance.CurrentGround.GetSingleLineName(); } else if (GameManager.Instance.CurrentScene == DungeonScene.Instance) { Location = ZoneManager.Instance.CurrentMap.GetSingleLineName(); } DataManager.Instance.MsgLog.Clear(); //end the game with a recorded ending recordFile = DataManager.Instance.EndPlay(this, StartDate); if (Outcome != ResultType.Escaped && Stakes == DungeonStakes.Risk) //remove all items { LossPenalty(this); } if (nextArea.IsValid()) // if an exit is specified, go to the exit. { NextDest = nextArea; } else { NextDest = new ZoneLoc(1, new SegLoc(-1, 1)); } } else { int completedZone = ZoneManager.Instance.CurrentZoneID; DungeonUnlocks[completedZone] = UnlockState.Completed; Location = ZoneManager.Instance.CurrentZone.Name.ToLocal(); DataManager.Instance.MsgLog.Clear(); //end the game with a recorded ending recordFile = DataManager.Instance.EndPlay(this, StartDate); if (nextArea.IsValid()) // if an exit is specified, go to the exit. { NextDest = nextArea; } else { NextDest = new ZoneLoc(1, new SegLoc(-1, 1)); } } TotalAdventures++; foreach (Character character in ActiveTeam.Players) { character.Dead = false; character.FullRestore(); } foreach (Character character in ActiveTeam.Assembly) { character.Dead = false; character.FullRestore(); } MidAdventure = false; ClearDungeonItems(); //clear rescue status Rescue = null; //merge back the team if the dungeon was level-limited yield return(CoroutineManager.Instance.StartCoroutine(RestoreLevel())); //save the result to the main file if (Stakes != DungeonStakes.None) { GameState state = DataManager.Instance.LoadMainGameState(); MainProgress mainSave = state.Save as MainProgress; mainSave.MergeDataTo(this); DataManager.Instance.SaveMainGameState(); } else { GameState state = DataManager.Instance.LoadMainGameState(); MainProgress mainSave = state.Save as MainProgress; mainSave.MergeDataTo(mainSave); DataManager.Instance.SetProgress(state.Save); DataManager.Instance.Save.NextDest = NextDest; } MenuBase.Transparent = false; if (recorded && display) { GameProgress ending = DataManager.Instance.GetRecord(DataManager.REPLAY_PATH + recordFile); if (fanfare) { if (result != ResultType.Cleared && result != ResultType.Escaped && result != ResultType.Rescue) { GameManager.Instance.Fanfare("Fanfare/MissionFail"); } else { GameManager.Instance.Fanfare("Fanfare/MissionClear"); } } else { GameManager.Instance.SE("Menu/Skip"); } FinalResultsMenu menu = new FinalResultsMenu(ending); yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(menu))); } yield return(new WaitForFrames(20)); }