Ejemplo n.º 1
0
 public void set_mode(Difficulty_Modes difficulty, bool arrowsVisible)
 {
     // Mode
     Mode.text = difficulty.ToString();// == Difficulty_Modes.Hard ? "Hard" : "Normal"; //Yeti
     // Arrows
     Left_Arrow.visible = Right_Arrow.visible = arrowsVisible;
 }
Ejemplo n.º 2
0
        protected virtual void RefreshData(bool resetData = true)
        {
            if (resetData)
            {
                MenuData.RefreshPreviousChapters(MenuData.ChapterId);
            }

            Difficulty_Modes difficulty = Global.game_system != null ?
                                          Global.game_system.Difficulty_Mode : Difficulty_Modes.Normal;

            TactileLibrary.Preset_Chapter_Data chapterData;

            if (Global.chapter_by_index(this.Redirect).Standalone ||
                MenuData.ValidPreviousChapters.Count == 0)
            {
                Global.game_system     = new Game_System();
                Global.game_battalions = new Game_Battalions();
                Global.game_actors     = new Game_Actors();

                chapterData = Global.chapter_by_index(this.Redirect).Preset_Data;
            }
            else
            {
                LoadData();
                Global.game_battalions.current_battalion =
                    Global.chapter_by_index(this.Redirect).Battalion;
                Global.game_actors.heal_battalion();
                // Not sure why this happens //Yeti
                // what conflicts are caused by using the loaded system //Yeti
                var system = Global.game_system;
                Global.game_system = system.copy();
                // For now, setting the event data so it shows up in the monitor //Yeti
                Global.game_system.set_event_data(system.SWITCHES, system.VARIABLES);

                chapterData = new TactileLibrary.Preset_Chapter_Data
                {
                    Lord_Lvl = Global.game_actors[Global.chapter_by_index(this.Redirect).World_Map_Lord_Id].level,
                    Units    = Global.chapter_by_index(this.Redirect).Preset_Data.Units + Global.battalion.actors.Count,
                    Gold     = Global.chapter_by_index(this.Redirect).Preset_Data.Gold + Global.battalion.gold,
                    Playtime = system.total_play_time
                };
            }

            DataWindow.set(
                Global.chapter_by_index(this.Redirect).ShortName,
                Global.chapter_by_index(this.Redirect).World_Map_Lord_Id,
                chapterData);

            Global.game_system.Difficulty_Mode = difficulty;

            UnitWindowAvailable = Global.game_system.Style != Mode_Styles.Classic &&
                                  Global.battalion != null && Global.battalion.actors.Any();
            // Block ranking window if this chapter is unranked
            RankingWindowAvailable =
                !Global.data_chapters[MenuData.ChapterId].Unranked &&
                Global.save_file.ContainsKey(MenuData.ChapterId);

            RefreshInputHelp();
            RefreshPreviousChapterSelected();
        }
Ejemplo n.º 3
0
        protected virtual void start_chapter(Data_Chapter chapter,
                                             Dictionary <string, string> selectedPreviousChapters)
        {
            Difficulty_Modes difficulty = Global.game_system.Difficulty_Mode;
            var validPreviousChapters   =
                Global.save_file.valid_previous_chapters(chapter.Id);

            if (chapter.Standalone && validPreviousChapters.Count == 0)
            {
                Global.game_system.reset();
                Global.game_system.reset_event_variables();
                //Event_Processor.reset_variables(); //Debug
                int battalion_index = chapter.Battalion;
                Global.game_battalions.add_battalion(battalion_index);
                Global.game_battalions.current_battalion = battalion_index;
            }
            else
            {
                WorldmapLoadData(chapter.Id, selectedPreviousChapters);
                Global.game_actors.heal_battalion();
                Global.battalion.refresh_deployed();
            }
            Global.game_system.Difficulty_Mode = difficulty;
            //if (Global.game_system.Style != Mode_Styles.Classic) // Save file is about to be set to null //Debug
            //    Global.save_file.Difficulty = Global.game_system.Difficulty_Mode;

            Global.game_system.New_Chapter_Id = chapter.Id;
            Global.game_system.new_chapter(chapter.Prior_Chapters, chapter.Id, selectedPreviousChapters);
            Global.game_temp = new Game_Temp();
            Global.current_save_info.SetStartedChapter(chapter.Id);
            Global.save_file = null;
            Global.scene_change("Start_Chapter");
        }
