123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using UnityEngine;
- using UnityEngine.PlayerLoop;
- using UnityEngine.UI;
- using static System.Net.Mime.MediaTypeNames;
- namespace ET.Client
- {
- #region 战斗推送相关
- [Event(SceneType.Client)]
- public class JoinRoomPush_AddComponent : AEvent<EventType.JoinRoomPush>
- {
- protected override async ETTask Run(Scene scene, EventType.JoinRoomPush args)
- {
- Log.Error("@@@ 刷新加入房间状态");
- CommonBridge.Instance.SetDispathPush(scene,args);
- }
- }
- [Event(SceneType.Client)]
- public class KickPush_AddComponent : AEvent<EventType.KickPush>
- {
- protected override async ETTask Run(Scene scene, EventType.KickPush args)
- {
- Log.Error("@@@ 刷新T人之后 房间状态");
- CommonBridge.Instance.SetDispathPush(scene,args);
- }
- }
- [Event(SceneType.Client)]
- public class ReadyPush_AddComponent : AEvent<EventType.ReadyPush>
- {
- protected override async ETTask Run(Scene scene, EventType.ReadyPush args)
- {
- Log.Error("@@@ 刷新准备之后 房间状态");
- CommonBridge.Instance.SetDispathPush(scene, args);
- }
- }
-
- [Event(SceneType.Client)]
- public class ReadyStartPush_AddComponent : AEvent<EventType.ReadyStartPush>
- {
- protected override async ETTask Run(Scene scene, EventType.ReadyStartPush args)
- {
- Log.Error("@@@ 刷新准备之后 房间状态");
- CommonBridge.Instance.SetDispathPush(scene, args);
- }
- }
-
- [Event(SceneType.Client)]
- public class GameStartPush_AddComponent : AEvent<EventType.GameStartPush>
- {
- protected override async ETTask Run(Scene scene, EventType.GameStartPush args)
- {
- Log.Error("@@@ 正式开始 发牌");
- CommonBridge.Instance.SetDispathPush(scene, args);
- }
- }
-
- [Event(SceneType.Client)]
- public class GameDrawCardPush_AddComponent : AEvent<EventType.GameDrawCardPush>
- {
- protected override async ETTask Run(Scene scene, EventType.GameDrawCardPush args)
- {
- Log.Error("@@@ 玩家摸牌");
- CommonBridge.Instance.SetDispathPush(scene, args);
- }
- }
- #endregion
- #region 定时器 刷新
- [Invoke(TimerInvokeType.fightTimeShow)]
- public class UIStartFightRoomComponentChecker : ATimer<UIStartFightRoomComponent>
- {
- protected override void Run(UIStartFightRoomComponent self)
- {
- try
- {
- self.Check();
- }
- catch (Exception e)
- {
- Log.Error($"idle check error: {self.Id}\n{e}");
- }
- }
- }
- [Invoke(TimerInvokeType.startFightTimeCount)]
- public class UIStartFightTimeCountChecker : ATimer<UIStartFightRoomComponent>
- {
- protected override void Run(UIStartFightRoomComponent self)
- {
- try
- {
- self.UpdateTimeCount();
- }
- catch (Exception e)
- {
- Log.Error($"idle check error: {self.Id}\n{e}");
- }
- }
- }
- #endregion
- [FriendOf(typeof(UIStartFightRoomComponent))]
- public static class UIStartFightRoomComponentSystem
- {
- public static void Check(this UIStartFightRoomComponent self)
- {
- self.timeTxt.text = string.Format("{0}:{1}", DateTime.Now.Hour, DateTime.Now.Minute);
- }
- public static void UpdateTimeCount(this UIStartFightRoomComponent self)
- {
- if (self.startTimeCount > 0)
- {
- self.timeCountObj.SetActive(true);
- self.timeCountTxt.text = self.startTimeCount.ToString();
- }
- else
- {
- self.timeCountObj.SetActive(false);
- if (self.startTimer > 0)
- TimerComponent.Instance?.Remove(ref self.startTimer);
- }
- self.startTimeCount = self.startTimeCount - 1;
- }
- [ObjectSystem]
- public class UIStartFightRoomComponentAwakeSystem : AwakeSystem<UIStartFightRoomComponent>
- {
- protected override void Awake(UIStartFightRoomComponent self, params object[] param)
- {
- ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
-
- self.houseIcon = rc.Get<GameObject>("houseIcon");
- self.houseIdTxt = rc.Get<GameObject>("houseIdTxt");
- self.gameNumTxt = rc.Get<GameObject>("gameNumTxt");
- self.curResidueTxt = rc.Get<GameObject>("curResidueTxt");
-
- self.wifiImage = rc.Get<GameObject>("wifiImage");
- self.powerImage = rc.Get<GameObject>("powerImage");
- var timeTxt = rc.Get<GameObject>("timeTxt");
- self.timeTxt = timeTxt.GetComponent<UnityEngine.UI.Text>();
- self.menuBtn = rc.Get<GameObject>("menuBtn");
- self.menuBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnMenuBtn(); });
- self.faceBtn = rc.Get<GameObject>("faceBtn");
- self.faceBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnFaceBtn(); });
- self.videoBtn = rc.Get<GameObject>("videoBtn");
- self.videoBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnVideoBtn(); });
-
- self.menuPanel = rc.Get<GameObject>("menuPanel");
- self.menuPanel.SetActive(false);
- self.maskBtn = rc.Get<GameObject>("maskBtn");
- self.maskBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnMenuPanelClose(); });
- self.menuBackBtn = rc.Get<GameObject>("menuBackBtn");
- self.menuBackBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnMenuPanelBack(); });
- self.menuQuitBtn = rc.Get<GameObject>("menuQuitBtn");
- self.menuQuitBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnMenuPanelQuit(); });
- self.menuSettingBtn = rc.Get<GameObject>("menuSettingBtn");
- self.menuSettingBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnMenuPanelSetting(); });
-
- self.facePanel = rc.Get<GameObject>("facePanel");
- self.facePanel.SetActive(false);
- self.fastToggleBtn = rc.Get<GameObject>("fastToggleBtn");
- self.fastToggleBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnFaceFastToggleBtn(0); });
- self.faceToggleBtn = rc.Get<GameObject>("faceToggleBtn");
- self.faceToggleBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnFaceFastToggleBtn(1); });
- self.faceAndVideoObj = rc.Get<GameObject>("faceAndVideoObj");
- self.faceAndVideoObj.SetActive(false);
- self.facePanelCloseBtn = rc.Get<GameObject>("facePanelCloseBtn");
- self.facePanelCloseBtn.GetComponent<Button>().onClick.AddListener(() => { self.facePanel.SetActive(false); });
-
- self.listFastGridBg = rc.Get<GameObject>("listFastGridBg");
- self.listFastGridBg.SetActive(false);
- self.listFastContent = rc.Get<GameObject>("listFastContent");
- self.gridFastItem = rc.Get<GameObject>("gridFastItem");
- self.listFaceGridBg = rc.Get<GameObject>("listFaceGridBg");
- self.listFaceGridBg.SetActive(false);
- self.listFaceContent = rc.Get<GameObject>("listFaceContent");
- self.gridFaceItem = rc.Get<GameObject>("gridFaceItem");
- self.timeCountObj = rc.Get<GameObject>("timeCountObj");
- self.timeCountTxt = rc.Get<GameObject>("timeCountTxt").GetComponent<UnityEngine.UI.Text>();
-
- self.readyBtn = rc.Get<GameObject>("readyBtn");
- self.readyBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnReadyAndInviteBtn(0); });
- self.inviteBtn = rc.Get<GameObject>("inviteBtn");
- self.inviteBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnReadyAndInviteBtn(1); });
- self.fightCardItem = rc.Get<GameObject>("fightCardItem");
- self.fightCardItem.SetActive(false);
- GameUtil.Instance.SetCardCloneItem(self.fightCardItem,0);
- self.fightCardItem1 = rc.Get<GameObject>("fightCardItem1");
- self.fightCardItem1.SetActive(false);
- GameUtil.Instance.SetCardCloneItem(self.fightCardItem1, 1);
- for (int i = 1;i <= 4;i++)
- {
- UIStartFightRoomPlayerCom uIStartFightRoomPlayerCom = new UIStartFightRoomPlayerCom();
- var playerObj = rc.Get<GameObject>("player" + i);
- var playerIconObj = rc.Get<GameObject>("playerIcon" + i);
- var readyImage = rc.Get<GameObject>("readyImage" + i);
- var playerIconImage = playerIconObj.GetComponent<UnityEngine.UI.Image>();
- uIStartFightRoomPlayerCom.playerObj = playerObj;
- uIStartFightRoomPlayerCom.readyImage = readyImage;
- uIStartFightRoomPlayerCom.playerIcon = playerIconImage;
- var fightCardContentNode = rc.Get<GameObject>("fightCardContent" + i);
- uIStartFightRoomPlayerCom.fightCardNode = fightCardContentNode;
- var disCardContentNode = rc.Get<GameObject>("disCardContent" + i);
- uIStartFightRoomPlayerCom.disCardsNode = disCardContentNode;
- self.uIStartFightRoomPlayerComs.Add(uIStartFightRoomPlayerCom);
- playerObj.SetActive(false);
- var playChatObj = rc.Get<GameObject>("playChatObj" + i);
- self.playChatObjList.Add(playChatObj);
- }
- self.Init();
- }
- }
- private static async void Init(this UIStartFightRoomComponent self)
- {
- self.RepeatedTimer = TimerComponent.Instance.NewRepeatedTimer(ConstValue.fightTimeRefreshTime / 2 + 100, TimerInvokeType.fightTimeShow, self);
- var startFightRoomInfo = self.ClientScene().GetComponent<StartFightRoomComponment>().GetStartFightRoomInfo();
- CommonBridge.Instance.dispathPush += DispathPush;
- self.readyBtn.SetActive(true);
- self.inviteBtn.SetActive(true);
- self.houseIdTxt.GetComponent<UnityEngine.UI.Text>().text = startFightRoomInfo.roomInfo.RoomId.ToString();
- self.gameNumTxt.GetComponent<UnityEngine.UI.Text>().text = startFightRoomInfo.roomInfo.OwnerId.ToString();
- self.curResidueTxt.GetComponent<UnityEngine.UI.Text>().text = "0";
- await SoundManager.Instance.PlaySound("common_playing", true);
- }
- private static void DispathPush(Scene scene, object type)
- {
- switch (type)
- {
- case EventType.JoinRoomPush:
- {
- var ui = scene.GetComponent<UIComponent>().Get(UIType.UIStartFightRoom);
- var startFightRoomComponentUI = ui.GetComponent<UIStartFightRoomComponent>();
- var startFightRoomInfo = scene.GetComponent<StartFightRoomComponment>().GetStartFightRoomInfo();
-
- for (int i = 1; i < startFightRoomComponentUI.uIStartFightRoomPlayerComs.Count; i++)
- {
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i].playerObj.SetActive(false);
- }
- if (startFightRoomInfo.roomInfo.OtherInfo != null && startFightRoomInfo.roomInfo.OtherInfo.Count > 0)
- {
- for (int i = 0; i < startFightRoomInfo.roomInfo.OtherInfo.Count; i++)
- {
- var otherPlayInfo = startFightRoomInfo.roomInfo.OtherInfo[i];
- if (i >= startFightRoomComponentUI.uIStartFightRoomPlayerComs.Count - 1)
- {
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].playerObj.SetActive(false);
- }
- else
- {
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].playerObj.SetActive(true);
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].readyImage.SetActive(false);
- }
- }
- }
- break;
- }
- case EventType.KickPush:
- {
- break;
- }
- case EventType.ReadyPush:
- {
- var ui = scene.GetComponent<UIComponent>().Get(UIType.UIStartFightRoom);
- var startFightRoomComponent = ui.GetComponent<UIStartFightRoomComponent>();
- var startFightRoomInfo = scene.GetComponent<StartFightRoomComponment>().GetStartFightRoomInfo();
-
- if (startFightRoomInfo.roomInfo.MyInfo != null)
- {
- startFightRoomComponent.readyBtn.SetActive(startFightRoomInfo.roomInfo.MyInfo.state == 0);
- startFightRoomComponent.inviteBtn.SetActive(startFightRoomInfo.roomInfo.MyInfo.state == 0);
- startFightRoomComponent.uIStartFightRoomPlayerComs[0].playerObj.SetActive(true);
- startFightRoomComponent.faceAndVideoObj.SetActive(true);
- startFightRoomComponent.uIStartFightRoomPlayerComs[0].readyImage.SetActive(startFightRoomInfo.roomInfo.MyInfo.state == 1);
- }
-
- for (int i = 1;i < startFightRoomComponent.uIStartFightRoomPlayerComs.Count;i++)
- {
- startFightRoomComponent.uIStartFightRoomPlayerComs[i].playerObj.SetActive(false);
- }
- if (startFightRoomInfo.roomInfo.OtherInfo != null && startFightRoomInfo.roomInfo.OtherInfo.Count > 0)
- {
- for (int i = 0; i < startFightRoomInfo.roomInfo.OtherInfo.Count; i++)
- {
- var otherPlayInfo = startFightRoomInfo.roomInfo.OtherInfo[i];
- if (i >= startFightRoomComponent.uIStartFightRoomPlayerComs.Count - 1)
- {
- startFightRoomComponent.uIStartFightRoomPlayerComs[i + 1].playerObj.SetActive(false);
- }
- else
- {
- startFightRoomComponent.uIStartFightRoomPlayerComs[i + 1].playerObj.SetActive(true);
- startFightRoomComponent.uIStartFightRoomPlayerComs[i + 1].readyImage.SetActive(otherPlayInfo.state == 1);
- }
- }
- }
- break;
- }
- case EventType.ReadyStartPush:
- {
-
- var startFightRoomInfo = scene.GetComponent<StartFightRoomComponment>().GetStartFightRoomInfo();
- Log.Error("@@@@@ 倒计时: " + startFightRoomInfo.readyStartTimeCount);
- var ui = scene.GetComponent<UIComponent>().Get(UIType.UIStartFightRoom);
- var startFightRoomComponentUI = ui.GetComponent<UIStartFightRoomComponent>();
- startFightRoomComponentUI.startTimeCount = startFightRoomInfo.readyStartTimeCount;
- startFightRoomComponentUI.startTimer = TimerComponent.Instance.NewRepeatedTimer(ConstValue.fightTimeRefreshTime / 2 + 100, TimerInvokeType.startFightTimeCount, startFightRoomComponentUI);
- break;
- }
- case EventType.GameStartPush:
- case EventType.GameDrawCardPush:
- {
-
- var ui = scene.GetComponent<UIComponent>().Get(UIType.UIStartFightRoom);
- var startFightRoomComponentUI = ui.GetComponent<UIStartFightRoomComponent>();
- var startFightRoomInfo = scene.GetComponent<StartFightRoomComponment>().GetStartFightRoomInfo();
- var myCardInfo = startFightRoomInfo.roomInfo.MyInfo;
- var otherCardInfo = startFightRoomInfo.roomInfo.OtherInfo;
- #region 其他玩家牌处理
-
- for (int i = 1; i < startFightRoomComponentUI.uIStartFightRoomPlayerComs.Count; i++)
- {
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i].playerObj.SetActive(false);
- }
- if (otherCardInfo != null && otherCardInfo.Count > 0)
- {
- RefreshPlayCardList(0, otherCardInfo, startFightRoomComponentUI);
- }
- #endregion
- #region 自己牌处理
-
-
- if (myCardInfo != null)
- {
- RefreshPlayCardList(1, new List<PlayerInfo>() { myCardInfo }, startFightRoomComponentUI);
- }
- #endregion
- break;
- }
- }
- }
- #region 右上系统部分
- public static void OnMenuBtn(this UIStartFightRoomComponent self)
- {
- self.menuPanel.SetActive(!self.menuPanel.activeInHierarchy);
- }
- public static async void OnFaceBtn(this UIStartFightRoomComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- self.facePanel.SetActive(true);
- self.LoadChatData(0);
- }
- public static void OnVideoBtn(this UIStartFightRoomComponent self)
- {
- }
- #endregion
- #region 菜单
- public static void OnMenuPanelClose(this UIStartFightRoomComponent self)
- {
- self.menuPanel.SetActive(false);
- }
- public static async void OnMenuPanelBack(this UIStartFightRoomComponent self)
- {
- Action<object> myAction = (param) =>
- {
- int result = (int)param;
- if (result == 1)
- {
- self.ReturnMainUI().Coroutine();
- }
- };
- Dictionary<string,object> dic = new Dictionary<string, object>()
- {
- { "callback",myAction},
- { "title","提示"},
- { "content","返回大厅,你的房间仍会保留。"},
- { "yesTxt","确定"},
- { "cancelTxt","取消"},
- };
- await SoundManager.Instance.PlaySound("clickbtnsound");
- await UIHelper.Create(self.ClientScene(), UIType.UIAlert, UILayer.High, dic);
- }
- public static void OnMenuPanelQuit(this UIStartFightRoomComponent self)
- {
- }
- public static void OnMenuPanelSetting(this UIStartFightRoomComponent self)
- {
- }
- #endregion
- #region 表情
- public static async void OnFaceFastToggleBtn(this UIStartFightRoomComponent self,int index)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- self.LoadChatData(index);
- }
- static async void LoadChatData(this UIStartFightRoomComponent self, int index)
- {
- self.listFaceGridBg.SetActive(false);
- self.listFastGridBg.SetActive(false);
- string[] abName = new string[] { "com_bg1", "com_bg2" };
- await ResourcesComponentHelper.Instance.LoadSprite(self.ClientScene(), "commonatlas");
- Sprite sprite = ResourcesComponentHelper.Instance.GetSprite("commonatlas", abName[0]);
- Sprite sprite1 = ResourcesComponentHelper.Instance.GetSprite("commonatlas", abName[1]);
- self.fastToggleBtn.GetComponent<UnityEngine.UI.Image>().sprite = index == 0 ? sprite: sprite1;
- self.faceToggleBtn.GetComponent<UnityEngine.UI.Image>().sprite = index == 1 ? sprite : sprite1;
- self.CleanChatItem(index);
- if (index == 0)
- {
- self.listFastGridBg.SetActive(true);
- var startFightRoomInfo = self.ClientScene().GetComponent<StartFightRoomComponment>().GetStartFightRoomInfo();
- int sexType = startFightRoomInfo.roomInfo.MyInfo.sex;
- var fightConfig = FightChatConfigCategory.Instance.GetAll();
- var achievedDic = fightConfig.Where(kvp => kvp.Value.Type == sexType);
- foreach (var item in achievedDic)
- {
- if (GameObjectPool.Instance.chatFastItemPools.Count > 0)
- {
- GameObject uiFastItem = GameObjectPool.Instance.chatFastItemPools[0];
- GameObjectPool.Instance.chatFastItemPools.RemoveAt(0);
- uiFastItem.SetActive(true);
- uiFastItem.transform.SetParent(self.listFastContent.transform, false);
- var txt = uiFastItem.GetComponentInChildren<UnityEngine.UI.Text>();
- txt.text = item.Value.Content;
- var btn = txt.gameObject.GetComponent<Button>();
- btn.onClick.RemoveAllListeners();
- btn.onClick.AddListener(async () =>
- {
- Log.Error("btn click1: " + item.Value.Content + " vedio: " + item.Value.VedioPath);
- await SoundManager.Instance.PlaySound(item.Value.VedioPath);
- self.facePanel.SetActive(false);
- self.playChatObjList[0].SetActive(true);
- var playChatTxt = self.playChatObjList[0].GetComponentInChildren<UnityEngine.UI.Text>();
- playChatTxt.text = item.Value.Content;
- await TimerComponent.Instance.WaitAsync(3000);
- self.playChatObjList[0].SetActive(false);
- });
- }
- else
- {
- var uiFastItem = GameUtil.Instance.InitializeObj(self.gridFastItem);
- uiFastItem.gameObject.SetActive(true);
- uiFastItem.transform.SetParent(self.listFastContent.transform, false);
- var txt = uiFastItem.GetComponentInChildren<UnityEngine.UI.Text>();
- txt.text = item.Value.Content;
- var btn = txt.gameObject.GetComponent<Button>();
- btn.onClick.RemoveAllListeners();
- btn.onClick.AddListener(() =>
- {
- Log.Error("btn click2: " + item.Value.Content);
- });
- }
- }
- }
- else
- {
-
- }
- }
- static void CleanChatItem(this UIStartFightRoomComponent self,int index)
- {
- Transform node = null;
- List<GameObject> list = null;
- if (index == 0)
- {
- node = self.listFastContent.transform;
- list = GameObjectPool.Instance.chatFastItemPools;
- }
- else
- {
- node = self.listFaceContent.transform;
- list = GameObjectPool.Instance.chatFaceItemPools;
- }
- for (int i = 0; i < node.childCount; i++)
- {
- var child = node.GetChild(i);
- list.Add(child.gameObject);
- child.gameObject.SetActive(false);
- }
- }
- #endregion
- #region 邀请以及准备
- public static void OnReadyAndInviteBtn(this UIStartFightRoomComponent self, int index)
- {
- if (index == 0)
- {
- self.ReadyRes().Coroutine();
- }
- else
- {
-
- }
- }
- #endregion
- public static void SetBattery()
- {
-
-
-
-
-
- }
- static async ETTask ReturnMainUI(this UIStartFightRoomComponent self)
- {
- var scene = self.ClientScene();
- await UIHelper.Remove(scene, UIType.UIStartFightRoom);
- var startFightRoomInfo = scene.GetComponent<StartFightRoomComponment>().GetStartFightRoomInfo();
- Dictionary<string, object> dic = new Dictionary<string, object>()
- {
- { "result",1},
- { "roomId",startFightRoomInfo.roomInfo.RoomId.ToString()}
- };
- await UIHelper.Create(scene, UIType.UIMain, UILayer.Mid, dic);
- }
- static async ETTask ReadyRes(this UIStartFightRoomComponent self)
- {
-
- {
- var scene = self.ClientScene();
- var session = scene.GetComponent<SessionComponent>().Session;
- if (session != null)
- {
- G2C_Ready g2Ready = (G2C_Ready)await session.Call(
- new C2G_Ready() { });
- if (g2Ready.Error != ErrorCode.ERR_Success)
- {
- Log.Error($"g2Ready错误...errCode={g2Ready.Error}" + " mess: " + g2Ready.Message);
- return;
- }
- }
- }
-
-
-
-
- }
- public static async void OnCloseAsync(this UIStartFightRoomComponent self)
- {
- await UIHelper.Remove(self.ClientScene(),UIType.UIStartFightRoom);
- }
- public static async void RefreshPlayCardList(int index, List<PlayerInfo> playerInfos, UIStartFightRoomComponent startFightRoomComponentUI)
- {
- if (index == 0)
- {
- for (int i = 0; i < playerInfos.Count; i++)
- {
- var otherPlayInfo = playerInfos[i];
- if (i >= startFightRoomComponentUI.uIStartFightRoomPlayerComs.Count - 1)
- {
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].playerObj.SetActive(false);
- }
- else
- {
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].playerObj.SetActive(true);
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].readyImage.SetActive(false);
- var fightCardParentNode = startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].fightCardNode;
- var disCardParentNode = startFightRoomComponentUI.uIStartFightRoomPlayerComs[i + 1].disCardsNode;
- CleanCardItemList(fightCardParentNode.transform,0);
- for (int p = 0; p < otherPlayInfo.cardInfo.RemainCardsNum; p++)
- {
- if (GameObjectPool.Instance.fightCardItemPools.Count > 0)
- {
- GameObject uifightItem = GameObjectPool.Instance.fightCardItemPools[0];
- GameObjectPool.Instance.fightCardItemPools.RemoveAt(0);
- uifightItem.gameObject.SetActive(true);
- uifightItem.transform.SetParent(fightCardParentNode.transform, false);
- var sprite = await GameObjectPool.Instance.AcquireSprite(GameSetting.Instance.otherPlayCardSpiteName);
- UnityEngine.UI.Image icon = uifightItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- var btn = icon.gameObject.GetComponent<Button>();
- btn.onClick.RemoveAllListeners();
- btn.onClick.AddListener(() =>
- {
- Log.Error("card Click...");
- });
- }
- else
- {
- int cloneItemIndex = i % 2 == 0? 1 : 0;
- var uifightItem = GameUtil.Instance.InitializeObj(GameUtil.Instance.GetCardCloneItem(cloneItemIndex));
- uifightItem.SetActive(true);
- uifightItem.transform.SetParent(fightCardParentNode.transform, false);
- var sprite = await GameObjectPool.Instance.AcquireSprite(GameSetting.Instance.otherPlayCardSpiteName);
- UnityEngine.UI.Image icon = uifightItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- }
- }
-
- CleanCardItemList(disCardParentNode.transform, 1);
- if (otherPlayInfo.cardInfo.DisCards != null)
- {
- for (int l = 0; l < otherPlayInfo.cardInfo.DisCards.Count; l++)
- {
- int value = otherPlayInfo.cardInfo.DisCards[l];
- if (GameObjectPool.Instance.disCardItemPools.Count > 0)
- {
- GameObject uiDisItem = GameObjectPool.Instance.disCardItemPools[0];
- GameObjectPool.Instance.disCardItemPools.RemoveAt(0);
- uiDisItem.gameObject.SetActive(true);
- uiDisItem.transform.SetParent(disCardParentNode.transform, false);
- var sprite = await GameObjectPool.Instance.AcquireSprite(string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- UnityEngine.UI.Image icon = uiDisItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- }
- else
- {
- int cloneItemIndex = i % 2 == 0 ? 1 : 0;
- var uiDisItem = GameUtil.Instance.InitializeObj(GameUtil.Instance.GetCardCloneItem(cloneItemIndex));
- uiDisItem.SetActive(true);
- uiDisItem.transform.SetParent(disCardParentNode.transform, false);
- var sprite = await GameObjectPool.Instance.AcquireSprite(string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- UnityEngine.UI.Image icon = uiDisItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- }
- }
- }
- }
- }
- }
- else
- {
- var myCardInfo = playerInfos[0];
- if (myCardInfo.cardInfo.RemainCards == null)
- {
- Log.Error("自己牌队列为NULL");
- return;
- }
- var parentNode = startFightRoomComponentUI.uIStartFightRoomPlayerComs[0].fightCardNode;
- var disCardParentNode = startFightRoomComponentUI.uIStartFightRoomPlayerComs[0].disCardsNode;
- startFightRoomComponentUI.uIStartFightRoomPlayerComs[0].readyImage.SetActive(false);
- Log.Error("card数量: " + myCardInfo.cardInfo.RemainCards.Count);
- CleanCardItemList(parentNode.transform,0);
- for (int i = 0; i < myCardInfo.cardInfo.RemainCards.Count;i++)
- {
- var value = myCardInfo.cardInfo.RemainCards[i];
- if (GameObjectPool.Instance.fightCardItemPools.Count > 0)
- {
- GameObject uifightItem = GameObjectPool.Instance.fightCardItemPools[0];
- GameObjectPool.Instance.fightCardItemPools.RemoveAt(0);
- uifightItem.gameObject.SetActive(true);
- uifightItem.transform.SetParent(parentNode.transform, false);
-
- var sprite = await GameObjectPool.Instance.AcquireSprite(string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- UnityEngine.UI.Image icon = uifightItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- var btn = icon.gameObject.GetComponent<Button>();
- btn.onClick.RemoveAllListeners();
- btn.onClick.AddListener(() =>
- {
- Log.Error("card Click... " + string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- });
- }
- else
- {
- var uifightItem = GameUtil.Instance.InitializeObj(GameUtil.Instance.GetCardCloneItem(0));
- uifightItem.gameObject.SetActive(true);
- uifightItem.transform.SetParent(parentNode.transform, false);
- var sprite = await GameObjectPool.Instance.AcquireSprite(string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- UnityEngine.UI.Image icon = uifightItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- icon.gameObject.GetComponent<Button>().onClick.AddListener(() =>
- {
- Log.Error("card Click... " + string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- });
- }
- }
-
- CleanCardItemList(disCardParentNode.transform, 1);
- if (myCardInfo.cardInfo.DisCards != null)
- {
- for (int l = 0; l < myCardInfo.cardInfo.DisCards.Count; l++)
- {
- int value = myCardInfo.cardInfo.DisCards[l];
- if (GameObjectPool.Instance.disCardItemPools.Count > 0)
- {
- GameObject uiDisItem = GameObjectPool.Instance.disCardItemPools[0];
- GameObjectPool.Instance.disCardItemPools.RemoveAt(0);
- uiDisItem.gameObject.SetActive(true);
- uiDisItem.transform.SetParent(disCardParentNode.transform, false);
- var sprite = await GameObjectPool.Instance.AcquireSprite(string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- UnityEngine.UI.Image icon = uiDisItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- }
- else
- {
- var uiDisItem = GameUtil.Instance.InitializeObj(GameUtil.Instance.GetCardCloneItem(0));
- uiDisItem.SetActive(true);
- uiDisItem.transform.SetParent(disCardParentNode.transform, false);
- var sprite = await GameObjectPool.Instance.AcquireSprite(string.Concat(GameSetting.Instance.selfPlayCardSpiteName, value));
- UnityEngine.UI.Image icon = uiDisItem.GetComponentInChildren<UnityEngine.UI.Image>();
- icon.sprite = sprite;
- }
- }
- }
- }
- }
- public static void CleanCardItemList(Transform node,int index)
- {
- List<GameObject> tempList = index == 0? GameObjectPool.Instance.fightCardItemPools: GameObjectPool.Instance.disCardItemPools;
- for (int i = 0;i < node.childCount;i++)
- {
- var child = node.GetChild(i);
- tempList.Add(child.gameObject);
- child.gameObject.SetActive(false);
- }
- }
- [ObjectSystem]
- public class UIStartFightRoomComponentDestroySystem : DestroySystem<UIStartFightRoomComponent>
- {
- protected override void Destroy(UIStartFightRoomComponent self)
- {
- TimerComponent.Instance?.Remove(ref self.RepeatedTimer);
- CommonBridge.Instance.Clear();
- }
- }
- }
- }
|