示例#1
0
        /// <summary>
        /// Unlocks all the scenarios stored in the 'scenarios' list.
        /// </summary>
        public void UnlockAll()
        {
            foreach (ScenarioScene ss in scenarios) //go through all scenarios and unlock them.
            {
                MissionSaveLoad.UnlockScenario(ss.source.GetCode());
            }

            RefreshUI(false); //refresh the UI status of the scenarios to allow them to be loadable
        }
示例#2
0
        //resets the player progress on all saved scenarios:
        public void Reset()
        {
            MissionSaveLoad.ClearSavedScenarios();

            for (int i = 1; i < scenarios.Length; i++) //go through all the scenario UI elements (except the first one)
            //make the buttons interactable so that none of them can be loaded
            {
                scenarioUIList[i].Refresh(scenarios[i].source.GetName(), scenarios[i].source.GetDescription(), false);
            }
        }
示例#3
0
        //called when all of the missions in the scenario are completed
        public void OnSuccess()
        {
            currMissionID--; //so we can see the last mission on the UI menu
            RefreshUI();

            status = ScenarioStatus.success;
            CustomEvents.OnScenarioSuccess(scenario); //trigger custom event

            gameMgr.WinGame();                        //player wins the game

            if (save)                                 //if saving is enabled
            {
                MissionSaveLoad.SaveScenario(scenario.GetCode(), true);
            }
        }
示例#4
0
        private void Start()
        {
            Dictionary <string, bool> savedScenarios = MissionSaveLoad.LoadScenarios(); //get the saved scenarios

            //start by creating the assigned scenarios
            for (int i = 0; i < scenarios.Length; i++)
            {
                ScenarioMenuUI nextScenarioUI = Instantiate(scenarioUIPrefab.gameObject, scenarioUIParent.transform).GetComponent <ScenarioMenuUI>(); //create a new scenario UI menu element
                scenarioUIList.Add(nextScenarioUI);

                nextScenarioUI.Init(this, i); //initialise it

                bool unlocked = true;
                if (i > 0)                                                                                             //only if this is not the first scenario in the list
                {
                    savedScenarios.TryGetValue(scenarios[i - 1].source.GetCode(), out unlocked);                       //check if it's unlocked or not
                }
                nextScenarioUI.Refresh(scenarios[i].source.GetName(), scenarios[i].source.GetDescription(), unlocked); //refresh the content of the scenario UI menu
            }
        }
示例#5
0
        /// <summary>
        /// Refreshes the UI elements of the available scenarios.
        /// </summary>
        /// <param name="redraw">When true, previous UI elements will be destroyed and redrawn. When false, only the state of the scenario in the UI elements will be updated.</param>
        public void RefreshUI(bool redraw)
        {
            if (redraw)                          //redraw the UI elemets for each scenario?
            {
                while (scenarioUIList.Count > 0) //go through the already drawn scenario UI elements
                {
                    Destroy(scenarioUIList[0]);  //destroy the UI element
                    scenarioUIList.RemoveAt(0);; //remove the element's entry
                }
            }

            Dictionary <string, bool> savedScenarios = MissionSaveLoad.LoadScenarios(); //get the saved scenarios

            //start by creating the assigned scenarios
            for (int i = 0; i < scenarios.Length; i++)
            {
                ScenarioMenuUI nextScenarioUI = scenarioUIList.Count > i
                    ? scenarioUIList[i]
                    : null;

                if (nextScenarioUI == null)                                                                                                //the scenario UI element is not found, create one
                {
                    nextScenarioUI = Instantiate(scenarioUIPrefab.gameObject, scenarioUIParent.transform).GetComponent <ScenarioMenuUI>(); //create a new scenario UI menu element
                    scenarioUIList.Add(nextScenarioUI);
                }

                nextScenarioUI.Init(this, i); //initialise it

                bool unlocked = true;
                if (i > 0)                                                                                             //only if this is not the first scenario in the list
                {
                    savedScenarios.TryGetValue(scenarios[i - 1].source.GetCode(), out unlocked);                       //check if it's unlocked or not
                }
                nextScenarioUI.Refresh(scenarios[i].source.GetName(), scenarios[i].source.GetDescription(), unlocked); //refresh the content of the scenario UI menu
            }
        }
示例#6
0
        //resets the player progress on all saved scenarios:
        public void Reset()
        {
            MissionSaveLoad.ClearSavedScenarios();

            RefreshUI(false); //update the UI status of the scenarios.
        }