Ejemplo n.º 4
0
        public Game_Ranking(string chapter_id, Difficulty_Modes difficulty, DataRanking ranking)
        {
            ChapterId  = chapter_id;
            Difficulty = difficulty;

            Data = ranking;
            Data.set_par(this.chapter_data);
        }
Ejemplo n.º 5
0
        public static Save_Data read(BinaryReader reader)
        {
            Save_Data result = new Save_Data();

            if (!Global.LOADED_VERSION.older_than(0, 4, 3, 0))
            {
                result.Time = DateTime.FromBinary(reader.ReadInt64());
            }
            result.Chapter_Id     = reader.ReadString();
            result.Progression_Id = reader.ReadString();
            result.System         = new Game_System();
            result.System.read(reader);
            if (Global.LOADED_VERSION.older_than(0, 4, 0, 4))
            {
                List <string> previous_chapters = Global.data_chapters[result.Chapter_Id].Prior_Chapters;
                result.System.previous_chapters.AddRange(previous_chapters);
            }
            result.Battalions = new Game_Battalions();
            result.Battalions.read(reader);
            if (Global.LOADED_VERSION.older_than(0, 5, 3, 1))
            {
                if (Global.data_chapters.ContainsKey(result.Chapter_Id))
                {
                    // Correct battalion id
                    result.Battalions.correct_battalion_id(
                        Global.data_chapters[result.Chapter_Id]);
                }
            }


            result.Actors = new Game_Actors();
            result.Actors.read(reader);
            result.Switches = Event_Variable_Data <bool> .read(reader);

            //result.Switches = new bool[Config.EVENT_DATA_LENGTH]; //Debug
            //result.Switches = result.Switches.read(reader);
            result.Variables = Event_Variable_Data <int> .read(reader);

            //result.Variables = new int[Config.EVENT_DATA_LENGTH];
            //result.Variables = result.Variables.read(reader);
            result.Ranking = Game_Ranking.read(reader);
            if (!Global.LOADED_VERSION.older_than(0, 4, 4, 0))
            {
                result.Past_Rankings = PastRankings.read(reader, result.System.Difficulty_Mode);
            }
            else
            {
                result.Past_Rankings = new PastRankings();
            }
            // If this save predates storing difficulty in the ranking object
            if (Global.LOADED_VERSION.older_than(0, 6, 1, 1))
            {
                Difficulty_Modes difficulty = result.System.Difficulty_Mode;
                result.Ranking = new Game_Ranking(result.Ranking, difficulty);
            }

            return(result);
        }
Ejemplo n.º 6
0
 public Save_Info(Save_Info info)
 {
     File_Id           = info.File_Id;
     Time              = info.Time;
     Chapter_Id        = info.Chapter_Id;
     Difficulty        = info.Difficulty;
     Style             = info.Style;
     Map_Save_Exists   = info.Map_Save_Exists;
     Suspend_Exists    = info.Suspend_Exists;
     AvailableChapters = new List <string>(info.AvailableChapters);
 }
Ejemplo n.º 7
0
 internal void refresh_rank(Difficulty_Modes mode)
 {
     if (Difficulty.IsNothing || mode == Difficulty)
     {
         Rank.SetColor(Global.Content, "Yellow");
     }
     else
     {
         Rank.SetColor(Global.Content, "Grey");
     }
 }
