Example #1
0
        public TopMenu()
        {
            bool inMod = PathMod.Mod != "";
            List <MenuTextChoice> choices = new List <MenuTextChoice>();

            if (DataManager.Instance.Save != null)
            {
                if (DataManager.Instance.Save.Rescue != null)
                {
                    if (DataManager.Instance.Save.Rescue.SOS.RescuingTeam == null)
                    {
                        choices.Add(new MenuTextChoice(Text.FormatKey("MENU_TOP_RESCUE_AWAIT"), () => { MenuManager.Instance.AddMenu(new RescueMenu(), false); }));
                    }
                    else
                    {
                        choices.Add(new MenuTextChoice(Text.FormatKey("MENU_TOP_CONTINUE"), () => { Continue(DataManager.Instance.Save.Rescue.SOS); }));
                    }
                }
                else
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_TOP_CONTINUE"), () => { Continue(null); }));
                }
                if (DataManager.Instance.Save.ActiveTeam.Name != "" && !inMod)
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_TOP_ROGUE"), () => { MenuManager.Instance.AddMenu(new RogueMenu(), false); }));
                }
            }
            else
            {
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_TOP_NEW"), () => { MainStartingMenu.StartFlow(new MonsterID(-1, -1, -1, Gender.Unknown), null, -1); }));
            }


            if (DataManager.Instance.FoundRecords(PathMod.ModSavePath(DataManager.REPLAY_PATH)) || DataManager.Instance.Save != null || RecordHeaderData.LoadHighScores().Count > 0)
            {
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_TOP_RECORD"), () => { MenuManager.Instance.AddMenu(new RecordsMenu(), false); }));
            }
            choices.Add(new MenuTextChoice(Text.FormatKey("MENU_OPTIONS_TITLE"), () => { MenuManager.Instance.AddMenu(new OptionsMenu(), false); }));

            if (!inMod)
            {
                string[] modsPath = Directory.GetDirectories(PathMod.MODS_PATH);
                if (DataManager.Instance.Save != null && modsPath.Length > 0)
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_MODS_TITLE"), () => { MenuManager.Instance.AddMenu(new ModsMenu(), false); }));
                }
            }
            else
            {
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_MODS_EXIT"), exitMod));
            }
            choices.Add(new MenuTextChoice(Text.FormatKey("MENU_QUIT_GAME"), exitGame));

            Initialize(new Loc(16, 16), CalculateChoiceLength(choices, 72), choices.ToArray(), 0);

            titleMenu = new SummaryMenu(Rect.FromPoints(new Loc(Bounds.End.X + 16, 16), new Loc(GraphicsManager.ScreenWidth - 16, 16 + LINE_SPACE + GraphicsManager.MenuBG.TileHeight * 2)));
            MenuText title = new MenuText(Path.GetFileName(PathMod.Mod), new Loc((titleMenu.Bounds.X + titleMenu.Bounds.End.X) / 2, titleMenu.Bounds.Y + GraphicsManager.MenuBG.TileHeight), DirH.None);

            titleMenu.Elements.Add(title);
        }
Example #2
0
        public RecordsMenu()
        {
            List <MenuTextChoice> choices = new List <MenuTextChoice>();

            if (DataManager.Instance.FoundRecords(PathMod.ModSavePath(DataManager.REPLAY_PATH)))
            {
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_REPLAYS_TITLE"), () => { MenuManager.Instance.AddMenu(new ReplaysMenu(), false); }));
            }
            Dictionary <int, List <RecordHeaderData> > scores = RecordHeaderData.LoadHighScores();

            if (scores.Count > 0)
            {
                int minDungeon = DataManager.Instance.DataIndices[DataManager.DataType.Zone].Count;
                foreach (int key in scores.Keys)
                {
                    if (key < minDungeon)
                    {
                        minDungeon = key;
                    }
                }
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_SCORES_TITLE"), () => { MenuManager.Instance.AddMenu(new ScoreMenu(scores, minDungeon, null), false); }));
            }

            if (DataManager.Instance.Save != null)
            {
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_DEX_TITLE"), () => { MenuManager.Instance.AddMenu(new DexMenu(), false); }));
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_DELETE_SAVE_TITLE"), DeleteAction));
            }

            Initialize(new Loc(16, 16), CalculateChoiceLength(choices, 72), choices.ToArray(), 0);
        }
