public virtual void Init(ModManager modManager, GameManager gameManager)
        {
            this.gameManager = gameManager;
            this.modManager  = modManager;
            modInstallPath   = Path.Combine(Application.persistentDataPath, "Mods");
            Directory.CreateDirectory(modInstallPath);
            modDirectory         = new ModDirectory(modInstallPath, true, false);
            Mod.DefaultDirectory = modDirectory;
            inited = true;
            gameManager.ConsoleWindow.WriteLine($"ModLoader initialized. Path: {modInstallPath}");
            UpdateModList();
            List <string> loadedMods = SaveLoadService.Load <List <string> >("");

            if (loadedMods == null)
            {
                loadedMods = new List <string>();
            }
            List <string> unloadedMods = LoadMods(loadedMods);

            foreach (string um in unloadedMods)
            {
                loadedMods.Remove(um);
            }
            SaveLoadService.Save(modsLoadedFileName, JsonUtility.ToJson(loadedMods));
        }
        public void LoadTest()
        {
            string tmpFilename = Path.GetTempFileName();

            MysteryCreator mysteryCreator1 = new MysteryCreator();

            mysteryCreator1.NumberOfColumns = 7;
            mysteryCreator1.NumberOfRows    = 7;
            mysteryCreator1.NumberOfShips   = 12;
            Mystery mystery1 = mysteryCreator1.Create();

            SaveLoadService.Save(mystery1, tmpFilename);

            MysteryCreator mysteryCreator2 = new MysteryCreator();

            mysteryCreator2.NumberOfColumns = 2;
            mysteryCreator2.NumberOfRows    = 2;
            mysteryCreator2.NumberOfShips   = 1;
            Mystery mystery2 = mysteryCreator2.Create();

            mystery2 = SaveLoadService.Load(mystery2, tmpFilename);
            Assert.IsTrue(mystery2.FieldList.Count == mystery1.FieldList.Count && mystery1.ShipList.Count == mystery2.ShipList.Count);
            if (File.Exists(tmpFilename))
            {
                File.Delete(tmpFilename);
            }
        }
예제 #3
0
    public void Load()
    {
        PlayerData = saveLoadService.Load();
        uiController.ResourcesChanged(PlayerData);
        var player = GameObject.FindGameObjectWithTag("Player");

        player.transform.position = PlayerData.Position;
        player.transform.rotation = PlayerData.Rotation;
    }
예제 #4
0
        private void Initialize()
        {
            archiveService = new ArchiveService <T>(_bufferCapacity);

            if (_useSaveSystem)
            {
                saveLoadService =
                    new SaveLoadService <T>(archiveService, this, _autoSave, autoSaveInterval);
                saveLoadService.Load();
            }
        }
예제 #5
0
 public GuildsDefinition()
 {
     settings   = SaveLoadService.Load <Dictionary <ulong, GuildSettings> >(FILE_NAME);
     reactRoles = SaveLoadService.Load <Dictionary <ulong, Dictionary <string, List <ReactRolesDefinition> > > >(REACTROLES_FILENAME);
     if (settings == null)
     {
         settings = new Dictionary <ulong, GuildSettings>();
         SaveLoadService.Save(FILE_NAME, settings);
     }
     if (reactRoles == null)
     {
         reactRoles = new Dictionary <ulong, Dictionary <string, List <ReactRolesDefinition> > >();
         SaveLoadService.Save(REACTROLES_FILENAME, reactRoles);
     }
 }
        private void LoadVirtualMystery(object parameter)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == true)
                {
                    Mystery = SaveLoadService.Load(Mystery, openFileDialog.FileName);
                }

                MainWindow mainWindow = MainWindow.GetSingelton();
                mainWindow.Show();
                mainWindow.UpdatePlayingField(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Fehler beim Laden", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #7
0
        private bool LoadBotDefinition()
        {
            string bd = SaveLoadService.Load("botdefinition.json");

            if (bd != null)
            {
                botDefinition = JsonConvert.DeserializeObject <BotDefinition>(bd);
                try
                {
                    token = botDefinition.GetCurrent().token;
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }
예제 #8
0
        public static bool ShowMenu()
        {
            if (SaveLoadService.CheckIfGamesaveExists())
            {
                player = SaveLoadService.Load();
            }
            bool atMenu = true;

            Console.Clear();
            while (atMenu)
            {
                Console.Clear();
                bool   continueCondition = player != null && player.IsAlive;
                string continueOption    = continueCondition ? "\n[2]Continue" : "";
                Console.WriteLine("Welcome to Rougelike by DrMayx!\n\n" +
                                  "Close game only from main menu.\n" +
                                  "Game saves automatically on closing." +
                                  $"\n\n[1]Start new Game{continueOption}\n[9]Exit");

                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.D1:
                    player = PlayerTile.CreateNewPlayer();
                    return(true);

                case ConsoleKey.D2:
                    if (continueCondition)
                    {
                        return(true);
                    }
                    break;

                case ConsoleKey.D9:
                    return(false);

                case ConsoleKey.D0:
                    ShowDebugInfo();
                    break;
                }
            }
            return(false);
        }
예제 #9
0
        public static CharacterDecider instance; //static variable is shared by all instances of a class

        /// <summary>
        /// setting the instance equal to this particular component
        /// </summary>
        private void Awake()
        {
            //proof that there is only one instance otherwise warn us
            if (instance != null)
            {
                Debug.LogWarning("More than one instance of CharacterDecider found!");
                return;
            }
            instance = this;

            saveLoadService = new SaveLoadServiceImpl();

            PlayerData playerData = saveLoadService.Load();

            if (playerData.loadNextAsNewGame)
            {
                CreateNewGame(playerData);
            }
            else
            {
                LoadExistingGame(playerData);
            }
        }