Ejemplo n.º 8
0
        public void UnitEditorMapMenuPlaytest()
        {
            string chapter_id, map_data_key, unit_data_key, event_data_key;
            bool   valid_map_data = get_map_data(
                out chapter_id, out map_data_key, out unit_data_key, out event_data_key);

            if (valid_map_data)
            {
                Global.game_system.play_se(System_Sounds.Confirm);

                Difficulty_Modes difficulty = Global.game_system.Difficulty_Mode;
                Global.game_system                 = new Game_System();
                Global.game_battalions             = new Game_Battalions();
                Global.game_actors                 = new Game_Actors();
                Global.game_system.Difficulty_Mode = difficulty;

                // Switch to the best fit save file
                Global.game_system.New_Chapter_Id = chapter_id;
                Global.current_save_id            = -1;
                if (Global.save_files_info != null)
                {
                    var matching_files = Global.save_files_info
                                         .Where(x => x.Value.chapter_available(
                                                    Global.game_system.New_Chapter_Id));
                    matching_files = matching_files.ToList();

                    if (matching_files.Any())
                    {
                        Global.current_save_id = matching_files
                                                 .OrderBy(x => x.Key)
                                                 .First()
                                                 .Key;
                    }
                }

                // Failed to find a save
                if (Global.current_save_id < 0)
                {
                    Global.current_save_id = 1;
                }

                Global.scene_change("Scene_Map_Playtest");
                Global.game_temp.menuing = false;
                MapMenu = null;
            }
            else
            {
                Global.game_system.play_se(System_Sounds.Buzzer);
            }
        }
Ejemplo n.º 9
0
        public WindowRankingsOverview(string chapter, Difficulty_Modes difficulty)
        {
            Chapter    = chapter;
            Difficulty = difficulty;

            initialize_sprites();
            update_black_screen();

            // Jump to chapter
            int index = Rankings.FindIndex(x => x.Key == chapter);

            Nodes.set_active_node(Nodes[index]);
            Cursor.UpdateTargetLoc();
            Cursor.move_to_target_loc();
        }
Ejemplo n.º 10
0
        public static PastRankings read(BinaryReader reader, Difficulty_Modes difficulty)
        {
            PastRankings result = new PastRankings();

            result.Data.read(reader);

            // If this save predates storing difficulty in the ranking object
            if (Global.LOADED_VERSION.older_than(0, 6, 1, 1))
            {
                foreach (var key in result.Data.Keys.ToList())
                {
                    result.Data[key] = new Game_Ranking(result.Data[key], difficulty);
                }
            }

            return(result);
        }
Ejemplo n.º 11
0
        private Suspend_Info(Suspend_Info source)
        {
            Chapter_Id      = source.Chapter_Id;
            Lord_Actor_Face = source.Lord_Actor_Face;
            Turn            = source.Turn;
            Units           = source.Units;
            Playtime        = source.Playtime;
            Gold            = source.Gold;
            Save_Id         = source.Save_Id;
            Preparations    = source.Preparations;
            HomeBase        = source.HomeBase;
            Difficulty      = source.Difficulty;
            Style           = source.Style;
            Time            = source.Time;
            ScreenshotData  = source.ScreenshotData.ToArray();

            SuspendModifiedTime = source.SuspendModifiedTime;
        }
Ejemplo n.º 12
0
        internal Metrics_Data(Gameplay_Metrics gameplay)
        {
            Chapter        = Global.game_system.chapter_id;
            StartTime      = Global.game_system.chapter_start_time;
            Difficulty     = Global.game_system.Difficulty_Mode;
            Style          = Global.game_system.Style;
            PlayTime       = Global.game_system.chapter_play_time;
            RankTurns      = Global.game_system.chapter_turn;
            RankCombat     = Global.game_system.chapter_damage_taken;
            RankExp        = Global.game_system.chapter_exp_gain;
            RankCompletion = Global.game_system.chapter_completion;
            RankSurvival   = Global.game_system.chapter_deaths;
            Deployed       = Global.game_system.deployed_unit_count;
            DeployedLvl    = Global.game_system.deployed_unit_avg_level;
            Battalion      = Global.battalion.actors.Count;
            BattalionLvl   = Global.battalion.average_level;

            GameplayStartTime = Global.game_system.gameplay_start_time;

            Gameplay = gameplay;
        }