Example #3
0
        public ReplaysMenu()
        {
            List <RecordHeaderData> records = DataManager.Instance.GetRecordHeaders(PathMod.ModSavePath(DataManager.REPLAY_PATH), DataManager.REPLAY_EXTENSION);

            List <MenuChoice> flatChoices = new List <MenuChoice>();

            foreach (RecordHeaderData record in records)
            {
                string fileName = Path.GetFileNameWithoutExtension(record.Path);
                if (record.Name != "")
                {
                    string rogueSign = "";
                    if (record.Result == GameProgress.ResultType.Escaped || record.Result == GameProgress.ResultType.Cleared)
                    {
                        rogueSign += "\uE10A";
                    }
                    else
                    {
                        rogueSign += "\uE10B";
                    }
                    if (record.IsRogue)
                    {
                        if (record.IsSeeded)
                        {
                            rogueSign += "\uE10D";
                        }
                        else
                        {
                            rogueSign += "\uE10C";
                        }
                    }

                    //also include an indicator of the floors traversed, if possible
                    flatChoices.Add(new MenuTextChoice(rogueSign + record.Name + ": " + record.LocationString, () => { choose(record.Path); }));
                }
                else
                {
                    flatChoices.Add(new MenuTextChoice(fileName, () => { choose(record.Path); }));
                }
            }
            List <MenuChoice[]> choices = SortIntoPages(flatChoices, SLOTS_PER_PAGE);

            //for the summary menu, include team, date, filename, location (string), seed, indication of rogue and seeded runs
            //if it can't be read, just include the filename

            Initialize(new Loc(0, 0), 240, Text.FormatKey("MENU_REPLAYS_TITLE"), choices.ToArray(), 0, 0, SLOTS_PER_PAGE);
        }
        private void DeleteAction()
        {
            if (File.Exists(recordDir))
            {
                File.Delete(recordDir);
            }

            MenuManager.Instance.RemoveMenu();

            if (DataManager.Instance.FoundRecords(PathMod.ModSavePath(DataManager.REPLAY_PATH)))
            {
                MenuManager.Instance.ReplaceMenu(new ReplaysMenu());
            }
            else
            {
                MenuManager.Instance.RemoveMenu();
                MenuManager.Instance.ReplaceMenu(new TopMenu());
            }
        }
Example #5
0
        public override IEnumerator <YieldInstruction> BeginGame(int zoneID, ulong seed, DungeonStakes stakes, bool recorded, bool noRestrict)
        {
            ZoneData zone = DataManager.Instance.GetZone(zoneID);

            //restrict team size/bag size/etc
            if (!noRestrict)
            {
                yield return(CoroutineManager.Instance.StartCoroutine(RestrictTeam(zone, false)));
            }

            MidAdventure = true;
            Stakes       = stakes;
            //create a copy (from save and load) of the current state and mark it with loss
            DataManager.Instance.SaveMainGameState();

            GameState state = DataManager.Instance.LoadMainGameState();

            if (state != null)
            {
                if (Stakes == DungeonStakes.Risk)
                {
                    LossPenalty(state.Save);
                }

                DataManager.Instance.SaveGameState(state);
            }

            //set everyone's levels and mark them for backreferral
            if (!noRestrict)
            {
                yield return(CoroutineManager.Instance.StartCoroutine(RestrictLevel(zone, false)));
            }

            RestartLogs(seed);
            RescuesLeft = zone.Rescues;

            if (recorded)
            {
                DataManager.Instance.BeginPlay(PathMod.ModSavePath(DataManager.SAVE_PATH, DataManager.QUICKSAVE_FILE_PATH), zoneID, false, false);
            }
        }
