/** Initializes the stage using values obtained from the world map. * @params worldlevel is the world selected, worldStageNames is a list of tuples containing a world, a stage, and the stage name, worldStageProgress is a list of tuples containing a world, a stage, and the user progress for that stage **/ public void LoadStageMap(int worldLevel, List <Tuple <int, int, string> > worldStageNames, List <Tuple <int, int, string> > worldStageProgress) { datahandler = GameObject.Find("DataManager").GetComponent <DataHandler>(); //default page number is 1 this.pageNumber = 1; this.worldLevel = worldLevel; stageMapImplementor = new StageMapManagerImplementation(); //Get stage names and progress from the parameters this.stageNames = stageMapImplementor.InitializeStageNames(worldStageNames, worldLevel); this.stageProgress = stageMapImplementor.InitializeStageProgress(worldStageProgress, worldLevel); //If User progress on last attempted stage is more than 70%, we allow him to proceed to next stage DetermineIfUserStageProgressShouldBeUpdated(); UpdateLeftRightButtons(); //If The number of stages in this world is 0, declare 0 stages. if (stageNames[0].Item1 == 0) { DeclareStageMapButtons(stageProgress.Count, 0, this.pageNumber); } else { DeclareStageMapButtons(stageProgress.Count, stageNames.Count, this.pageNumber); } stageSelect.SetActive(true); }
public void TestCorrectStageInitializeStageNamesTestWhenStageNamesAreUnordered() { List <Tuple <int, int, string> > worldStageNames = new List <Tuple <int, int, string> >(); worldStageNames.Add(new Tuple <int, int, string>(2, 1, "Stage1")); worldStageNames.Add(new Tuple <int, int, string>(1, 2, "Stage2")); worldStageNames.Add(new Tuple <int, int, string>(1, 1, "Stage3")); StageMapManagerImplementation stageMapImplementor = new StageMapManagerImplementation(); List <Tuple <int, string> > result = stageMapImplementor.InitializeStageNames(worldStageNames, 1); Assert.AreEqual(1, result[0].Item1); Assert.AreEqual("Stage3", result[0].Item2); Assert.AreEqual(2, result[1].Item1); Assert.AreEqual("Stage2", result[1].Item2); }