예제 #1
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);
     }
 }
예제 #2
0
    public void Awake()
    {
        _saveLoadSystem = new SaveLoadService();

        //Флаг LevelMove ставится в Exit.cs при переходе со сцены на сцену
        if (PlayerPrefs.GetInt("LevelMove") == 1) //Если это переход с другой сцены, то загружаем данные из сейва, который был сделан до перехода на эту сцену
        {
            Continue(SceneManager.GetActiveScene().name);
        }
        else if (PlayerPrefs.GetInt("LoadHandleSave") == 1)
        {
            _saveLoadSystem.LoadHandleSave();
            PlayerPrefs.SetInt("LoadHandleSave", 0);
        }
    }
예제 #3
0
    // Start is called before the first frame update
    void Awake()
    {
        saveLoadService      = new SaveLoadService();
        playerDataController = FindObjectOfType <PlayerDataController>().GetComponent <PlayerDataController>();
        uiController         = FindObjectOfType <UIController>();
        if (!PlayerPrefs.HasKey(Constants.NEWGAME) || PlayerPrefs.GetInt(Constants.NEWGAME) == 1)
        {
            seaWrapper    = GameObject.FindGameObjectWithTag("SeaWrapper");
            seaPrefab     = Resources.Load("Prefabs/Procedural/OceanTile") as GameObject;
            borderPrefab1 = Resources.Load("Prefabs/Procedural/Border1") as GameObject;
            borderPrefab2 = Resources.Load("Prefabs/Procedural/Border2") as GameObject;
            borderPrefab3 = Resources.Load("Prefabs/Procedural/Border3") as GameObject;
            borderPrefab4 = Resources.Load("Prefabs/Procedural/Border4") as GameObject;
            loadWater();

            bottomWrapper    = GameObject.FindGameObjectWithTag("BottomWrapper");
            sandPrefab       = Resources.Load("Prefabs/Procedural/SandTile") as GameObject;
            decorationPrefab = Resources.Load("Prefabs/Procedural/BottomDecoration1") as GameObject;
            loadBottom();

            mapWrapper  = GameObject.FindGameObjectWithTag("MapWrapper");
            islandArray = new List <Island>();
            generateIslands(9, 1);
            generateIslands(6, 2);
            generateIslands(3, 3);
            loadIslands();

            battleEventHolderPrefab   = Resources.Load("Prefabs/Procedural/BattleEventHolder") as GameObject;
            wreckageEventHolderPrefab = Resources.Load("Prefabs/Procedural/WreckageEventHolder") as GameObject;
            loadEvents(15);

            playerShipPrefab = Resources.Load("Prefabs/Procedural/PlayerShip") as GameObject;

            eventsWrapper = GameObject.FindGameObjectWithTag("EventsWrapper");
            //Default resources when creating a new game
            SetInitialPlayerData();
            loadPlayerShipPrefab();
            playerDataController.Save();
            uiController.ResourcesChanged(playerDataController.PlayerData);
        }
        else
        {
            playerDataController.Load();
        }
    }
        private void SaveVirtualMystery(object parameter)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.FileName   = "export.txt";
                saveFileDialog.DefaultExt = "txt";
                saveFileDialog.Filter     = "txt files (*.txt) | *.txt";

                if (saveFileDialog.ShowDialog() == true)
                {
                    SaveLoadService.Save(Mystery, saveFileDialog.FileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Fehler beim Speichern", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        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);
            }
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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);
            }
        }
        public void SaveTest()
        {
            string tmpFilename = Path.GetTempFileName();

            MysteryCreator mysteryCreator = new MysteryCreator();

            mysteryCreator.NumberOfColumns = 7;
            mysteryCreator.NumberOfRows    = 7;
            mysteryCreator.NumberOfShips   = 12;
            Mystery mystery = mysteryCreator.Create();

            SaveLoadService.Save(mystery, tmpFilename);

            if (File.Exists(tmpFilename))
            {
                Assert.IsTrue(true);
                File.Delete(tmpFilename);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
        public static CharacterSelector instance; //static variable is shared by all instances of a class

        #endregion

        private void Awake()
        {
            //proof that there is only one instance otherwise warn us
            if (instance != null)
            {
                Debug.LogWarning("More than one instance of PlayerStats found!");
                return;
            }
            instance = this;

            //get characterPosition
            characterPosition = player1.transform.position;

            //get offScreenPosiotion
            offScreen = player2.transform.position;

            //get each spriteRenderer
            player1Renderer         = player1.GetComponent <SpriteRenderer>();
            player1Renderer.enabled = true;
            player2Renderer         = player2.GetComponent <SpriteRenderer>();
            player2Renderer.enabled = false;

            saveLoadService = new SaveLoadServiceImpl();
        }
예제 #11
0
        public void OnButtonClicked(ConsoleKeyInfo button)
        {
            _hasMoved = true;
            if (IsError)
            {
                StopGameFunctionalities();
                return;
            }
            switch (button.Key)
            {
            case ConsoleKey.Escape:
                Console.Clear();
                SaveLoadService.Save(PlayerRef);
                GameStop();
                break;

            case ConsoleKey.A:
            case ConsoleKey.LeftArrow:
                if (isAttacking)
                {
                    movement.Attack(-1, 0);
                    isAttacking = false;
                    break;
                }
                movement.Move(-1, 0);
                break;

            case ConsoleKey.D:
            case ConsoleKey.RightArrow:
                if (isAttacking)
                {
                    movement.Attack(1, 0);
                    isAttacking = false;
                    break;
                }
                movement.Move(1, 0);
                break;

            case ConsoleKey.W:
            case ConsoleKey.UpArrow:
                if (isAttacking)
                {
                    movement.Attack(0, -1);
                    isAttacking = false;
                    break;
                }
                movement.Move(0, -1);
                break;

            case ConsoleKey.S:
            case ConsoleKey.DownArrow:
                if (isAttacking)
                {
                    movement.Attack(0, 1);
                    isAttacking = false;
                    break;
                }
                movement.Move(0, 1);
                break;

            case ConsoleKey.Spacebar:
                isAttacking = true;
                Console.Write("\b");
                break;

            case ConsoleKey.O:
                QuestControlActivated?.Invoke(true);
                break;

            case ConsoleKey.P:
                QuestControlActivated?.Invoke(false);
                break;

            default:
                Console.Write("\b");
                break;
            }
        }
예제 #12
0
 public void SaveReactRoles()
 {
     SaveLoadService.Save(REACTROLES_FILENAME, reactRoles, Formatting.Indented);
 }
예제 #13
0
 public void SaveSettings()
 {
     SaveLoadService.Save(FILE_NAME, settings);
 }