/// <summary> /// Checks the gameConfig update. /// </summary> void CheckConfigUpdate() { //检查配置更新 //string questionUrl = "http://localhost/LightExam/gameConfig.json"; string questionUrl = "http://app.jiakaojingling.com/jkjl/static/dengguang/LightExam/gameConfig.json"; //string questionUrl = "http://loongx.gz01.bdysite.com/LightExam/gameConfig.json"; StartCoroutine(RequestNetworkFile(questionUrl, (result, content, data) => { if (result) { GameVersion gameVersion = LitJson.JsonMapper.ToObject <GameVersion>(content); if (ConfigDataMgr.Instance.gameConfig != null && gameVersion.AppVersion != ConfigDataMgr.Instance.gameConfig.AppVersion) { UIPrompDialog.ShowPromp(UIPrompDialog.PrompType.Confirm, "版本更新", "应用功能版本更新,请退出前往更新?", (confirm) => { if (confirm) { Application.Quit(); } }); } else { GameConfig gameConfig = LitJson.JsonMapper.ToObject <GameConfig>(content); if (ConfigDataMgr.Instance.gameConfig == null || gameVersion.ResVersion != ConfigDataMgr.Instance.gameConfig.ResVersion) { StartCoroutine(UpdateResource(gameConfig)); } else { CheckLoginState(); } } } else if (ConfigDataMgr.Instance.gameConfig != null) { CheckLoginState(); } else { UITipsDialog.ShowTips("题库缺失,请链接网络后重新进入", true); } })); }
public static void CheckNetwork(Callback callback) { successCallback = callback; if (Application.internetReachability != NetworkReachability.NotReachable) { successCallback(); } else { UIPrompDialog.ShowPromp(UIPrompDialog.PrompType.Confirm, title, content, confirm => { if (confirm) { CheckNetwork(successCallback); } }); } }
public void DownLoadCallback(bool result, float prog) { if (!isDownloadFail) { if (result) { downloadProg = prog; } else { isDownloadFail = true; UIPrompDialog.ShowPromp(UIPrompDialog.PrompType.Confirm, "资源加载失败", "请退出游戏后检查网络设置?", confirm => { if (confirm) { Application.Quit(); } }); } } }
IEnumerator BeginLightExam(List <int> examList) { bool isPass = true; //是否通过考试 //bool isBreak = false; //是否中断考试 int totalScore = 100; //考试总成绩 float totalTime = 5f; //考试总时长 //试题开始的提示信息 textQuestion.text = examTip.exam_tip; textAnswer.text = ""; audioObject = AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.GetAudioWithURL(examTip.exam_audio)); Debug.Log(audioObject.playTime); yield return(new WaitForSeconds(audioObject.playTime)); audioObject = null; yield return(new WaitForSeconds(0.5f)); for (int i = 0; i < examList.Count; i++) { sQuestionData question = GameDataMgr.Instance.carInfo.GetQuestionWithId(examList[i]); #region MyRegion textQuestion.text = question.question; textAnswer.text = question.answer; textAnswer.gameObject.SetActive(IsShowAnswer); imgResult.gameObject.SetActive(false); audioObject = AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.GetAudioWithURL(question.audio)); Debug.Log(audioObject.playTime); float playTime = Mathf.Clamp(audioObject.playTime - 0.2f, 0.2f, audioObject.playTime); LowToHigCount = 0;//防止抢先操作 yield return(new WaitForSeconds(playTime)); audioObject = null; Debug.LogWarning("开始答题:" + question.question); if (!string.IsNullOrEmpty(examTip.broadcast_end) && i != 0 && //第一道题不提示ding i != (examList.Count - 1)) //最后一道题不提示ding { Debug.LogWarning("Ding ^^^^^^^^^^^^ "); AudioObject audioBroadcast = AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.GetAudioWithURL(examTip.broadcast_end)); yield return(new WaitForSeconds(audioBroadcast.playTime)); } bool result = GetQuestionResult(question); float delay; if (result) //默认灯光是正确的 { Debug.LogWarning("答案默认正确"); delay = totalTime; isOperation = false; while (delay > 0f) { yield return(null); delay -= Time.deltaTime; if (isOperation) //如果正确时进行其他操作变错误 { Debug.LogWarning("等待时间中进行了操作"); result = false; break; } } } else //默认灯光是不正确 { Debug.LogWarning("答案默认错误"); delay = totalTime; do { yield return(null); delay -= Time.deltaTime; if (isOperation) { isOperation = false; result = GetQuestionResult(question); } } while (delay > 0 && !result); if (result) //等待剩余时间 { Debug.LogWarning("答题时间:" + delay); isOperation = false; delay = Mathf.Clamp(delay, 0f, (i + 1) == examList.Count ? 0.5f : 1f); while (delay > 0f) { yield return(null); delay -= Time.deltaTime; if (isOperation) //如果正确时进行其他操作变错误 { Debug.LogWarning("等待时间中进行了操作"); result = false; break; } } } } textAnswer.gameObject.SetActive(true); imgResult.gameObject.SetActive(true); imgResult.sprite = result ? sprRight : sprError; if (result) { Debug.LogWarning("答题----正确"); yield return(new WaitForSeconds(2.0f)); imgResult.gameObject.SetActive(false); } else { Debug.LogWarning("答题----错误"); AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("error")); yield return(new WaitForSeconds(2.0f)); totalScore -= question.score; } //未通过考试,进行首次提示 if (isPass && totalScore < 90) { Debug.LogWarning("未通过考试---提示"); isPass = false; bool waiting = true; bool choice = false; UIPrompDialog.ShowPromp(UIPrompDialog.PrompType.CancelAndConfirm, "", "考试不合格,是否继续考试?", (confirm) => { choice = confirm; waiting = false; }, "继续考试", "放弃考试"); while (waiting) { yield return(null); } if (!choice) //选择放弃考试 { Debug.LogWarning("放弃考试"); IsLightExam = false; IsChioce = false; yield break; } } #endregion } textQuestion.text = ""; if (isPass) //通过考试 { if (totalScore == 100) //满分通过 { textAnswer.text = "<color=#00ff00>恭喜你满分通过考试!!!</color>"; imgResult.gameObject.SetActive(true); imgResult.sprite = sprRight; AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("right")); } else { textAnswer.text = "<color=#00ff00>恭喜你通过考试!!!</color>"; imgResult.gameObject.SetActive(true); imgResult.sprite = sprRight; AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("right")); } } else //未通过考试 { textAnswer.text = "<color=#ff0000>考试未通过</color>"; imgResult.gameObject.SetActive(true); imgResult.sprite = sprError; AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("error")); PauseQuestion(); } }
public static void ShowPromp(PrompType type, string title, string content, Callback <bool> callback, string confirm = "确定", string cancel = "取消") { UIPrompDialog uIPrompDialog = UIManager.Instance.OpenUI <UIPrompDialog>(); uIPrompDialog.InitWith(type, title, content, callback); }