//method that starts a new scenario: public void ActivateScenario(Scenario scenario) { if (!scenario || status == ScenarioStatus.success || status == ScenarioStatus.failed) //if there was an active scenario that ended, do not proceed { return; } menu.SetActive(false); //start by hiding the menu if (status == ScenarioStatus.active && this.scenario) //if there was an active scenario already { CustomEvents.OnScenarioFail(scenario); //mark scenario as failed scenario.GetMission(currMissionID).Disable(); //disable the last active mission in that scenario } //assign new scenario this.scenario = scenario; currMissionID = -1; menu.SetActive(true); //show the scenario menu EnableNext(); //enable the first mission status = ScenarioStatus.active; //this mission scenario is now active CustomEvents.OnScenarioStart(scenario); //trigger custom event enabled = true; //enable this component }
//called when one of the missions has failed public void OnFailed() { status = ScenarioStatus.failed; CustomEvents.OnScenarioFail(scenario); //trigger custom event scenario.GetMission(currMissionID).Disable(); //disable the last active mission gameMgr.LooseGame(); //player loses the game }