public void StartNewGame() { if (this.currentlyActiveQuestObject != null) { Destroy(this.currentlyActiveQuestObject.gameObject); this.currentlyActiveQuestObject = null; } if (this.currentlyUsedBullet != null) { Destroy(this.currentlyUsedBullet.gameObject); this.currentlyUsedBullet = null; this.weaponController.loadedBullet = null; } this.weaponController.Resume(); this.currentlyUsedBullet = this.weaponController.LoadNewBullet().GetComponent <BulletComponent>(); this.currentlyUsedBullet.AddListenerToBullet(this.OnBulletDeactivation); this.currentlyUsedBullet = this.weaponController.LoadNewBullet().GetComponent <BulletComponent>(); this.currentlyUsedBullet.AddListenerToBullet(this.OnBulletDeactivation); this.thisLevelSpawnCountGoal = Player.playerProgressData[this.currentlySelectedProblem].levelsSpawnCount[this.currentLevel]; this.spawnCount = 1; this.UpdateSpawnCount(); this.SpawnNewQuestion(ProblemManager.GetNewQuestion(this.currentlySelectedProblem, this.currentLevel, this.spawnCount)); this.isAGameRunning = true; }
public void OnCorrectNumberHit() { this.messageHolderText.text = "CORRECT!"; Destroy(this.currentlyActiveQuestObject.gameObject); this.currentlyActiveQuestObject = null; this.UpdatePlayerResources(1); this.spawnCount++; if (this.spawnCount > this.thisLevelSpawnCountGoal) { this.currentLevel++; if (!Player.playerProgressData[this.currentlySelectedProblem].levels.ContainsKey(this.currentLevel)) { this.currentLevel--; } else { this.levelText.text = this.currentLevel.ToString(); Player.playerProgressData[this.currentlySelectedProblem].levels[this.currentLevel] = true; Player.Save(); } this.spawnCount = 1; } this.UpdateSpawnCount(); this.SpawnNewQuestion(ProblemManager.GetNewQuestion(this.currentlySelectedProblem, this.currentLevel, this.spawnCount)); }
private void SpawnNewQuestion(QuestionData qData) { GameObject newObject = (GameObject)Instantiate(this.questionObjectPrefab, this.spawnPosition.transform.position, this.spawnPosition.transform.rotation); newObject.SetActive(true); QuestionComponent qComponent = newObject.GetComponent <QuestionComponent>(); qComponent.BindQuestionData(qData); qComponent.AddListenerToCorrectHit(this.OnCorrectNumberHit); qComponent.AddListenerToIncorrectHit(this.OnIncorrectNumberHit); this.currentlyActiveQuestObject = qComponent; }