Exemplo n.º 1
0
        public void SaveLevel(int _levelNo, float _time, int _star, int _items, int _jumped, int _restarted, int _score)
        {
            var chapter     = MainMenuManager.Instance.chapter.ToString("0");
            var levelString = chapter + levelNo.ToString("00");

            if (int.TryParse(levelString, out _levelNo))
            {
                if (SaveGame.Exists("Level" + _levelNo))
                {
                    time = CheckBest(
                        SaveGame.Load <float>("Level" + levelNo + "/Time", t),
                        _time);

                    star = (int)CheckBest(
                        SaveGame.Load <int>("Level" + levelNo + "/Star", s),
                        _star);

                    items = (int)CheckBest(
                        SaveGame.Load <int>("Level" + levelNo + "/Items", i),
                        _items);

                    jumped = (int)CheckBest(
                        SaveGame.Load <int>("Level" + levelNo + "/Jumped", j),
                        _jumped);

                    restarted = (int)CheckBest(
                        SaveGame.Load <int>("Level" + levelNo + "/Restarted", r),
                        _restarted);
                    score = (int)CheckBest(
                        SaveGame.Load <int>("Level" + levelNo + "/Score", sc),
                        _score);

                    SaveLevelStats(time, star, items, jumped, restarted, score);
                }
                else
                {
                    PlayerLevelStats playerLevelStats = new PlayerLevelStats
                    {
                        time      = _time,
                        star      = _star,
                        items     = _items,
                        jumped    = _jumped,
                        restarted = _restarted,
                        score     = _score
                    };
                }
            }

            print("2b. Saved levelStats. Level: " + _levelNo + ", Time: " + _time + ", star: " + _star + ", items: " + _items +
                  ", jumped: " + _jumped + ", restarted: " + _restarted + ", score: " + _score);

            SaveGame.Save("Level" + _levelNo + "/Time", _time);
            SaveGame.Save("Level" + _levelNo + "/Star", _star);
            SaveGame.Save("Level" + _levelNo + "/Items", _items);
            SaveGame.Save("Level" + _levelNo + "/Jumped", _jumped);
            SaveGame.Save("Level" + _levelNo + "/Restarted", _restarted);
            SaveGame.Save("Level" + _levelNo + "/Score", _score);
        }
Exemplo n.º 2
0
        private void Awake()
        {
            Instance          = this;
            levelStats        = gameObject.GetComponent <PlayerLevelStats>();
            chaptersAndLevels = gameObject.GetComponent <ChaptersAndLevels>();

            if (gameLevelPresets == null)
            {
                gameLevelPresets = GetComponent <GameLevelPresets>();
            }
        }