Пример #1
0
    private void SaveToFile()
    {
        SaveData sd = FileManagment.ReadFile <SaveData>("save");

        sd.saves[sd.saves.FindIndex(x => x.gameName == ApplicationModel.GameName)] = gameSave;
        FileManagment.WriteFile("save", sd);
    }
Пример #2
0
    public void CreateNewGame()
    {
        SaveData sd       = FileManagment.ReadFile <SaveData>("save");
        string   gameName = newGameField.text;

        if (sd == null || sd.saves == null)
        {
            sd = new SaveData {
                saves = new List <Game>()
            }
        }
        ;

        if (sd.saves.Exists(x => x.gameName == gameName))
        {
            result.text  = "Gra o takiej nazwie istnieje!";
            result.color = Color.red;
            return;
        }

        Game newGame = new Game {
            gameName = gameName
        };

        sd.saves.Add(newGame);

        result.text  = "Utworzono gre!";
        result.color = Color.green;

        FileManagment.WriteFile("save", sd);
    }
Пример #3
0
    private void SaveUpgrade(SaveData save, int cost)
    {
        save.Coins      -= cost;
        CoinsAmount.text = save.Coins.ToString();

        FileManagment.WriteFile("save.dat", save);
    }
    public void CheckSaveFile()
    {
        FileManagment.FileChecking();

        SaveData save = FileManagment.ReadFile <SaveData>("save.dat");

        if (save == null)
        {
            SaveData newSave = new SaveData
            {
                Levels = new List <Level>()
            };

            newSave.Levels.Add(new Level());

            FileManagment.WriteFile("save.dat", newSave);
        }
    }
Пример #5
0
    private void SaveResults()
    {
        SaveData save = FileManagment.ReadFile <SaveData>("save.dat");

        int index = SceneManager.GetActiveScene().buildIndex - 1; // because of level selection Scene

        if (index == save.Levels.Count - 1)
        {
            save.Levels.Add(new Level());
        }

        if (save.Levels[index].Coins < MyPlayer.CoinsAmount)
        {
            save.Coins += MyPlayer.CoinsAmount - save.Levels[index].Coins;
            save.Levels[index].Coins = MyPlayer.CoinsAmount;
        }

        if (save.Levels[index].SecretItems < MyPlayer.CoinsAmount)
        {
            save.Levels[index].SecretItems = MyPlayer.SecretItemsAmount;
        }

        FileManagment.WriteFile("save.dat", save);
    }
Пример #6
0
 public void SaveOptions()
 {
     FileManagment.WriteFile("preferences", optionsData);
 }