| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | 
using System;using System.Collections.Generic;using FairyGUI;using UI.Field;using UnityEngine;namespace GFGGame{    public class FieldTaskView : BaseWindow    {        private UI_FieldTaskUI _ui;        private List<FieldTaskCfg> _cfgs;        private string[] difficulty = new string[] { "初级", "中级", "高级" };        public override void Dispose()        {            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            _ui = UI_FieldTaskUI.Create();            this.viewCom = _ui.target;            this.viewCom.Center();            this.modal = true;            viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;            _ui.m_list.itemRenderer = ListItemRender;        }        protected override void OnShown()        {            base.OnShown();            UpdateList();        }        protected override void OnHide()        {            base.OnHide();        }        private void UpdateList()        {            _cfgs = FieldDataManager.Instance.GetTaskCfgs();            _ui.m_list.numItems = _cfgs.Count;        }        private void ListItemRender(int index, GObject obj)        {            UI_ListItem item = UI_ListItem.Proxy(obj);            FieldCfg cfg = FieldCfgArray.Instance.GetCfg(_cfgs[index].chapterId);            item.m_txtDesc.text = string.Format("{0}难度挑战成功{1}轮", cfg.name, _cfgs[index].target);            item.m_btnGet.m_txtTitle.text = string.Format("每周上限+{0}", _cfgs[index].addRewardLimit);            item.m_btnGet.m_c1.selectedIndex = FieldDataManager.Instance.GetTaskState(_cfgs[index].id);            if (item.m_btnGet.target.data == null)            {                item.m_btnGet.target.onClick.Add(OnBtnGetClick);            }            item.m_btnGet.target.data = _cfgs[index].id;            UI_ListItem.ClearProxy();        }        private async void OnBtnGetClick(EventContext context)        {            int taskId = (int)(context.sender as GObject).data;            int state = FieldDataManager.Instance.GetTaskState(taskId);            if (state == 1)            {                bool result = await FieldSProxy.ReqFieldTaskBonus(taskId);                if (result)                {                    PromptController.Instance.ShowFloatTextPrompt("每周奖励上限提升");                    UpdateList();                }            }        }    }}
 |