123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- 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<HallComp>
- {
- 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<PageComp>().setOnPageCloseListener((() =>
- {
- _fullLoadingInstance = null;
- OnLoadingCloseAction?.Invoke();
- }));
- }
- }
- public void OpenAutoCloseLoading(int seconds)
- {
- OpenLoading();
- _fullLoadingInstance.GetComponent<LoadingComp>().initAutoClose(seconds);
- }
- public void CloseLoading()
- {
- if (_fullLoadingInstance != null)
- {
- var p = _fullLoadingInstance.GetComponent<PageComp>();
- 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<OnlinePlayerItemComp>()
- .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);
- }
- }
- }
|