using System; using Api; using Message; using Plugins.CxShine.page; using Plugins.CxShine.Singleton; using Sound; using TMPro; using UI.BattleRequest; using UI.Common; using UI.Hall; using UI.Items; using UI.Loading; using UnityEditor; using UnityEngine; using UnityEngine.UI; namespace UI { public class HallComp : UnitySingleton { public Transform OnlinePlayerContainer; public GameObject PlayerPrefab; public GameObject FullLoadingPrefab; private GameObject _fullLoadingInstance; public GameObject RefreshButton; public Button DefaultSelectOnlinePlayerTypeButton; public InputField PlayerIdInput; public CockUIItemComp MyCockComp; public GameObject MarketPrefab; public GameObject SettingPagePrefab; public GameObject UpdateInfoPrefab; private OnlinePlayerType _curType = OnlinePlayerType.Friends; public Action OnLoadingCloseAction; private void Start() { MessageComp.Instance.EnterHall = true; // initOnlinePlayers(); SoundCore.Instance.PlaySound(SoundType.HallBgmMain, SoundCtrl.HallBgmPlayer, true, true); BackToHallAndRefreshUI(); Invoke(nameof(TTT), 1.0f); } public void BackToHallAndRefreshUI() { MyCockComp.ModeCockMy(); UserInfoComp.Instance.RefreshSelfUI(); } public void HideSelf() { PageManagerComp.singleton.HideUI(); } private void TTT() { DefaultSelectOnlinePlayerTypeButton.onClick.Invoke(); // GameStartJumper.JumpGameScene("100020VS100019:1680153980543:WNBIDVLNYT"); } public void A__ClickUpdateInfo() { PageManagerComp.singleton.OpenPage(UpdateInfoPrefab); } public void A__ClickSetting() { PageManagerComp.singleton.OpenPage(SettingPagePrefab); } public void OpenLoading() { if (_fullLoadingInstance == null) { _fullLoadingInstance = PageManagerComp.singleton.OpenPage(FullLoadingPrefab); _fullLoadingInstance.GetComponent().setOnPageCloseListener((() => { _fullLoadingInstance = null; OnLoadingCloseAction?.Invoke(); })); } } public void OpenAutoCloseLoading(int seconds) { OpenLoading(); _fullLoadingInstance.GetComponent().initAutoClose(seconds); } public void CloseLoading() { if (_fullLoadingInstance != null) { var p = _fullLoadingInstance.GetComponent(); p.A__ClosePage(); } } public void A__ClickRefresh() { // TipsComp.ShowTips("sssssss"); initOnlinePlayers(); } public void A__ClickInviteByPlayerId() { // TipsComp.ShowTips("test test test!"); if (!String.IsNullOrEmpty(PlayerIdInput.text)) { int enemyId; int.TryParse(PlayerIdInput.text, out enemyId); if (enemyId > 0) { OnInviteClick(enemyId); } } } public void A__Click_AllOnlinePlayers() { if (_curType == OnlinePlayerType.All) { return; } _curType = OnlinePlayerType.All; initOnlinePlayers(); } public void A__Click_FriendsPlayers() { if (_curType == OnlinePlayerType.Friends) { return; } _curType = OnlinePlayerType.Friends; initOnlinePlayers(); } public void A__Click_IndiaPlayers() { if (_curType == OnlinePlayerType.India) { return; } _curType = OnlinePlayerType.India; initOnlinePlayers(); } private void initOnlinePlayers() { ApiComp.Instance.GetOnlinePlayers(_curType, data => { RemoveTransformAllChild(OnlinePlayerContainer); if (data.players != null) { foreach (var dataPlayer in data.players) { Instantiate(PlayerPrefab, OnlinePlayerContainer, false).GetComponent() .init(OnInviteClick, dataPlayer); } } }, (code, err) => { }); } private void OnInviteClick(int enemyId) { OpenAutoCloseLoading(10); BattleInviteManager.Instance.InviteBattle(enemyId, data => { }, (code, err) => { CloseLoading(); // TipsComp.ShowTips(); }); } public void A__ClickMarket() { PageManagerComp.singleton.OpenPage(MarketPrefab); } } }