Example #6
0
        public static void Continue(SOSMail rescueMail)
        {
            //check for presence of a main save-quicksave
            ReplayData replay    = null;
            string     recordDir = PathMod.ModSavePath(DataManager.SAVE_PATH, DataManager.QUICKSAVE_FILE_PATH);

            if (File.Exists(recordDir))
            {
                replay = DataManager.Instance.LoadReplay(recordDir, true);
                if (replay == null)
                {
                    cannotRead(recordDir);
                    return;
                }
            }
            if (replay != null)
            {
                MenuManager.Instance.ClearMenus();
                GameManager.Instance.SceneOutcome = continueReplay(replay, rescueMail);
                return;
            }

            //then, we should load a main save instead
            GameState state = DataManager.Instance.LoadMainGameState();

            if (state == null)
            {
                cannotRead(DataManager.SAVE_PATH + DataManager.SAVE_FILE_PATH);
                return;
            }
            if (state.Save.Rescue != null)
            {
                state.Save.Rescue = null;
                DataManager.Instance.SaveGameState(state);
            }
            MenuManager.Instance.ClearMenus();
            GameManager.Instance.SceneOutcome = continueMain(state);
        }
        /// <summary>
        /// Generate all high score tables in real time, organized by dungeon, by going through all replays
        /// </summary>
        /// <returns></returns>
        public static Dictionary <int, List <RecordHeaderData> > LoadHighScores()
        {
            Dictionary <int, List <RecordHeaderData> > highScores = new Dictionary <int, List <RecordHeaderData> >();

            List <RecordHeaderData> records = DataManager.Instance.GetRecordHeaders(PathMod.ModSavePath(DataManager.REPLAY_PATH), DataManager.REPLAY_EXTENSION);

            foreach (RecordHeaderData record in records)
            {
                if (record.IsRogue && !record.IsSeeded)
                {
                    if (!highScores.ContainsKey(record.Zone))
                    {
                        highScores[record.Zone] = new List <RecordHeaderData>();
                    }

                    List <RecordHeaderData> dungeonHighScore = highScores[record.Zone];

                    int placing = 0;
                    for (int ii = 0; ii < dungeonHighScore.Count; ii++)
                    {
                        if (dungeonHighScore[ii].Score <= record.Score)
                        {
                            break;
                        }
                        placing++;
                    }
                    dungeonHighScore.Insert(placing, record);
                    if (dungeonHighScore.Count > RecordHeaderData.MAX_HIGH_SCORES)
                    {
                        dungeonHighScore.RemoveRange(RecordHeaderData.MAX_HIGH_SCORES, dungeonHighScore.Count - RecordHeaderData.MAX_HIGH_SCORES);
                    }
                }
            }

            return(highScores);
        }
Example #8
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.GetColoredName();
                }
                else if (GameManager.Instance.CurrentScene == DungeonScene.Instance)
                {
                    Location = ZoneManager.Instance.CurrentMap.GetColoredName();
                }

                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(PathMod.ModSavePath(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, PathMod.ModSavePath(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.GetDisplayName();

                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(PathMod.ModSavePath(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, PathMod.ModSavePath(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;
                    DialogueBox 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))
                            {
                                if (character.EquippedItem.ID > -1)
                                {
                                    mainSave.ItemsToStore.Add(character.EquippedItem);
                                }
                                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));
            }
        }
Example #9
0
        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.GetDisplayName();

                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(PathMod.ModSavePath(DataManager.REPLAY_PATH, recordFile), false);
                AOKMail    aok         = new AOKMail(sos, DataManager.Instance.Save, dateRescued, replay);
                GeneratedAOK = DataManager.SaveRescueMail(PathMod.NoMod(DataManager.RESCUE_OUT_PATH + DataManager.AOK_FOLDER), aok, false);
                string deletePath = DataManager.FindRescueMail(PathMod.NoMod(DataManager.RESCUE_IN_PATH + DataManager.SOS_FOLDER), 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.GetColoredName();
                }
                else if (GameManager.Instance.CurrentScene == DungeonScene.Instance)
                {
                    Location = ZoneManager.Instance.CurrentMap.GetColoredName();
                }

                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.GetDisplayName();

                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.EnumerateChars())
            {
                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()));

            GameState    state    = DataManager.Instance.LoadMainGameState();
            MainProgress mainSave = state?.Save as MainProgress;

            //save the result to the main file
            if (Stakes != DungeonStakes.None)
            {
                if (mainSave != null)
                {
                    mainSave.MergeDataTo(this);
                }
                DataManager.Instance.SaveMainGameState();
            }
            else
            {
                if (mainSave != null)
                {
                    DataManager.Instance.SetProgress(mainSave);
                }
                DataManager.Instance.Save.NextDest = NextDest;
            }

            MenuBase.Transparent = false;

            if (recorded && display)
            {
                GameProgress ending = DataManager.Instance.GetRecord(PathMod.ModSavePath(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));
        }