Ejemplo n.º 13
0
        public void TitleNewGame(int fileId, Mode_Styles style, Difficulty_Modes difficulty)
        {
            Global.save_file            = new Tactile.IO.Save_File();
            Global.save_file.Style      = style;
            Global.save_file.Difficulty = difficulty;

            Global.game_options.reset_options();
            Global.start_game_file_id = fileId;
            Global.start_new_game     = true;

            // Save file on creation
            CallSaveData();
            Loading_Suspend = false;
            Closing         = true;
            Timer           = 0;
            if (Global.save_files_info == null)
            {
                Global.save_files_info = new Dictionary <int, Tactile.IO.Save_Info>();
            }
            Global.save_files_info.Add(
                Global.start_game_file_id, Tactile.IO.Save_Info.new_file());
        }
Ejemplo n.º 14
0
        public Difficulty_Info_Panel(Difficulty_Modes difficulty)
        {
            var window = new System_Color_Window();

            window.width          = WIDTH;
            window.height         = 48;
            window.color_override = Constants.Difficulty.DIFFICULTY_COLOR_REDIRECT[difficulty];
            window.small          = true;
            Window = window;

            Size = new Vector2(WIDTH, Window.height);

            Difficulty     = new TextSprite();
            Difficulty.loc = new Vector2(24, -8);
            Difficulty.SetFont(Config.UI_FONT, Global.Content, "Yellow");
            Difficulty.text = difficulty.ToString();
            Description     = new TextSprite();
            Description.loc = new Vector2(16, 8);
            Description.SetFont(Config.UI_FONT, Global.Content, "Blue");
            Description.text = Global.system_text["Difficulty " + difficulty.ToString()];

            active = false;
        }
Ejemplo n.º 15
0
        public static Game_Ranking read(BinaryReader reader)
        {
            string           chapter    = reader.ReadString();
            Difficulty_Modes difficulty = Difficulty_Modes.Normal;

            if (!Global.LOADED_VERSION.older_than(0, 6, 1, 1))
            {
                difficulty = (Difficulty_Modes)reader.ReadInt32();
            }
            int turns      = reader.ReadInt32();
            int combat     = reader.ReadInt32();
            int exp        = reader.ReadInt32();
            int survival   = 0;
            int completion = 0;

            if (!Global.LOADED_VERSION.older_than(0, 4, 0, 5))
            {
                survival   = reader.ReadInt32();
                completion = reader.ReadInt32();
            }
            var ranking = new DataRanking(turns, combat, exp, survival, completion);

            return(new Game_Ranking(chapter, difficulty, ranking));
        }
