Esempio n. 1
0
        private void AddConsumablesInfo()
        {
            LOG.Debug("If Ships has been loaded, we will not have Consumables on them. Then we will force a reload/add of the consumables to corresponding ship.");
            bool ForceSave = (Program.AllShips[0].Consumables == null || Program.AllShips[0].Consumables.Count == 0);

            Updater.AddConsumablesInfo(ForceSave);
        }
Esempio n. 2
0
        private void LoadAllData()
        {
            LOG.Info("Loading game data");
            bool allFilesLoaded = true;

            try { Program.AllModules = BinarySerialize.Read2 <Dictionary <string, ModuleData> >(Commons.GetModulesFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Modules", e); }
            try { Program.AllShips = BinarySerialize.Read2 <List <Ship> >(Commons.GetShipListFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Ships", e); }
            try { Program.Upgrades = BinarySerialize.ReadFromBinaryFile <List <Consumable> >(Commons.GetUpgradesFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Upgrades", e); }
            //try { Program.CommanderSkills = BinarySerialize.ReadFromBinaryFile<List<Skill>>(Commons.GetCommanderSkillFileName()); } catch(Exception) { allFilesLoaded = false; }
            try { Program.CommanderSkills = BinarySerialize.ReadFromBinaryFile <Dictionary <string, List <Skill> > >(Commons.GetCommanderSkillFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Skills", e); }
            try { Program.Flags = BinarySerialize.ReadFromBinaryFile <List <Consumable> >(Commons.GetFlagsFileName()); } catch (Exception e) { allFilesLoaded = false; LOG.Error("Unable to load Flags", e); }

            if (Program.Flags.Count == 0 || Program.CommanderSkills.Count == 0 || Program.Upgrades.Count == 0 || Program.AllShips.Count == 0 || Program.AllModules.Count == 0)
            {
                LOG.Warning("Not all files loaded; " + Program.Flags.Count + "," + Program.CommanderSkills.Count + "," + Program.Upgrades.Count + "," + Program.AllShips.Count + "," + Program.AllModules.Count);
                allFilesLoaded = false;
            }

            if (allFilesLoaded == false)
            {
                LOG.Info("One or more files missing - force update");
                StartLoadingAnimation();
                BGUpdater.RunWorkerAsync();
            }
            else
            {
                randomizerUpdater.UpdateCommanderSkills();
                Updater.AddConsumablesInfo(false);
                LOG.Info("All files loaded.");
                FinalizeLoad();
            }
        }