|
@@ -1,3 +1,4 @@
|
|
|
+using System.Collections.Generic;
|
|
|
using ET;
|
|
|
using FairyGUI;
|
|
|
using UI.League;
|
|
@@ -9,7 +10,8 @@ namespace GFGGame
|
|
|
public class LeagueMemberView : BaseWindow
|
|
|
{
|
|
|
private UI_LeagueMemberUI _ui;
|
|
|
-
|
|
|
+ private LeagueData _leagueData;
|
|
|
+ private List<long> _memberIds;
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
if (_ui != null)
|
|
@@ -28,29 +30,240 @@ namespace GFGGame
|
|
|
this.viewCom = _ui.target;
|
|
|
isfullScreen = true;
|
|
|
|
|
|
- // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
|
|
|
+ _ui.m_btnback.onClick.Add(OnBtnBackClick);
|
|
|
+ _ui.m_btnRecruit.target.onClick.Add(OnBtnRecruitClick);
|
|
|
+ _ui.m_btnApplyList.onClick.Add(OnBtnApplyListClick);
|
|
|
+ _ui.m_btnMemberLog.onClick.Add(OnBtnMemberLogClick);
|
|
|
+ _ui.m_btnExit.onClick.Add(OnBtnExitClick);
|
|
|
+
|
|
|
+ _ui.m_list.itemRenderer = RenderListItem;
|
|
|
+ _ui.m_list.SetVirtual();
|
|
|
}
|
|
|
protected override void AddEventListener()
|
|
|
{
|
|
|
base.AddEventListener();
|
|
|
+ EventAgent.AddEventListener(ConstMessage.LEAGUE_MEMBER_CHANGE, UpdateMember);
|
|
|
|
|
|
}
|
|
|
protected override void OnShown()
|
|
|
{
|
|
|
base.OnShown();
|
|
|
|
|
|
+ UpdateMember();
|
|
|
+ UpdateBtnRecruit();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protected override void OnHide()
|
|
|
{
|
|
|
base.OnHide();
|
|
|
-
|
|
|
+ if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
|
|
|
+ Timers.inst.Remove(OnUpdateTimer);
|
|
|
}
|
|
|
|
|
|
protected override void RemoveEventListener()
|
|
|
{
|
|
|
base.RemoveEventListener();
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.LEAGUE_MEMBER_CHANGE, UpdateMember);
|
|
|
+ }
|
|
|
+ private void OnBtnBackClick()
|
|
|
+ {
|
|
|
+ ViewManager.GoBackFrom(typeof(LeagueMemberView).FullName);
|
|
|
+ }
|
|
|
+ //招募
|
|
|
+ private void OnBtnRecruitClick()
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(GlobalCfgArray.globalCfg.consumeWantedArr[0][0]);
|
|
|
+ long needCount = GlobalCfgArray.globalCfg.consumeWantedArr[0][1];
|
|
|
+ long hasCount = ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.consumeWantedArr[0][0]);
|
|
|
+ if (needCount > hasCount)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("消耗不足");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ string tips = string.Format("是否花费{0}货币发布24小时招募成员信息,并临时增加新加入成员上限?", itemCfg.name);
|
|
|
+ AlertUI.Show(tips).
|
|
|
+ SetLeftButton(true, "取消").
|
|
|
+ SetRightButton(true, "确认", async (object param) =>
|
|
|
+ {
|
|
|
+ bool result = await LeagueSproxy.ReqSendLeagueAD();
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ UpdateBtnRecruit();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //申请列表
|
|
|
+ private void OnBtnApplyListClick()
|
|
|
+ {
|
|
|
+ ViewManager.Show<LeagueApplyView>(null, new object[] { typeof(LeagueMemberView).FullName, null });
|
|
|
+ }
|
|
|
+ //联盟日志
|
|
|
+ private void OnBtnMemberLogClick()
|
|
|
+ {
|
|
|
+ ViewManager.Show<LeagueMemberLogView>(null, new object[] { typeof(LeagueMemberView).FullName, null });
|
|
|
+ }
|
|
|
+ //退出联盟
|
|
|
+ private void OnBtnExitClick()
|
|
|
+ {
|
|
|
+ if (LeagueDataManager.Instance.LeagueData.OwnerId == RoleDataManager.roleId)
|
|
|
+ {
|
|
|
+ AlertUI.Show("一家之主不可无呀,先把会长职位给别人吧~").SetRightButton(true, "确认");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ long joinLeagueTime = LeagueDataManager.Instance.LeagueData.LeagueMemberDatas[RoleDataManager.roleId].JoinLeagueTime;
|
|
|
+ long curTime = TimeHelper.ServerNow();
|
|
|
+ long seconds = (curTime - joinLeagueTime) / 1000;
|
|
|
+ if (seconds < TimeUtil.SECOND_PER_DAY)
|
|
|
+ {
|
|
|
+ AlertUI.Show("您加入的时间不足一天").SetRightButton(true, "确认");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AlertUI.Show("您加入的时间不足一天")
|
|
|
+ .SetLeftButton(true, "取消")
|
|
|
+ .SetRightButton(true, "确认", async (object param) =>
|
|
|
+ {
|
|
|
+ bool result = await LeagueSproxy.ReqQuitLeague();
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ ViewManager.Show<MainUIView>(null, null, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void UpdateMember()
|
|
|
+ {
|
|
|
+ _leagueData = LeagueDataManager.Instance.LeagueData;
|
|
|
+ _memberIds = new List<long>(_leagueData.LeagueMemberDatas.Keys);
|
|
|
+
|
|
|
+ int ownerIndex = _memberIds.IndexOf(_leagueData.OwnerId);
|
|
|
+ if (ownerIndex >= 0) _memberIds.RemoveAt(ownerIndex);
|
|
|
+ int subOwnerIndex = _memberIds.IndexOf(_leagueData.SubOwnerId);
|
|
|
+ if (subOwnerIndex >= 0) _memberIds.RemoveAt(subOwnerIndex);
|
|
|
+
|
|
|
+ _memberIds = SortMemberIds(_memberIds);
|
|
|
+ _ui.m_list.numItems = _memberIds.Count;
|
|
|
+ }
|
|
|
+ private void UpdateBtnRecruit()
|
|
|
+ {
|
|
|
+ ItemUtil.UpdateItemNeedNum(_ui.m_btnRecruit.m_comcost, GlobalCfgArray.globalCfg.consumeWantedArr[0][0], GlobalCfgArray.globalCfg.consumeWantedArr[0][1]);
|
|
|
+ int myPos = _leagueData.LeagueMemberDatas[RoleDataManager.roleId].Pos;
|
|
|
+ bool isLeader = myPos == LeaguePos.Owner || myPos == LeaguePos.SubOwner;
|
|
|
+ long timeCount = (_leagueData.AdEndTime - TimeHelper.ServerNow()) / 1000;
|
|
|
+
|
|
|
+ _ui.m_btnRecruit.target.touchable = timeCount <= 0;
|
|
|
+ _ui.m_btnRecruit.m_comcost.visible = timeCount > 0 ? false : true;
|
|
|
+ _ui.m_btnRecruit.m_txtTime.text = "";
|
|
|
+
|
|
|
+ if (isLeader && timeCount > 0)
|
|
|
+ {
|
|
|
+ _ui.m_btnRecruit.m_txtTime.visible = timeCount > 0 ? true : false;
|
|
|
+ Timers.inst.Add(1, (int)timeCount, OnUpdateTimer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void OnUpdateTimer(object param)
|
|
|
+ {
|
|
|
+ int timeCount = (int)(_leagueData.AdEndTime - TimeHelper.ServerNow()) / 1000;
|
|
|
+ if (timeCount <= 0)
|
|
|
+ {
|
|
|
+ _ui.m_btnRecruit.target.touchable = true;
|
|
|
+ _ui.m_btnRecruit.m_txtTime.text = "";
|
|
|
+ Timers.inst.Remove(OnUpdateTimer);
|
|
|
+ }
|
|
|
+ string time = TimeUtil.FormattingTime5(timeCount);
|
|
|
+ _ui.m_btnRecruit.m_txtTime.text = string.Format("剩余时间:{0}", time);
|
|
|
+ }
|
|
|
+ private void UpdateLeader(GObject obj, long roleId)
|
|
|
+ {
|
|
|
+ LeagueMemberData memberData = _leagueData.LeagueMemberDatas.ContainsKey(roleId) ? _leagueData.LeagueMemberDatas[roleId] : null;
|
|
|
+ UI_ComLeader com = UI_ComLeader.Proxy(obj);
|
|
|
+ if (memberData == null)
|
|
|
+ {
|
|
|
+ RoleInfoManager.Instance.UpdateHead(com.m_comHead, 0, 0);
|
|
|
+ com.m_txtname.text = "虚位以待";
|
|
|
+ com.m_btnAppoint.visible = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ RoleInfoManager.Instance.UpdateHead(com.m_comHead, memberData.RoleInfo.headId, memberData.RoleInfo.headBorderId);
|
|
|
+ com.m_txtname.text = memberData.RoleInfo.roleName;
|
|
|
+ com.m_btnAppoint.visible = memberData.Pos == LeaguePos.SubOwner && _leagueData.LeagueMemberDatas[RoleDataManager.roleId].Pos == LeaguePos.Owner;
|
|
|
+ if (com.m_btnAppoint.data == null)
|
|
|
+ {
|
|
|
+ com.m_btnAppoint.onClick.Add(OnBtnAppointClick);
|
|
|
+ }
|
|
|
+ com.m_btnAppoint.data = memberData;
|
|
|
+ }
|
|
|
+ UI_ComLeader.Proxy();
|
|
|
+ }
|
|
|
+ private void RenderListItem(int index, GObject obj)
|
|
|
+ {
|
|
|
+ LeagueMemberData memberData = _leagueData.LeagueMemberDatas[_memberIds[index]];
|
|
|
+
|
|
|
+ UI_ListMemberItem item = UI_ListMemberItem.Proxy(obj);
|
|
|
+
|
|
|
+ RoleInfoManager.Instance.UpdateHead(item.m_comHead, memberData.RoleInfo.headId, memberData.RoleInfo.headBorderId);
|
|
|
+ item.m_txtName.text = memberData.RoleInfo.roleName;
|
|
|
+ item.m_txtWeekContribuation.text = memberData.WeekContribution.ToString();
|
|
|
+ item.m_txtAllContribuation.text = memberData.AllContribution.ToString();
|
|
|
+ if (memberData.RoleInfo.offlineTimeSec == 0)
|
|
|
+ {
|
|
|
+ item.m_txtState.text = "在线";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TimeUtil.FormattingTime(memberData.RoleInfo.offlineTimeSec, TimeHelper.ServerNow(), out int num, out string strState);
|
|
|
+ strState = strState == "秒" ? "刚刚" : num + strState + "前";
|
|
|
+ item.m_txtState.text = strState;
|
|
|
+ }
|
|
|
+ int myPos = _leagueData.LeagueMemberDatas[RoleDataManager.roleId].Pos;
|
|
|
+
|
|
|
+ item.m_btnAppoint.visible = myPos == LeaguePos.Owner || myPos == LeaguePos.SubOwner;
|
|
|
+ if (item.m_btnAppoint.data == null)
|
|
|
+ {
|
|
|
+ item.m_btnAppoint.onClick.Add(OnBtnAppointClick);
|
|
|
+ }
|
|
|
+ item.m_btnAppoint.data = memberData;
|
|
|
+ UI_ListMemberItem.ProxyEnd();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnBtnAppointClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ LeagueMemberData memberData = obj.data as LeagueMemberData;
|
|
|
+ if (!_leagueData.LeagueMemberDatas.ContainsKey(memberData.RoleInfo.roleId))
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("该玩家已离开雅集");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ViewManager.Show<LeagueMemberAppointView>(memberData, new object[] { typeof(LeagueMemberView).FullName, null });
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<long> SortMemberIds(List<long> memberIds)
|
|
|
+ {
|
|
|
+ memberIds.Sort((long a, long b) =>
|
|
|
+ {
|
|
|
+ LeagueMemberData memberDataA = _leagueData.LeagueMemberDatas[a];
|
|
|
+ LeagueMemberData memberDataB = _leagueData.LeagueMemberDatas[b];
|
|
|
+ if (memberDataA.Pos == LeaguePos.Flower && memberDataB.Pos != LeaguePos.Flower) return 1;
|
|
|
+ if (memberDataA.Pos != LeaguePos.Flower && memberDataB.Pos == LeaguePos.Flower) return -1;
|
|
|
+ if (memberDataA.RoleInfo.offlineTimeSec == 0 && memberDataB.RoleInfo.offlineTimeSec != 0) return 1;
|
|
|
+ if (memberDataA.RoleInfo.offlineTimeSec != 0 && memberDataB.RoleInfo.offlineTimeSec == 0) return -1;
|
|
|
+ if (memberDataA.WeekContribution > memberDataB.WeekContribution) return 1;
|
|
|
+ if (memberDataA.WeekContribution < memberDataB.WeekContribution) return -1;
|
|
|
+ if (memberDataA.AllContribution > memberDataB.AllContribution) return 1;
|
|
|
+ if (memberDataA.AllContribution < memberDataB.AllContribution) return -1;
|
|
|
+ if (memberDataA.RoleInfo.roleLv > memberDataB.RoleInfo.roleLv) return 1;
|
|
|
+ if (memberDataA.RoleInfo.roleLv < memberDataB.RoleInfo.roleLv) return -1;
|
|
|
+ if (a > b) return 1;
|
|
|
+ if (a < b) return -1;
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
|
|
|
+ return memberIds;
|
|
|
}
|
|
|
}
|
|
|
}
|