Ejemplo n.º 16
0
        public static void start_unit_editor_playtest()
        {
            var old_scene = Global.scene;

            if (!(old_scene is Scene_Map_Unit_Editor))
            {
                return;
            }

            Difficulty_Modes difficulty = Global.game_system.Difficulty_Mode;
            var chapter = Global.data_chapters[Global.game_system.New_Chapter_Id];

            var previous_chapters    = Global.save_file.valid_previous_chapters(chapter.Id);
            var previous_chapter_ids = previous_chapters
                                       .ToDictionary(p => p.Key, p => p.Value.Count == 0 ? "" : p.Value.Last());

            if (previous_chapters.Count == 0 || previous_chapters.Any(x => x.Value.Count == 0))
            {
                if (previous_chapters.Count > 0)
                {
                    Print.message(string.Format(
                                      "Could not load any save data\nfor \"{0}\", tried to use save file {1}",
                                      Global.game_system.New_Chapter_Id, Global.current_save_id));
                }
                previous_chapter_ids = previous_chapter_ids
                                       .ToDictionary(p => p.Key, p => "");
                Global.game_system.reset();
                Global.game_system.reset_event_variables();
                int battalion_index = chapter.Battalion;
                Global.game_battalions.add_battalion(battalion_index);
                Global.game_battalions.current_battalion = battalion_index;
            }
            else
            {
                Global.save_file.load_data(chapter.Id, previous_chapter_ids, "");

                Global.game_actors.heal_battalion();
                Global.battalion.refresh_deployed();
            }
            Global.game_system.Difficulty_Mode = difficulty;

            if (Global.game_system.Style != Mode_Styles.Classic)
            {
                Global.save_file.Difficulty = Global.game_system.Difficulty_Mode;
            }
            Global.game_system.new_chapter(chapter.Prior_Chapters, chapter.Id,
                                           previous_chapter_ids);

            // these weren't copied in like the rest of the Scene_Worldmap.start_chapter() stuff? //Debug
            Global.game_temp = new Game_Temp();
            Global.save_file = null;


            Global.change_to_new_scene("Scene_Map");

            Global.reset_game_state();
            var old_map = Global.game_map;

            Global.game_map = new Game_Map();
            Global.player   = new Player();

            // Trying to start this after everything else, instead of in the middle
            //move_range_update_thread(); //Debug
            Global.clear_events();

            //Global.Audio.clear_map_theme(); //@Debug

            (Scene as Scene_Map).set_map(old_scene as Scene_Map_Unit_Editor);
            Global.game_state.reset_support_data();
            Global.change_game_state_turn();

            if (old_map != null)
            {
                Global.game_map.set_scroll_loc(old_map.display_loc, true, true);
                Global.player.center_cursor(true);
            }
        }
