Пример #1
0
        private static void UnlockNextLevel(LevelPack levelPack, Level.LevelInfo level)
        {
            var levelIndex = level.Index;

            if (levelIndex >= 0 && levelIndex + 1 < levelPack.TotalLevelCount)
            {
                // Next Level in current pack
                var nextLevel = levelPack.Levels[levelIndex + 1];
                nextLevel.SetStatus(Level.LevelInfo.LevelInfoStatus.Unsolved);
                levelPack.SaveProgressForPack();
            }
            else if (levelIndex + 1 >= levelPack.TotalLevelCount)
            {
                // Next Level in next pack
                var nextPack = GetNextPack(levelPack);
                nextPack?.UnlockFirstLevel();
            }
        }
Пример #2
0
        public static void SolveLevel(LevelPack levelPack, string levelID, bool isWithinMoves, bool hasCollectedSushi)
        {
            if (!levelPack.Levels.Contains(levelID))
            {
                throw new Exception($"No Level loaded with ID {levelID}");
            }

            // Get the pack's corresponding level info
            // Not using level.Info as the level's info might not be the same one as the pack
            var packLevelInfo = levelPack.Levels[levelID];

            // Mark the level as the correct level of solved
            bool isWithinMinMoves = packLevelInfo.IsSolvedWithinMinMoves || isWithinMoves;
            bool hasSushi         = packLevelInfo.IsSolvedWithSushi || hasCollectedSushi;

            if (isWithinMinMoves && hasSushi)
            {
                packLevelInfo.SetStatus(Level.LevelInfo.LevelInfoStatus.FullySolved);
            }
            else if (isWithinMinMoves && !hasSushi)
            {
                packLevelInfo.SetStatus(Level.LevelInfo.LevelInfoStatus.SolvedWithMinMoves);
            }
            else if (!isWithinMinMoves && hasSushi)
            {
                packLevelInfo.SetStatus(Level.LevelInfo.LevelInfoStatus.SolvedWithSushi);
            }
            else
            {
                packLevelInfo.SetStatus(Level.LevelInfo.LevelInfoStatus.Solved);
            }

            // Unlock next level and save the pack
            UnlockNextLevel(levelPack, packLevelInfo);
            levelPack.SaveProgressForPack();
        }