| | |
| | | using UnityEngine.UI; |
| | | |
| | | /// <summary> |
| | | /// 加入公会界面 |
| | | /// 加入公会界面 :公会查找列表,也是排行榜 |
| | | /// </summary> |
| | | public class GuildJoinWin : UIBase |
| | | { |
| | |
| | | int lastPage = 0; |
| | | protected override void InitComponent() |
| | | { |
| | | findBtn.AddListener(OnFindBtnClick); |
| | | findBtn.AddListener(() => OnFindBtnClick()); |
| | | createGuildBtn.AddListener(OnCreateGuildBtnClick); |
| | | quicklyJoinGuildBtn.AddListener(OnQuicklyJoinGuildBtnClick); |
| | | } |
| | |
| | | { |
| | | findText.text = ""; |
| | | //打开界面默认请求,滚动的时候需要处理页数 |
| | | OnFindBtnClick(); |
| | | QueryGuild(); |
| | | GuildManager.Instance.OnRefreshFairyList += OnRefreshGuildList; |
| | | GuildManager.Instance.MyRequestJoinEvent += MyRequestJoinEvent; |
| | | PlayerDatas.Instance.fairyData.OnRefreshFairyInfo += OnRefreshFairyInfo; |
| | | guildListScroller.OnRefreshCell += RefreshCell; |
| | | Display(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | GuildManager.Instance.OnRefreshFairyList -= OnRefreshGuildList; |
| | | GuildManager.Instance.MyRequestJoinEvent -= MyRequestJoinEvent; |
| | | guildListScroller.OnRefreshCell -= RefreshCell; |
| | | PlayerDatas.Instance.fairyData.OnRefreshFairyInfo -= OnRefreshFairyInfo; |
| | | |
| | | var win = UIManager.Instance.GetUI<MainWin>(); |
| | | if (win) |
| | | win.RestoreFuncBtn(); |
| | | |
| | | } |
| | | |
| | | void OnRefreshFairyInfo() |
| | | { |
| | | //当前界面下有刷新自家的公会数据,说明一定是加入了公会,需主动跳转到公会界面 |
| | | CloseWindow(); |
| | | var win = UIManager.Instance.GetUI<MainWin>(); |
| | | if (win) |
| | | win.ClickFunc(4); |
| | | } |
| | | |
| | | void Display() |
| | |
| | | CreateScroller(); |
| | | } |
| | | |
| | | void MyRequestJoinEvent() |
| | | { |
| | | guildListScroller.m_Scorller.RefreshActiveCellViews(); |
| | | } |
| | | |
| | | |
| | | //列表变小的话 重新创建;列表变大的话,只添加 |
| | | void CreateScroller() |
| | | { |
| | | if (GuildManager.Instance.pageIndexList.Count == 0) |
| | | { |
| | | noGuildTf.SetActive(true); |
| | | guildListScroller.SetActive(false); |
| | | return; |
| | | } |
| | | noGuildTf.SetActive(false); |
| | | guildListScroller.SetActive(true); |
| | | |
| | | var startCount = guildListScroller.GetNumberOfCells(); |
| | | if (startCount > GuildManager.Instance.pageIndexList.Count) |
| | | { |
| | |
| | | guildListScroller.Restart(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | GuildManager.Instance.OnRefreshFairyList -= OnRefreshGuildList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | void OnRefreshGuildList() |
| | |
| | | CreateScroller(); |
| | | } |
| | | |
| | | void RefreshCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell.GetComponent<GuildViewListCell>(); |
| | | _cell.Display(cell.index); |
| | | } |
| | | |
| | | private void OnFindBtnClick() |
| | | { |
| | | lastQuery = findText.text; |
| | | var nowQuery = findText.text; |
| | | if (string.IsNullOrEmpty(nowQuery) && string.IsNullOrEmpty(lastQuery)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("GuildSys5"); |
| | | return; |
| | | } |
| | | if (nowQuery.Length < 2 && nowQuery.Length > 0) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("GuildSys7"); |
| | | return; |
| | | } |
| | | |
| | | lastQuery = nowQuery; |
| | | lastPage = 0; |
| | | guildListScroller.Refresh(); |
| | | GuildManager.Instance.SendFindGuild(lastQuery); |
| | | } |
| | | |
| | | |
| | | void QueryGuild() |
| | | { |
| | | lastQuery = ""; |
| | | lastPage = 0; |
| | | guildListScroller.Refresh(); |
| | | GuildManager.Instance.SendFindGuild(lastQuery); |
| | |
| | | |
| | | private void OnCreateGuildBtnClick() |
| | | { |
| | | // TODO: 实现创建公会逻辑 |
| | | UIManager.Instance.OpenWindow<GuildCreateWin>(); |
| | | } |
| | | |
| | | private void OnQuicklyJoinGuildBtnClick() |
| | | { |
| | | // TODO: 实现快速加入公会逻辑 |
| | | if (GuildManager.Instance.pageIndexList.Count == 0) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("QuickEnterFamilyFail"); |
| | | return; |
| | | } |
| | | GuildManager.Instance.SendApplyGuild(0, 0); |
| | | |
| | | } |
| | | |