Exemple #1
0
        public Level.Event Debug_WinLevel()
        {
            Result = 1;

            var levelProgress = Database.Load <LevelProgressData>(LevelIndex);

            levelProgress.Value.stars  = 3;
            levelProgress.Value.points = 9999;
            levelProgress.Value.moves  = 99;
            Database.Save(levelProgress);

            LevelProgressData.UnlockLevel(LevelIndex + 1);

            return(new Level.LevelWinEvent(3, 99, 9999, 99, 9999));
        }
Exemple #2
0
        private Level.Event GetEndOfLevelResults()
        {
            Assert.IsTrue(Result == 0, "[LevelState] Getting end of level results, but the level already ended");

            switch (Config.goalType)
            {
            case LevelGoalType.Points:
            {
                if (Points < Config.goal1)
                {
                    Result = -1;

                    return(new Level.LevelLoseEvent());
                }
                else
                {
                    Result = 1;

                    var levelProgress = Database.Load <LevelProgressData>(LevelIndex);
                    int bestMoves     = levelProgress.Value.moves <= 0 ? Moves : Mathf.Min(Moves, levelProgress.Value.moves);
                    int bestPoints    = Mathf.Max(Points, levelProgress.Value.points);
                    int stars         = Points >= Config.goal3 ? 3 : Points >= Config.goal2 ? 2 : 1;

                    levelProgress.Value.moves  = bestMoves;
                    levelProgress.Value.points = bestPoints;
                    levelProgress.Value.stars  = Mathf.Max(stars, levelProgress.Value.stars);
                    Database.Save(levelProgress);

                    LevelProgressData.UnlockLevel(LevelIndex + 1);

                    return(new Level.LevelWinEvent(stars, Moves, Points, bestMoves, bestPoints));
                }
            }

            default:
            {
                Logger.LogError($"Unhandled LevelGoalType: {Config.goalType}");
                Result = -1;
                return(new Level.LevelLoseEvent());                        // we don't know how to end the level properly, so end it immediately
            }
            }
        }