Esempio n. 1
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);
    }
Esempio n. 2
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);
    }
Esempio n. 3
0
    private void LoadUpgrades()
    {
        SaveData save = FileManagment.ReadFile <SaveData>("save.dat");

        bonusSpeed     = MyPlayerStats.BonusSpeed + save.BonusSpeed;
        baseSpeed      = MyPlayerStats.MovementSpeed + save.MovementSpeed;
        MaxBoostAmount = MyPlayerStats.MaxBoostAmount + save.MaxBoostAmount;
    }
    private void SetUpgradesLevels()
    {
        SaveData save = FileManagment.ReadFile <SaveData>("save.dat");

        SetFirstUpgradeLevel(save);
        SetSecondUpgradeLevel(save);
        SetThirdUpgradeLevel(save);
    }
Esempio n. 5
0
    private void LoadSave()
    {
        SaveData sd = FileManagment.ReadFile <SaveData>("save");

        gameSave = sd.saves.Find(x => x.gameName == ApplicationModel.GameName);

        _historyWins   = gameSave.wins;
        _historyLosses = gameSave.losses;
    }
    public void UpgradeBoostSpeed(int cost)
    {
        if (CanBuy(cost))
        {
            SaveData save = FileManagment.ReadFile <SaveData>("save.dat");
            save.BonusSpeed += BonusSpeed;

            SaveUpgrade(save, cost);
            SetThirdUpgradeLevel(save);
        }
    }
    public void UpgradeBoostAmount(int cost)
    {
        if (CanBuy(cost))
        {
            SaveData save = FileManagment.ReadFile <SaveData>("save.dat");
            save.MaxBoostAmount += BonusMaxBoostAmount;

            SaveUpgrade(save, cost);
            SetSecondUpgradeLevel(save);
        }
    }
    public void UpgradeMovementSpeed(int cost)
    {
        if (CanBuy(cost))
        {
            SaveData save = FileManagment.ReadFile <SaveData>("save.dat");
            save.MovementSpeed += BonusMovementSpeed;

            SaveUpgrade(save, cost);
            SetFirstUpgradeLevel(save);
        }
    }
    private void SetLevelMenuValues(int level)
    {
        level--;

        LevelName.text           = Levels[level].LevelName;
        LevelMaxCoins.text       = Levels[level].Coins.ToString();
        LevelMaxSecretItems.text = Levels[level].SecretItems.ToString();

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

        LevelPlayerCoins.text = save.Levels[level].Coins.ToString();
        LevelPlayerItems.text = save.Levels[level].SecretItems.ToString();
    }
Esempio n. 10
0
    public void LoadOptions()
    {
        OptionsData od = FileManagment.ReadFile <OptionsData>("preferences");

        if (od == null)
        {
            return;
        }

        resolutionDropdown.value = od.resolutionIndex;
        resolutionDropdown.RefreshShownValue();

        valueChanged = false;
        optionsData  = od;
    }
    public void LoadSave()
    {
        SaveData save = FileManagment.ReadFile <SaveData>("save.dat");

        CoinsAmount.text = save.Coins.ToString();

        foreach (Transform transform1 in LevelsParent.transform)
        {
            transform1.GetComponent <Button>().interactable = false;
        }

        for (int i = 0; i < save.Levels.Count; i++)
        {
            LevelsParent.transform.GetChild(i).GetComponent <Button>().interactable = true;
        }
    }
Esempio n. 12
0
    private void LoadGameList()
    {
        SaveData sd = FileManagment.ReadFile <SaveData>("save");

        if (sd == null || sd.saves == null)
        {
            return;
        }

        foreach (Game sdSave in sd.saves)
        {
            GameButton b = Instantiate(gameButton, gameList);
            b.nameLabel.text = sdSave.gameName;
            var save = sdSave;
            b.buttonComponent.onClick.AddListener(delegate { LoadGame(save.gameName); });
        }
    }
    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);
        }
    }
Esempio n. 14
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);
    }