public static void TriggerTaskEvent(PlayerTaskTarget taskTarget, int change_num) { int hasFinished = 0; List <AllData_Task> allTask = Save.data.allData.lucky_schedule.user_task; int taskCount = allTask.Count; for (int i = 0; i < taskCount; i++) { AllData_Task task = allTask[i]; if (task.taskTargetId == taskTarget) { if (task.taskTargetId == PlayerTaskTarget.InviteAFriend) { continue; } task.task_cur += change_num; if (!string.IsNullOrEmpty(task.task_describe)) { task.task_describe = task.task_cur + "/" + task.task_tar; } if (task.task_cur >= task.task_tar && !task.task_receive) { task.task_complete = true; hasFinished++; } else { task.task_describe = ""; } } } UI.OnHasTaskFinished(hasFinished > 0); }
private void OnGetTaskListCallback(bool doublReward) { List <AllData_Task> taskDatas = Save.data.allData.lucky_schedule.user_task; AllData_Task inviteTaskData = null; if (taskDatas != null && taskDatas.Count > 0) { foreach (var task in taskDatas) { if (task.taskTargetId == PlayerTaskTarget.InviteAFriend) { inviteTaskData = task; break; } } } if (inviteTaskData == null) { Master.Instance.ShowTip("Error: can not get task id", 2); } else { //Server.Instance.OperationData_FinishTask(OnGetRewardCallback, null, inviteTaskData.task_id, doublReward, Reward.Cash, Reward.Ticket); Server_New.Instance.ConnectToServer_FinishTask(OnGetRewardCallback, null, null, true, inviteTaskData.task_id, doublReward, Reward.Cash, Reward.Ticket); } }
public void RefreshTaskInfo() { foreach (var task in get_tickets_items) { task.gameObject.SetActive(false); } foreach (var task in daily_task_items) { task.gameObject.SetActive(false); } foreach (var task in achievement_task_items) { task.gameObject.SetActive(false); } int getticketsTaskIndex = 0; int dailyTaskIndex = 0; int achievementIndex = 0; List <AllData_Task> taskList = Save.data.allData.lucky_schedule.user_task; int allTaskCount = taskList.Count; for (int i = 0; i < allTaskCount; i++) { AllData_Task taskData = taskList[i]; switch (taskData.task_type) { //gettickets case 1: if (getticketsTaskIndex > get_tickets_items.Count - 1) { TaskItem newTaskItem = Instantiate(single_get_tickets_task.gameObject, single_get_tickets_task.transform.parent).GetComponent <TaskItem>(); get_tickets_items.Add(newTaskItem); } get_tickets_items[getticketsTaskIndex].gameObject.SetActive(true); get_tickets_items[getticketsTaskIndex].Init(taskData.task_id, taskData.task_title, taskData.task_describe, taskData.taskTargetId, taskData.reward_type, taskData.task_reward, taskData.task_receive, taskData.task_complete, 0); getticketsTaskIndex++; break; //daily task case 2: if (dailyTaskIndex > daily_task_items.Count - 1) { TaskItem newTaskItem = Instantiate(single_daily_task.gameObject, single_daily_task.transform.parent).GetComponent <TaskItem>(); daily_task_items.Add(newTaskItem); } daily_task_items[dailyTaskIndex].gameObject.SetActive(true); daily_task_items[dailyTaskIndex].Init(taskData.task_id, taskData.task_title, taskData.task_describe, taskData.taskTargetId, taskData.reward_type, taskData.task_reward, taskData.task_receive, taskData.task_complete, 1); dailyTaskIndex++; break; //achievement case 3: if (achievementIndex > achievement_task_items.Count - 1) { TaskItem newTaskItem = Instantiate(single_achievement_task.gameObject, single_achievement_task.transform.parent).GetComponent <TaskItem>(); achievement_task_items.Add(newTaskItem); } achievement_task_items[achievementIndex].gameObject.SetActive(true); achievement_task_items[achievementIndex].Init(taskData.task_id, taskData.task_title, taskData.task_describe, taskData.taskTargetId, taskData.reward_type, taskData.task_reward, taskData.task_receive, taskData.task_complete, 2); achievementIndex++; break; } } bool hasGetTicketTask = getticketsTaskIndex > 0; all_get_tickets_root.SetActive(hasGetTicketTask); get_tickets_title.SetActive(hasGetTicketTask); bool hasDailyTask = dailyTaskIndex > 0; all_daily_task_root.SetActive(hasDailyTask); daily_task_title.SetActive(hasDailyTask); bool hasAchievementTask = achievementIndex > 0; all_achievement_root.SetActive(hasAchievementTask); achievement_task_title.SetActive(hasAchievementTask); StartCoroutine("DelayRefreshLayout"); }