Beispiel #1
0
 public void OnNormalRefreshClick(TaskNormalItem item)
 {
     if (item == normalTask1)
     {
         do
         {
             normalTaskInfo1 = (normalTaskInfo1 + 1) % goldTask.Count;
         } while (normalTaskInfo1 == normalTaskInfo2);
         SettingManager.Instance.NormalItem1 = normalTaskInfo1;
         normalTask1.Reset(goldTask[normalTaskInfo1]);
         normalTask1.Init(goldTask[normalTaskInfo1]);
         normalTask1.description.text = goldTask[normalTaskInfo1].Description;
     }
     else if (item == normalTask2)
     {
         do
         {
             normalTaskInfo2 = (normalTaskInfo2 + 1) % goldTask.Count;
         } while (normalTaskInfo2 == normalTaskInfo1);
         SettingManager.Instance.NormalItem2 = normalTaskInfo2;
         normalTask2.Reset(goldTask[normalTaskInfo2]);
         normalTask2.Init(goldTask[normalTaskInfo2]);
         normalTask2.description.text = goldTask[normalTaskInfo2].Description;
     }
 }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        var data = IOHelper.GetTaskInfos();

        goldTask  = new List <TaskInfo>();
        dailyTask = new List <TaskInfo>();
        growTask  = new List <TaskInfo>();
        foreach (var e in data)
        {
            if (e.type == 1)
            {
                goldTask.Add(e);
            }
            else if (e.type == 2)
            {
                dailyTask.Add(e);
            }
            else if (e.type == 3)
            {
                growTask.Add(e);
            }
        }

        foreach (var e in dailyTask)
        {
            var item = NGUITools.AddChild(grid.gameObject, dailyItemPrefab).GetComponent <TaskDailyItem>();
            item.description.text = e.Description;
            item.Init(e);
        }

        normalTask1     = NGUITools.AddChild(grid.gameObject, normalItemPrefab).GetComponent <TaskNormalItem>();
        normalTask2     = NGUITools.AddChild(grid.gameObject, normalItemPrefab).GetComponent <TaskNormalItem>();
        normalTaskInfo1 = SettingManager.Instance.NormalItem1;
        normalTaskInfo2 = SettingManager.Instance.NormalItem2;
        normalTask1.description.text = goldTask[normalTaskInfo1].Description;
        normalTask1.Init(goldTask[normalTaskInfo1]);
        normalTask2.description.text = goldTask[normalTaskInfo2].Description;
        normalTask2.Init(goldTask[normalTaskInfo2]);

        foreach (var e in growTask)
        {
            var item = NGUITools.AddChild(grid.gameObject, growItemPrefab).GetComponent <TaskGrowItem>();
            item.Init(e);
            item.description.text = e.Description;
        }

        grid.Reposition();
    }