Exemplo n.º 1
0
        public static void OnExit()
        {
            try
            {
                if (!IsFriendRoom)
                {
                    UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("通知", "是否退出房间?");
                    script.setOnClickOkEvent(() =>
                    {
                        SessionComponent.Instance.Session.Send(new Actor_GamerExitRoom()
                        {
                            IsFromClient = true
                        });
                        if (ISGaming)
                        {
                            CommonUtil.ShowUI(UIType.UIMain);
                            GameUtil.Back2Main();
                        }
                    });

                    script.setOnClickCloseEvent(() =>
                    {
                        Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel);
                    });

                    script.getTextObj().alignment = TextAnchor.MiddleCenter;
                }
                //好友房硬件返回屏蔽
                else
                {
                    if (!ISGaming && CurrentJuCount == 0)
                    {
                        UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("通知", "是否退出房间?");
                        script.setOnClickOkEvent(() =>
                        {
                            SessionComponent.Instance.Session.Send(new Actor_GamerExitRoom()
                            {
                                IsFromClient = true
                            });
                            if (ISGaming)
                            {
                                CommonUtil.ShowUI(UIType.UIMain);
                                GameUtil.Back2Main();
                            }
                        });

                        script.setOnClickCloseEvent(() =>
                        {
                            Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel);
                        });

                        script.getTextObj().alignment = TextAnchor.MiddleCenter;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
        protected override async void Run(ETModel.Session session, Actor_GamerReadyTimeOut message)
        {
            try
            {
                Log.Info($"收到准备超时:{message.Message}");
                CommonUtil.ShowUI(UIType.UIMain);
                GameUtil.Back2Main();

                {
                    UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("通知", message.Message);
                    script.setOnClickOkEvent(() =>
                    {
                        Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel);
                    });

                    script.setOnClickCloseEvent(() =>
                    {
                        Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel);
                    });

                    script.getTextObj().alignment = TextAnchor.MiddleCenter;
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Exemplo n.º 3
0
        protected override async void Run(ETModel.Session session, Actor_GamerExitRoom message)
        {
            try
            {
                Log.Info($"收到退出");
                UI uiRoom = Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom);

                if (uiRoom == null)
                {
                    return;
                }
//                UI uiReady = Game.Scene.GetComponent<UIComponent>().Get(UIType.UIReady);

                GamerComponent  gamerComponent  = uiRoom.GetComponent <GamerComponent>();
                UIRoomComponent uiRoomComponent = uiRoom.GetComponent <UIRoomComponent>();

//                UIReadyComponent uiReadyComponent = uiReady.GetComponent<UIReadyComponent>();

                if (gamerComponent.LocalGamer.UserID == message.Uid)
                {
                    CommonUtil.ShowUI(UIType.UIMain);
                    GameUtil.Back2Main();
                }
                else
                {
                    Gamer gamer = gamerComponent.Get(message.Uid);
                    gamer?.GetComponent <GamerUIComponent>()?.ResetReadyPanel();
                    uiRoomComponent.RemoveGamer(message.Uid);
                }

                SoundsHelp.Instance.playSound_LiKai();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }