//如果type = UITaskType.None,按玩家最近一次的选择显示 public static UITask Open(UITaskType type = UITaskType.None, System.Action callBack = null) { if (Instance == null) { Object prefab = PrefabLoader.loadFromPack("LS/MissionSys/MissionSysRoot"); if (prefab != null) { GameObject obj = Instantiate(prefab) as GameObject; RED.AddChild(obj, DBUIController.mDBUIInstance._TopRoot); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; obj.transform.localEulerAngles = Vector3.zero; Instance = obj.GetComponent <UITask>(); } } else { if (!Instance.gameObject.activeSelf) { Instance.gameObject.SetActive(true); } Instance.UIInit(); } Instance.exitCallBack = callBack; //if(type != UITaskType.None) Instance.curTaskType = type; return(Instance); }
//服务器任务列表返回 void OnListRequestFinished(BaseHttpRequest request, BaseResponse response) { ComLoading.Close(); if (Core.Data.guideManger.isGuiding) { Core.Data.guideManger.AutoRUN(); } if (response.status != BaseResponse.ERROR) { TaskListResponse res = response as TaskListResponse; foreach (TaskDataResponse data in res.data.tasks) { TaskData tdata = tm[data.id]; if (tdata != null) { tdata.curProgress = data.progress; tdata.Progress = data.condition; if (tdata.Type == 0) { DayTaskList.Add(tdata); } else if (tdata.Type == 1) { MainTaskList.Add(tdata); } } else { Debug.LogError("Not find Task[" + data.id.ToString() + "]"); } } } //如果某种任务完成,优先显示那一类 if (isHaveCompleteTask(ref MainTaskList)) { Core.Data.taskManager.LastSelectedType = 1; } if (isHaveCompleteTask(ref DayTaskList)) { Core.Data.taskManager.LastSelectedType = 0; } if (curTaskType == UITaskType.None) { curTaskType = (UITaskType)Core.Data.taskManager.LastSelectedType; } //每日任务列表可能为空,但主线任务列表永远不会为空 if (DayTaskList.Count == 0) { _view.SetBtnBright(0, 1); curTaskType = UITaskType.MainLine; } RefreshTaskList(); }
/*设置每个元素的显示 * */ public void SetCell(TaskData data) { this.m_data = data; uitype = (UITaskType)data.Type; isSelected = false; string progress = ""; if (data.curProgress != data.Progress) { progress = "(" + data.curProgress.ToString() + "/" + data.Progress.ToString() + ")"; } Lab_Title.text = data.Title.ToString() + progress; Spr_Sign.enabled = data.curProgress == data.Progress; }
/*按钮事件处理 * */ public void OnBtnClick(string btnName) { switch (btnName) { //主线任务 case "Btn_MainLine": if (curTaskType == UITaskType.MainLine) { return; } curTaskType = UITaskType.MainLine; //Debug.Log("Btn_MainLine"); RefreshTaskList(); break; //每日任务 case "Btn_EveryData": if (curTaskType == UITaskType.EveryData) { return; } curTaskType = UITaskType.EveryData; //Debug.Log("Btn_EveryData"); RefreshTaskList(); break; //领取奖励 case "Btn_GetReward": SendGetRewardRequest(); break; //关闭 case "Btn_Close": UIDestory(); break; case "Btn_Jump": TaskJump(); break; } }
//领取任务奖励返回 void OnListGetRewardFinished(BaseHttpRequest request, BaseResponse response) { isSendGetRwewarding = false; ComLoading.Close(); _view.ShowGetRewardFinger(false); if (response.status != BaseResponse.ERROR) { TaskData data = null; TaskRewardResponse res = response as TaskRewardResponse; if (res == null || res.data == null || res.data.award == null) { SQYAlertViewMove.CreateAlertViewMove(Core.Data.stringManager.getString(9124)); return; } GetRewardSucUI.OpenUI(res.data.award, Core.Data.stringManager.getString(5047)); AddRewardToBag(res.data.award); HttpRequest req = request as HttpRequest; Send_TaskReward param = req.ParamMem as Send_TaskReward; if (res.data.nextTask != null) { data = tm[res.data.nextTask.id]; if (data != null) { data.curProgress = res.data.nextTask.progress; data.Progress = res.data.nextTask.condition; } int index = 0; if (curTaskType == UITaskType.EveryData) { index = GetTaskIndex(ref DayTaskList, param.taskId); if (index > -1) { DayTaskList[index] = data; } } else if (curTaskType == UITaskType.MainLine) { index = GetTaskIndex(ref MainTaskList, param.taskId); if (index > -1) { MainTaskList[index] = data; } } } else { if (curTaskType == UITaskType.EveryData) { DeleteTask(ref DayTaskList, param.taskId); } else if (curTaskType == UITaskType.MainLine) { DeleteTask(ref MainTaskList, param.taskId); } } //刷新当前列表 if (curTaskType == UITaskType.EveryData) { if (DayTaskList.Count == 0) { _view.SetBtnBright(0, 1); curTaskType = UITaskType.MainLine; } } if (data == null) { RefreshTaskList(); } else { RefreshTaskList(data.ID); } //刷新任务按钮提示 // Core.Data.taskManager.isHaveTaskComplete = isHaveCompleteTask(ref DayTaskList) || isHaveCompleteTask(ref MainTaskList) ; // UITaskBtnState.Refresh(); _view.ObjectPool[0].isSelected = true; if (FightRoleSelectPanel.Instance == null) { DBUIController.mDBUIInstance.RefreshUserInfo(); } } }