/** * 添加列表项 * */ public void AddItem(System.Object sender, TaskEventArgs e) { GameObject a = Instantiate(item) as GameObject; a.transform.SetParent(content.transform); TaskItem t = a.GetComponent <TaskItem>(); dictionary.Add(e.taskID, t); t.Init(e); }
//添加列表项 public void AddItem(System.Object sender, TaskEventArgs e) { GameObject a = Instantiate(item) as GameObject; a.transform.parent = content.transform; a.transform.localPosition = new Vector3(itemLocalPos.x, itemLocalPos.y - dictionary.Count * itemHeight, 0); TaskItem t = a.GetComponent <TaskItem>(); dictionary.Add(e.taskID, t); t.Init(e); if (contentSize.y <= dictionary.Count * itemHeight)//增加内容的高度 { content.GetComponent <RectTransform>().sizeDelta = new Vector2(contentSize.x, dictionary.Count * itemHeight); } }
public void LoadItem(TaskEventArgs e) { item = Resources.Load("Item") as GameObject; GameObject a = Instantiate(item) as GameObject; a.transform.SetParent(content.transform); //a.transform.localPosition = new Vector3(itemLocalPos.x, itemLocalPos.y - dictionary.Count * itemHeight, 0); TaskItem t = a.GetComponent <TaskItem>(); dictionary.Add(e.taskID, t); t.Init(e); /* * if (contentSize.y <= dictionary.Count * itemHeight)//增加内容的高度 * { * content.GetComponent<RectTransform>().sizeDelta = new Vector2(contentSize.x, dictionary.Count * itemHeight); * }*/ }
public void UpdateTaskDate() { if (m_TaskUI.activeSelf != true) { return; } if (PlayerRole.Instance.TaskManager.GetTaskArray() == null) { return; } m_TaskList.Clear(); ClearGrid(); m_ScrollTrans.localPosition = new Vector3(0, 2, 0); m_UIPanel.clipOffset = new Vector2(0, -2); m_UIScrollView.ResetPosition(); foreach (KeyValuePair <byte, RoleTaskBase> map in PlayerRole.Instance.TaskManager.GetTaskArray()) { TaskItem item = new TaskItem(); item.Init(m_TaskItemObj); string taskName = FishConfig.Instance.m_TaskInfo.m_TaskStr[map.Value.pConfig.TaskID].TaskName; string taskDes = FishConfig.Instance.m_TaskInfo.m_TaskStr[map.Value.pConfig.TaskID].TaskDec; string taskIcon = FishConfig.Instance.m_TaskInfo.m_TaskStr[map.Value.pConfig.TaskID].TaskIcon; uint curTaskValue = PlayerRole.Instance.TaskManager.GetTask(map.Value.pConfig.TaskID).pTaskInfo.TaskValue; uint TaskValueMax = PlayerRole.Instance.TaskManager.GetTask(map.Value.pConfig.TaskID).pConfig.TaskEventInfo.FinishValue; tagRewardOnce pOnce = FishConfig.Instance.GetRewardOnceByID(map.Value.pConfig.RewardID); item.SetTaskDate(pOnce, map.Value.pConfig.TaskID, taskDes, taskName, taskIcon); item.UpdateTaskProgress(curTaskValue, TaskValueMax, map.Value.m_TaskEventIsFinish); if (map.Value.m_TaskEventIsFinish) { item.UpdateTaskBg(m_TaskBgTex); } m_TaskList.Add(item); } m_TaskList.Sort(CompareItemBySate); for (int i = 0; i < m_TaskList.Count; ++i) { m_UITaskGrid.AddChild(m_TaskList[i].m_BaseTrans); m_TaskList[i].ResetLocalScale(); } }
void InitTaskItem(RoleTaskBase value) { TaskItem item = new TaskItem(); item.Init(m_Scroll.m_BaseChild, false); tagTaskStrInfo taskStrInfo = FishConfig.Instance.m_TaskInfo.m_TaskStr[value.pConfig.TaskID]; string taskName = taskStrInfo.TaskName; string taskDes = taskStrInfo.TaskDec; uint curTaskValue = PlayerRole.Instance.TaskManager.GetTask(value.pConfig.TaskID).pTaskInfo.TaskValue; uint TaskValueMax = value.pConfig.TaskEventInfo.FinishValue; tagRewardOnce pOnce = FishConfig.Instance.GetRewardOnceByID(value.pConfig.RewardID); item.SetTaskDate(pOnce, value.pConfig.TaskID, taskDes, taskName, taskStrInfo.TaskIcon); item.UpdateTaskProgress(curTaskValue, TaskValueMax, value.m_TaskEventIsFinish); if (value.m_TaskEventIsFinish) { item.UpdateTaskBg(m_TaskBgTex[1]); } else { item.UpdateTaskBg(m_TaskBgTex[0]); } m_TaskList.Add(item); }