using System; using System.Linq; using UnityEngine; using UnityEngine.UI; using vnxbqy.UI; public class CrossServerGodBattleFieldAssortApplicationListWin : Window { [SerializeField] TextEx txtCount; [SerializeField] ButtonEx btnClose; [SerializeField] ButtonEx btnBatchNo; [SerializeField] Button btnAutoJoin; [SerializeField] Image imgAutoJoin; [SerializeField] ScrollerController scroller; [SerializeField] InputField inputField; bool isHaveTeam; bool isCaptain; uint teamID; AssortTeamInfo teamInfo; CrossServerGodBattleFieldAssortModel model { get { return ModelCenter.Instance.GetModel(); } } protected override void BindController() { } protected override void AddListeners() { btnClose.SetListener(CloseClick); btnBatchNo.SetListener(BatchNo); btnAutoJoin.SetListener(AutoJoin); inputField.RemoveAllListeners(); inputField.onEndEdit.AddListener(OnInputFieldEndEdit); } private void OnInputFieldEndEdit(string str) { long result; if (long.TryParse(str, out result)) { model.nowPowerNum = result; } else { model.nowPowerNum = 0; } model.SavePowerNum(); SendPack(); } protected override void OnPreOpen() { scroller.OnRefreshCell += OnRefreshCell; model.UpdateTeamInfoEvent += OnUpdateTeamInfoEvent; model.UpdateTeamDissolveEvent += OnUpdateTeamDissolveEvent; Display(); } private void OnRefreshCell(ScrollerDataType type, CellView cell) { var _cell = cell as CrossServerGodBattleFieldAssortApplicationListCell; _cell.Display(_cell.index, cell); } void CreateScroller() { scroller.Refresh(); var keys = teamInfo.ApplicantDict.Keys.ToList(); keys = model.GetApplicantSortList(keys); for (int i = 0; i < keys.Count; i++) { uint playerId = keys[i]; CellInfo cellInfo = new CellInfo(); cellInfo.infoInt1 = (int)playerId; scroller.AddCell(ScrollerDataType.Header, i, cellInfo); } scroller.Restart(); } void Display() { isHaveTeam = model.TryGetPlayerTeamInfo(out isCaptain, out teamID, out teamInfo); if (!isHaveTeam || teamInfo.ApplicantDict == null) { WindowCenter.Instance.Close(); return; } inputField.text = model.nowPowerNum.ToString(); imgAutoJoin.SetActive(model.isAutoJoin); txtCount.text = Language.Get("GodBattleFieldAssort21", StringUtility.Contact(teamInfo.ApplicantDict.Count, "/", FunctionTeamSetConfig.Get((int)model.FuncMapID).ApplyMax)); } protected override void OnAfterOpen() { CreateScroller(); } protected override void OnAfterClose() { } private void OnUpdateTeamInfoEvent() { Display(); CreateScroller(); } void OnUpdateTeamDissolveEvent() { bool isHaveTeam = model.TryGetPlayerTeamInfo(out bool isCaptain, out uint teamID, out AssortTeamInfo teamInfo); if (!isHaveTeam) { WindowCenter.Instance.Close(); } } protected override void OnPreClose() { scroller.OnRefreshCell -= OnRefreshCell; model.UpdateTeamInfoEvent -= OnUpdateTeamInfoEvent; model.UpdateTeamDissolveEvent -= OnUpdateTeamDissolveEvent; } void BatchNo() { if (model.IsOpenAction()) { SysNotifyMgr.Instance.ShowTip("GodBattleFieldAssort03"); return; } model.SendFuncTeamMemOP(teamID, model.FuncMapID, 4, 0); } void AutoJoin() { if (model.IsOpenAction()) { SysNotifyMgr.Instance.ShowTip("GodBattleFieldAssort03"); return; } model.isAutoJoin = !model.isAutoJoin; LocalSave.SetBool(StringUtility.Contact("gszczd_toggle1_", PlayerDatas.Instance.baseData.PlayerID), model.isAutoJoin); imgAutoJoin.SetActive(model.isAutoJoin); SendPack(); } void SendPack() { ulong minFightPower = ulong.Parse(inputField.text) % Constants.ExpPointValue; ulong minFightPowerEx = ulong.Parse(inputField.text) / Constants.ExpPointValue; int needCheck = model.isAutoJoin ? 0 : 1; model.SendChangeFuncTeam(teamID, model.FuncMapID, 0, (uint)minFightPower, (uint)minFightPowerEx, 0, (byte)needCheck); } }