Ejemplo n.º 17
0
        public void read(BinaryReader reader, Version loadedVersion)
        {
            Instant_Move         = reader.ReadBoolean();
            Character_Anim_Count = reader.ReadInt32();
            Selected_Unit_Id     = reader.ReadInt32();
            if (loadedVersion.older_than(0, 4, 3, 2))
            {
                List <int> rand = new List <int>();
                rand.read(reader);
                reset_rng();
            }
            else
            {
                Rand = Rng.read(reader, loadedVersion);
            }
            //reset_rng(); //Debug
            Preset_Rng.read(reader);
            Preparations = reader.ReadBoolean();
            if (!loadedVersion.older_than(0, 4, 3, 6))
            {
                Home_Base = reader.ReadBoolean();
            }
            Menu_Canto   = (Canto_Records)reader.ReadInt32();
            Battler_1_Id = reader.ReadInt32();
            Battler_2_Id = reader.ReadInt32();
            Aoe_Targets.read(reader);
            Staff_User_Id    = reader.ReadInt32();
            Staff_Target_Id  = reader.ReadInt32();
            Staff_Target_Loc = Staff_Target_Loc.read(reader);
            Rescuer_Id       = reader.ReadInt32();
            Rescuee_Id       = reader.ReadInt32();
            Item_User        = reader.ReadInt32();
            Item_Used        = reader.ReadInt32();
            if (!loadedVersion.older_than(0, 4, 6, 1))
            {
                Item_Inventory_Target = reader.ReadInt32();
            }
            if (!loadedVersion.older_than(0, 6, 6, 0))
            {
                ItemPromotionId = reader.ReadInt32();
            }
            if (!loadedVersion.older_than(0, 6, 4, 1))
            {
                ItemTargetLoc = ItemTargetLoc.read(reader);
            }
            Shopper_Id = reader.ReadInt32();
            Shop_Loc   = Shop_Loc.read(reader);
            if (!loadedVersion.older_than(0, 5, 0, 5))
            {
                SecretShop = reader.ReadBoolean();
            }
            In_Arena       = reader.ReadBoolean();
            Wager          = reader.ReadInt32();
            Arena_Distance = reader.ReadInt32();
            Arena_Round    = reader.ReadInt32();
            Stolen_Item    = reader.ReadInt32();
            Dance_Item     = reader.ReadInt32();
            Discarder_Id   = reader.ReadInt32();
            if (!loadedVersion.older_than(0, 5, 5, 4))
            {
                SupportGainId = reader.ReadInt32();
                SupportGainTargets.read(reader);
            }

            Battle_Mode    = (Constants.Animation_Modes)reader.ReadInt32();
            Objective_Text = reader.ReadString();
            Victory_Text   = reader.ReadString();
            Loss_Text      = reader.ReadString();
            Objective_Mode = Objective_Mode.read(reader);
            Loss_On_Death.read(reader);
            Ally_Loss_On_Death.read(reader);
            if (loadedVersion.older_than(0, 4, 2, 0))
            {
                Difficulty_Mode = reader.ReadBoolean() ? Difficulty_Modes.Hard: Difficulty_Modes.Normal;
            }
            else
            {
                Difficulty_Mode = (Difficulty_Modes)reader.ReadInt32();
            }
            Style = (Mode_Styles)reader.ReadInt32();
            if (!loadedVersion.older_than(0, 4, 0, 4))
            {
                Previous_Chapters.read(reader);
            }
            if (!loadedVersion.older_than(0, 4, 4, 0))
            {
                Chapter_Id = reader.ReadString();
                if (!loadedVersion.older_than(0, 5, 6, 3))
                {
                    PreviousChapterIds.read(reader);
                }
                else
                {
                    PreviousChapterIds.Clear();
                    string previous_chapter = reader.ReadString();
                    if (!string.IsNullOrEmpty(previous_chapter))
                    {
                        if (!Global.data_chapters.ContainsKey(Chapter_Id))
                        {
                            throw new KeyNotFoundException(string.Format("Problem loading save, cannot find chapter {0}", Chapter_Id));
                        }
                        else if (!Global.data_chapters.ContainsKey(previous_chapter))
                        {
                            throw new KeyNotFoundException(string.Format("Problem loading save, cannot find chapter {0}", previous_chapter));
                        }
                        else
                        {
                            string progression_id;
                            if (!Global.data_chapters[Chapter_Id].Prior_Chapters
                                .Intersect(Global.data_chapters[previous_chapter].Progression_Ids)
                                .Any())
                            {
#if DEBUG
                                //throw new KeyNotFoundException(string.Format(
                                //    "Chapter {0}'s prior chapters do not match chapter {1}'s progression ids",
                                //    Chapter_Id, previous_chapter));
#endif

                                // Incorrect but eh @Debug
                                progression_id = Global.data_chapters[Chapter_Id].Prior_Chapters.First();
                            }
                            else
                            {
                                progression_id = Global.data_chapters[Chapter_Id].Prior_Chapters
                                                 .Intersect(Global.data_chapters[previous_chapter].Progression_Ids)
                                                 .First();
                            }
                            PreviousChapterIds.Add(progression_id, previous_chapter);
                        }
                    }
                }
            }
            if (!loadedVersion.older_than(0, 6, 7, 0))
            {
                Rankings = PastRankings.read(reader, Difficulty_Mode);
            }
            else
            {
                Rankings = new PastRankings();
            }
            Total_Play_Time   = reader.ReadInt32();
            Chapter_Play_Time = reader.ReadInt32();
            if (!loadedVersion.older_than(0, 4, 6, 3))
            {
                Chapter_Start_Time = DateTime.FromBinary(reader.ReadInt64());
                if (!loadedVersion.older_than(0, 6, 3, 1))
                {
                    GameplayStartTime = DateTime.FromBinary(reader.ReadInt64());
                }
                else
                {
                    GameplayStartTime = Chapter_Start_Time;
                }
                Deployed_Unit_Count     = reader.ReadInt32();
                Deployed_Unit_Avg_Level = reader.ReadInt32();
            }
            Chapter_Turn         = reader.ReadInt32();
            Chapter_Exp_Gain     = reader.ReadInt32();
            Chapter_Damage_Taken = reader.ReadInt32();
            Chapter_Deaths       = reader.ReadInt32();
            Chapter_Completion   = reader.ReadInt32();
            if (!loadedVersion.older_than(0, 4, 4, 3))
            {
                Home_Base_Background = reader.ReadString();
            }

            SWITCHES = Event_Variable_Data <bool> .read(reader, Config.EVENT_DATA_LENGTH);

            VARIABLES = Event_Variable_Data <int> .read(reader, Config.EVENT_DATA_LENGTH);

            //Event_Processor.read_data(reader); //Debug
        }
