private GradeObtained CheckForGradeBonusGP() { GradeObtained obtained = GradeObtained.UNRANKED; int levelGP = 0; if (sessionScore >= currentLevel.goldScore) { levelGP = currentLevel.goldGP; obtained = GradeObtained.GOLD; } else if (sessionScore >= currentLevel.silverScore) { levelGP = currentLevel.silverGP; obtained = GradeObtained.SILVER; } else if (sessionScore >= currentLevel.bronzeScore) { levelGP = currentLevel.bronzeGP; obtained = GradeObtained.BRONZE; } if (levelGP != 0) { sessionGravityPoints += levelGP; } return(obtained); }
public void LevelCompleted() { Time.timeScale = 1f; isGameOver = true; attemptUsed = true; obstacleSpawner.PauseSpawnTimer(true); extraSpawner.PauseSpawnTimer(true); LevelsData levelsData = SaveManager.GetInstance().LoadPersistentData(SaveManager.LEVELSDATA_PATH).GetData <LevelsData>(); levelsData.UnlockLevel(currentLevel.id + 1); levelsData.UpdateLevelScore(currentLevel.id, (int)sessionScore); SaveManager.GetInstance().SavePersistentData <LevelsData>(levelsData, SaveManager.LEVELSDATA_PATH); sessionGravityPoints = GameplayMath.GetInstance().GetGravityPointsFromSession(sessionScore, playerManager.properTime, currentLevel); GradeObtained obt = CheckForGradeBonusGP(); currencyData.gravityPoints = sessionGravityPoints + currentGravityPoints; SaveManager.GetInstance().SavePersistentData <CurrencyData>(currencyData, SaveManager.CURRENCY_PATH); CheckForPlayerLevelUp(obt); HUDManager.GetInstance().EnableHighGravityFieldPanel(false); HUDManager.GetInstance().DisplayLevelCompletedPanel(); }
private void CheckForPlayerLevelUp(GradeObtained obt) { int newLevel = playerManager.CalculateLevel(sessionGravityPoints, obt); if (newLevel != 0) { HUDManager.GetInstance().DisplayPlayerLevelUp(newLevel); } }
public void EndSession() { GradeObtained obt = GradeObtained.UNRANKED; isGameOver = true; highScoreReached = false; obstacleSpawner.PauseSpawnTimer(true); extraSpawner.PauseSpawnTimer(true); sessionGravityPoints = GameplayMath.GetInstance().GetGravityPointsFromSession(sessionScore, playerManager.properTime, currentLevel); if (currentLevel.category == Level.LevelCategory.ENDLESS) { LevelsData data = SaveManager.GetInstance().LoadPersistentData(SaveManager.LEVELSDATA_PATH).GetData <LevelsData>(); data.UpdateLevelScore(LevelsData.ENDLESS_ID, (int)sessionScore); SaveManager.GetInstance().SavePersistentData <LevelsData>(data, SaveManager.LEVELSDATA_PATH); obt = CheckForGradeBonusGP(); if (attemptUsed) { sessionGravitons = 0; } else { sessionGravitons = GameplayMath.GetInstance().GetGravitonsFromGame(playerManager.properTime, sessionScore); currencyData.gravitons += sessionGravitons; } } currencyData.gravityPoints = sessionGravityPoints + currentGravityPoints; SaveManager.GetInstance().SavePersistentData <CurrencyData>(currencyData, SaveManager.CURRENCY_PATH); CheckForPlayerLevelUp(obt); if (currentLevel.category == Level.LevelCategory.ENDLESS) { HUDManager.GetInstance().DisplayGameOverPanel(true, true); } else { HUDManager.GetInstance().DisplayGameOverPanel(false, false); } HUDManager.GetInstance().EnableHighGravityFieldPanel(false); }