using System.Collections.Generic; using System.Threading.Tasks; using ET; using FairyGUI; using UI.League; using UnityEngine; namespace GFGGame { //联盟申请列表 public class LeagueApplyView : BaseWindow { private UI_LeagueApplyUI _ui; private List _listKeys; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_LeagueApplyUI.PACKAGE_NAME; _ui = UI_LeagueApplyUI.Create(); this.viewCom = _ui.target; isfullScreen = true; // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj"); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zjm_2_2"); _ui.m_btnNoCheck.onClick.Add(OnBtnNoCheckClick); _ui.m_btnRule.onClick.Add(OnBtnRuleClick); _ui.m_btnback.onClick.Add(OnBtnBackClick); _ui.m_list.itemRenderer = RenderListItem; } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); _ui.m_btnNoCheck.selected = !LeagueDataManager.Instance.LeagueData.NeedAudit; UpdateView(); } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void OnBtnBackClick() { ViewManager.GoBackFrom(typeof(LeagueApplyView).FullName); } private void OnBtnRuleClick() { ViewManager.Show(); } private void OnBtnNoCheckClick() { LeagueSproxy.ReqSetLeagueApply(!_ui.m_btnNoCheck.selected).Coroutine(); } private void UpdateView() { _listKeys = new List(LeagueDataManager.Instance.ListApplyDatas.Keys); _ui.m_list.numItems = LeagueDataManager.Instance.ListApplyDatas.Count; } private void RenderListItem(int index, GObject obj) { OtherRoleInfoData roleInfoData = LeagueDataManager.Instance.ListApplyDatas[_listKeys[index]]; UI_ListApplyItem item = UI_ListApplyItem.Proxy(obj); RoleInfoManager.Instance.UpdateHeadWithLv(item.m_comHead, roleInfoData.headId, roleInfoData.headBorderId, roleInfoData.roleLv); item.m_txtName.text = roleInfoData.roleName; if (item.m_btnAgree.data == null) { item.m_btnAgree.onClick.Add(OnBtnAgreeClick); } item.m_btnAgree.data = roleInfoData.roleId; if (item.m_btnRefuse.data == null) { item.m_btnRefuse.onClick.Add(OnBtnRefuseClick); } item.m_btnRefuse.data = roleInfoData.roleId; UI_ListApplyItem.ProxyEnd(); } private async void OnBtnAgreeClick(EventContext context) { long roleId = (long)(context.sender as GObject).data; LeagueHotelCfg hotelCfg = LeagueHotelCfgArray.Instance.GetCfg(LeagueDataManager.Instance.LeagueData.HotelLevel); if (LeagueDataManager.Instance.LeagueData.Num >= hotelCfg.limit) { PromptController.Instance.ShowFloatTextPrompt("雅集满员啦"); return; } bool result = await LeagueSproxy.ReqAuditJoinLeague(roleId, true); if (result) { UpdateView(); } } private async void OnBtnRefuseClick(EventContext context) { long roleId = (long)(context.sender as GObject).data; bool result = await LeagueSproxy.ReqAuditJoinLeague(roleId, false); if (result) { UpdateView(); } } } }