public void loadLevelOrQuestion() { questionPlayed++; isUserPlayedTheQuestion = true; totalWrongAttempts = 0; loadingQuestionOrLevelInProgress = true; Debug.Log("Total Attempts: " + totalAttempts + " Total Corrects: " + totalCorrects); bool isleveldone = false; if (totalAttempts > 0) { isleveldone = pgDataManager.calculateResult(totalAttempts, totalCorrects); } if (questionPlayed >= 5) { AGGameState.loadNextGameInLoop(AGGameIndex.k_ShapePond); // to play in loop return; } if (isleveldone) // Check result { StartCoroutine(ResetLevel(0.5F, nextLevelDecision.loadLevel)); // load new level } else { StartCoroutine(ResetLevel(0.5F, nextLevelDecision.loadQuestion)); // load next question } }
public void loadNextQuestion(float timeToLoad) { float restartLevelTime = 0; //restartLevelTime= timeToLoad; Debug.Log("Load Next Question"); int questionAttempts = 0; int wrongAttempts = 0; if (isResetInProgress) { inputController.isTouchEnabled = false; return; } isResetInProgress = true; questionAttempts = inputController.qAttemptsCount(); wrongAttempts = inputController.wrongAttempts; if (questionAttempts > 0) { #if (MAC_PLATFORM) AGGameState.incrementStarCount(); if (AGGameState.currentGameIndex == (int)AGGameIndex.k_NamingFruits) { if (dataManager.currentLevel == 17 || dataManager.currentLevel == 8) { dataManager.currentLevel = 1; } else { dataManager.currentLevel++; } } else if (AGGameState.currentGameIndex == (int)AGGameIndex.k_2DShapesColors) { if (dataManager.currentLevel == 17 || dataManager.currentLevel == 20) { dataManager.currentLevel = 1; } else { dataManager.currentLevel++; } } if (wrongAttempts >= 5) { restartLevelTime = 1.5f; } else if (wrongAttempts < 5) { inputController.setCelebrationStatus(true); restartLevelTime = 3.0f; } dataManager.fetchLevelData(); questionAttempts = 0; wrongAttempts = 0; CancelInvoke("createOllyModel"); Invoke("resetAllLevelState", restartLevelTime); #else AGGameState.incrementStarCount(); bool isLevelDone = dataManager.calculateResult(questionAttempts, answersListCount); if (isLevelDone) { restartLevelTime = 3.0f; inputController.setCelebrationStatus(true); dataManager.fetchLevelData(); } else if (!isLevelDone) { if (wrongAttempts == 5) { restartLevelTime = 1.25f; } else { restartLevelTime = 2.0f; } } wrongAttempts = 0; questionAttempts = 0; CancelInvoke("createOllyModel"); Invoke("resetAllLevelState", restartLevelTime); #endif } }