Ejemplo n.º 1
0
        protected override async void Run(ETModel.Session session, Actor_ForceOffline message)
        {
            try
            {
                HeartBeat.getInstance().stopHeartBeat();

                {
                    UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("提示", message.Reason);
                    script.setOnClickOkEvent(() =>
                    {
                        //Game.Scene.GetComponent<UIComponent>().RemoveAll();
                        //CommonUtil.ShowUI(UIType.UILogin);

                        Application.Quit();
                    });

                    script.setOnClickCloseEvent(() =>
                    {
                        //Game.Scene.GetComponent<UIComponent>().RemoveAll();
                        //CommonUtil.ShowUI(UIType.UILogin);

                        Application.Quit();
                    });
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 2
0
        private void ShowNotice()
        {
            for (int i = 0; i < NoticeConfig.getInstance().getDataList().Count; i++)
            {
                NoticeInfo config = NoticeConfig.getInstance().getDataList()[i];

                string key = $"{PlayerInfoComponent.Instance.uid}{config.id}";
                if (PlayerPrefs.GetInt(key) != 1)
                {
                    PlayerPrefs.SetInt(key, 1);
                    UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel(config.title, config.content);
                    script.setOnClickOkEvent(() =>
                    {
                        Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel);
                        ShowNotice();
                    });

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

                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private async void CreateRoom()
        {
            FriendRoomInfo info = new FriendRoomInfo();

            info.Hua      = curHua;
            info.Ju       = curJu;
            info.IsPublic = curType;
            info.KeyCount = curKey;

            UINetLoadingComponent.showNetLoading();
            G2C_CreateFriendRoom c2gCreate =
                (G2C_CreateFriendRoom)await SessionComponent.Instance.Session.Call(new C2G_CreateFriendRoom
            {
                FriendRoomInfo = info,
                UserId         = PlayerInfoComponent.Instance.uid
            });

            if (c2gCreate.Error != ErrorCode.ERR_Success)
            {
                UICommonPanelComponent panel = UICommonPanelComponent.showCommonPanel("提示", c2gCreate.Message);
                if (c2gCreate.Error != ErrorCode.ERR_RoomNoExist)
                {
                    panel.setOnClickOkEvent(OpenShop);
                }
                UINetLoadingComponent.closeNetLoading();
                return;
            }

            await UIJoinRoomComponent.EnterFriendRoom(c2gCreate.RoomId.ToString());
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        public static async Task EnterFriendRoom(string curEnterValue)
        {
            if (curEnterValue.Length >= 6)
            {
                //向服务器发送消息
                // ToastScript.createToast(curEnterValue);
                //如果curRoomId不为0,则是点击私密房间
                if (curRoomId != 0)
                {
                    if (curRoomId != Convert.ToInt64(curEnterValue))
                    {
                        UICommonPanelComponent.showCommonPanel("提示", "房间号输入错误,请重新输入!");
                        return;
                    }
                }
                UINetLoadingComponent.showNetLoading();
                G2C_EnterRoom g2CEnterRoom = (G2C_EnterRoom)await SessionComponent.Instance.Session.Call(new C2G_EnterRoom()
                {
                    RoomType = 3,
                    RoomId   = Convert.ToInt32(curEnterValue)
                });

                Game.Scene.GetComponent <UIComponent>().Remove(UIType.UIJoinRoom);
                UINetLoadingComponent.closeNetLoading();
                if (g2CEnterRoom.Error != ErrorCode.ERR_Success)
                {
                    UICommonPanelComponent.showCommonPanel("提示", g2CEnterRoom.Message);
                    return;
                }
            }
        }
        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);
            }
        }
Ejemplo n.º 7
0
        public async void Update()
        {
            // 如果还没有建立Session直接返回、或者没有到达发包时间
            if ((Time.time - RecordDeltaTime < SendInterval))
            {
                return;
            }
            // 记录当前时间
            this.RecordDeltaTime = Time.time;
            // 开始发包
            try
            {
                G2C_HeartBeat g2cHeartBeat = (G2C_HeartBeat)await SessionComponent.Instance.Session.Call(new C2G_HeartBeat { });
            }
            catch
            {
                // 执行断线后的操作 Debug.Log(“断线了”);
                UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("提示", "与服务器断开连接,请重新登录。");
                script.setOnClickOkEvent(() =>
                {
                    Game.Scene.GetComponent <UIComponent>().RemoveAll();
                    Game.Scene.GetComponent <UIComponent>().Create(UIType.UILogin);
                });

                script.setOnClickCloseEvent(() =>
                {
                    Game.Scene.GetComponent <UIComponent>().RemoveAll();
                    Game.Scene.GetComponent <UIComponent>().Create(UIType.UILogin);
                });
            }
        }
Ejemplo n.º 8
0
        public async void reqHeartBeat()
        {
            try
            {
                G2C_HeartBeat g2cHeartBeat = (G2C_HeartBeat)await SessionComponent.Instance.Session.Call(new C2G_HeartBeat { });
            }
            catch (Exception ex)
            {
                if (!isStopHeartBeat)
                {
                    stopHeartBeat();

                    //Game.Scene.GetComponent<UIComponent>().Create(UIType.UINetError);

                    if (GameUtil.GetComponentByType <UIMainComponent>(UIType.UIMain) != null)
                    {
                        GameUtil.GetComponentByType <UIMainComponent>(UIType.UIMain).StopFriendReq();
                    }

                    UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("提示", "与服务器断开连接,请重新登录。");
                    script.setOnClickOkEvent(() =>
                    {
#if GM
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGMLogin);
#else
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UILogin);
#endif
                    });

                    script.setOnClickCloseEvent(() =>
                    {
#if GM
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UIGMLogin);
#else
                        Game.Scene.GetComponent <UIComponent>().RemoveAll();
                        Game.Scene.GetComponent <UIComponent>().Create(UIType.UILogin);
#endif
                    });
                }
            }
        }
Ejemplo n.º 9
0
        public void showGuiZe()
        {
            string content = "1、每完成一次对局可获得一次转盘机会,每日最高3次\r\n\r\n2、贵族用户每日额外赠送一次机会\r\n\r\n";

            if (!OtherData.getIsShiedShare())
            {
                content += "3、以上转盘次数用完后分享游戏可额外获得一次机会";
            }

            UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("规则", content);

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

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

            script.Text_content.alignment = TextAnchor.MiddleLeft;
        }
Ejemplo n.º 10
0
        protected override void Run(ETModel.Session session, Actor_EmergencyNotice message)
        {
            try
            {
                // HeartBeat.getInstance().stopHeartBeat();

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

                    script.setOnClickCloseEvent(() =>
                    {
                        Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel);
                    });
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 11
0
        public void Update()
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Log.Info("第三方返回:" + PlatformHelper.isThirdSDKQuit());

                if (PlatformHelper.isThirdSDKQuit())
                {
                    PlatformHelper.thirdSDKQuit("AnroidCallBack", "", "");
                }
                else
                {
                    // 不在游戏内,退出整个游戏
                    if (Game.Scene.GetComponent <UIComponent>().Get(UIType.UIRoom) == null)
                    {
                        UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel("通知", "是否退出游戏?");
                        script.setOnClickOkEvent(() =>
                        {
                            Application.Quit();
                        });

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

                        script.getTextObj().alignment = TextAnchor.MiddleCenter;
                    }
                    // 在游戏内,退回到主界面
                    else
                    {
                        UIRoomComponent.OnExit();
                    }
                }
            }
        }