Ejemplo n.º 18
0
        public void reset()
        {
            Instant_Move     = false;
            Selected_Unit_Id = -1;
            //Rng = new List<int>();
            reset_rng();
            Preset_Rng            = new List <int>();
            Saved_Rns             = new List <int>();
            Saving_Rns            = false;
            Preparations          = false;
            Home_Base             = false;
            Menu_Canto            = Canto_Records.None;
            Battler_1_Id          = -1;
            Battler_2_Id          = -1;
            Aoe_Targets           = new List <int>();
            Staff_User_Id         = -1;
            Staff_Target_Id       = -1;
            Staff_Target_Loc      = new Vector2(-1, -1);
            Rescuer_Id            = -1;
            Rescuee_Id            = -1;
            Item_User             = -1;
            Item_Used             = -1;
            Item_Inventory_Target = -1;
            ItemPromotionId       = -1;
            ItemTargetLoc         = new Vector2(-1, -1);
            Visitor_Id            = -1;
            Visit_Loc             = new Vector2(-1, -1);
            Shopper_Id            = -1;
            Shop_Loc           = new Vector2(-1, -1);
            SecretShop         = false;
            In_Arena           = false;
            Wager              = -1;
            Arena_Distance     = -1;
            Arena_Round        = -1;
            Arena_Retreat      = false;
            Stolen_Item        = -1;
            Discarder_Id       = -1;
            SupportGainId      = -1;
            SupportGainTargets = new List <int>();

            Battle_Mode        = Constants.Animation_Modes.Map;
            Status_Page        = 0;
            Unit_Page          = 0;
            Unit_Sort          = 0;
            Unit_Sort_Up       = true;
            DataPage           = 0;
            Supply_Item_Type   = 0;
            Objective_Text     = "";
            Victory_Text       = "";
            Loss_Text          = "";
            Objective_Mode     = new int[] { 0, 0 };
            Loss_On_Death      = new HashSet <int>();
            Ally_Loss_On_Death = new List <int>();
            Difficulty_Mode    = Difficulty_Modes.Normal;
            Style                         = Global.save_file == null ? Mode_Styles.Standard : Global.save_file.Style;
            Previous_Chapters             = new List <string>();
            Rankings                      = new PastRankings();
            Total_Play_Time               = 0;
            Chapter_Save_Progression_Keys = new string[0];
            Victory                       = false;
            Failure                       = false;
            clear_events();
        }
Ejemplo n.º 19
0
 public bool ContainsKey(string key, Difficulty_Modes difficulty)
 {
     return(Data.ContainsKey(key) && Data[key].Any(x => x.Value.difficulty == difficulty));
 }
