} // End of SceneLoadWithDelay // Load next level with delay. private IEnumerator LvlLoadNextWithDelay(float delay,bool is_async) { // If current level is last. if((int)Instance.cur_lvl==Lvls.GetNames(typeof(Lvls)).Length-1) { // Load 'Win' level. StartCoroutine(SceneLoadWithDelay(Scenes.WIN,delay)); // Exit from function. yield break; } // Wait for seconds. yield return new WaitForSecondsRealtime(delay); // Set current scene. Instance.cur_scene=Scenes.NONE; // Actualize current level. Instance.cur_lvl++; // If asynchronouse mode. if(is_async) { // Load next level. AsyncOperation oper = SceneManager.LoadSceneAsync(LvlNameDecode(Instance.cur_lvl)); // Activate loading panel. Instance.loading_panel.SetActive(true); // Reset slider progress. Instance.progress_slider.value=0.0F; // Duration of operation float duration = Time.realtimeSinceStartup; // Loop until operation is done. while(!oper.isDone) { // Compute real progress (Unity always reserve '0.1' for activation stage, so it's better to ommit that value). float progress = Mathf.Clamp01(oper.progress/0.9F); // Change slider progress. Instance.progress_slider.value=progress; // Yield until next frame. yield return null; } // Compute duration of operation. duration = Time.realtimeSinceStartup - duration; // If duration of operation was shorter than 1 second. if(duration < 1.0F) { // Yield to at least 1 full second (this is only for purpose of showing loading panel at least 1 second). yield return new WaitForSecondsRealtime(1.0F - duration); } // Disable loading panel. Instance.loading_panel.SetActive(false); } // If not asynchronouse mode. else { // Load next level. SceneManager.LoadScene(LvlNameDecode(Instance.cur_lvl)); } } // End of LvlLoadNextWithDelay
protected void Page_Init() { if (!db.Connect()) { userLvl = Lvls.Guest; goto End; } if (Session.Count == 0) userLvl = Lvls.Guest; else { System.Data.SqlClient.SqlDataReader reader = db.Query("SELECT email, lvl FROM " + Globals.DbName + ".[User] WHERE email=@p1", Session["email"]); if (!reader.HasRows || reader == null) { userLvl = Lvls.Guest; goto End; } reader.Read(); userLvl = (Lvls)int.Parse(reader["lvl"].ToString()); reader.Dispose(); } End: nav.AddSiteMap(Server.MapPath("/User/"+userLvl.ToString()+".sitemap")); }
} // End of SceneNameDecode // Decode level name. private string LvlNameDecode(Lvls lvl) { switch(lvl) { case Lvls.Lvl_01: { return "03_Lvl_01"; } case Lvls.Lvl_02: { return "03_Lvl_02"; } default: { throw new System.Exception("Cannot load level ["+lvl.ToString()+"]"); } } } // End of LvlNameDecode
public void AddLvl(int lvl) { Lvls.Add(lvl); Questions.listQuests.Add(lvl, new List <Question>()); }