Ejemplo n.º 20
0
        public static Save_File read(BinaryReader reader)
        {
            Save_File result = new Save_File();

            result.Style = (Mode_Styles)reader.ReadInt32();
            if (!Global.LOADED_VERSION.older_than(0, 4, 3, 4))
            {
                result.Difficulty = (Difficulty_Modes)reader.ReadInt32();
            }
            if (!Global.LOADED_VERSION.older_than(0, 5, 7, 0))
            {
                result.Description = reader.ReadString();
            }

            int chapter_count = reader.ReadInt32();

            if (Global.LOADED_VERSION.older_than(0, 6, 1, 0))
            {
                var old_data = new Dictionary <string, Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> > >();
                if (Global.LOADED_VERSION.older_than(0, 4, 4, 0))
                {
                    for (int i = 0; i < chapter_count; i++)
                    {
                        string    key   = reader.ReadString();
                        Save_Data value = Save_Data.read(reader);
                        old_data.Add(key, new Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> > {
                            { value.difficulty, new Dictionary <string, Save_Data> {
                                  { value.progression_id, value }
                              } }
                        });
                    }
                }
                else
                {
                    for (int i = 0; i < chapter_count; i++)
                    {
                        string chapter_key = reader.ReadString();
                        Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> > chapter =
                            new Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> >();

                        int count = reader.ReadInt32();
                        for (int j = 0; j < count; j++)
                        {
                            Difficulty_Modes key = (Difficulty_Modes)reader.ReadInt32();
                            Dictionary <string, Save_Data> value = read_chapter(reader);
                            chapter.Add(key, value);
                        }
                        old_data.Add(chapter_key, chapter);
                    }
                }
                // Select the newer save data for each chapter?
                result.Data = new Dictionary <string, Dictionary <string, Save_Data> >();
                foreach (var pair in old_data)
                {
                    result.Data.Add(pair.Key, new Dictionary <string, Save_Data>());
                    // Get all progression ids
                    var progression_ids = pair.Value.SelectMany(y => y.Value.Select(x => x.Key))
                                          .Distinct()
                                          .ToList();
                    foreach (string progression in progression_ids)
                    {
                        var chapter_dataset = pair.Value
                                              .Where(x => x.Value.ContainsKey(progression))
                                              .Select(x => x.Value[progression])
                                              // Find the newest
                                              .OrderByDescending(x =>
                        {
                            if (x.difficulty != Difficulty_Modes.Normal)
                            {
                            }
                            // Add 5 minutes if the save is a on hard mode,
                            //     to account for hard saving before normal
                            int extra_minutes =
                                x.difficulty == Difficulty_Modes.Normal ? 0 : 5;
                            return(x.time + new TimeSpan(0, extra_minutes, 0));
                        })
                                              .ToList();
                        if (chapter_dataset.Count > 1 && !(
                                chapter_dataset[0].time.Date == chapter_dataset[1].time.Date &&
                                chapter_dataset[0].time.Hour == chapter_dataset[1].time.Hour &&
                                chapter_dataset[0].time.Minute == chapter_dataset[1].time.Minute))
                        {
                        }
                        result.Data[pair.Key].Add(progression, chapter_dataset.First());
                    }
                }
            }
            else
            {
                for (int i = 0; i < chapter_count; i++)
                {
                    string chapter_key = reader.ReadString();
                    Dictionary <string, Save_Data> value = read_chapter(reader);
                    result.Data.Add(chapter_key, value);
                }
            }
            return(result);
        }
Ejemplo n.º 21
0
 public IEnumerable <string> available_chapters(Difficulty_Modes difficulty)
 {
     return(new List <string>(AvailableChapters));
 }
Ejemplo n.º 22
0
 public Game_Ranking(string chapter_id, Difficulty_Modes difficulty,
                     int turns, int combat, int exp, int survival, int completion)
     : this(chapter_id, difficulty, new DataRanking(
                turns, combat, exp, survival, completion))
 {
 }
Ejemplo n.º 23
0
 internal Game_Ranking(Game_Ranking ranking, Difficulty_Modes difficulty) :
     this(ranking.ChapterId, difficulty, new DataRanking(ranking.Data))
 {
 }