Exemple #1
0
        /// <summary>
        /// 创建房间
        /// </summary>
        private async void OnCreateRoom()
        {
            try
            {
                RoomInfo ToServerinfo = new RoomInfo();
                ToServerinfo.GameCount   = 10;
                ToServerinfo.GameScore   = 20;
                ToServerinfo.PlayerCount = 2;
                G2C_CreateRoom RoomInfo = await SessionComponent.Instance.Session.Call(new C2G_CreateRoom()
                {
                    Room = ToServerinfo
                }) as G2C_CreateRoom;

                Log.Debug($"RoomInfo={RoomInfo.Room.GameCount},{RoomInfo.Room.GameScore},{RoomInfo.Room.PlayerCount}");

                //添加房间配置
                RoomConfig config = new RoomConfig();
                config.GameCount  = RoomInfo.Room.GameCount;
                config.GamePlayer = RoomInfo.Room.PlayerCount;
                config.RoomId     = RoomInfo.RoomId;
                config.GameScore  = RoomInfo.Room.GameScore;

                GameTools.GetUser().ChairId = RoomInfo.ChairID;
                RoomComponent roomComponent = Game.Scene.GetComponent <RoomComponent>();

                if (roomComponent == null)
                {
                    Game.Scene.AddComponent <RoomComponent, RoomConfig>(config);
                }
                else
                {
                    roomComponent.SetRoomConfig(config);
                }


                Game.Scene.GetComponent <UIComponent>().CreateOrShow(UIType.UIRoom);
                this.Close();
            }
            catch (Exception e)
            {
            }
        }
Exemple #2
0
        protected override void Run(ETModel.Session session, Actor_XJGameResult_Ntt message)
        {
            List <XJResultInfo> Results = message.XJResult;

            for (int i = 0; i < Results.Count; i++)
            {
                XJResultInfo info = Results[i];
                Log.Debug($"玩家{info.ChairId.ToView()},当局得分:{info.XJScore}");
                if (GameTools.IsSelf(info.ChairId))
                {
                    GameTools.GetUser().GetComponent <GamerUIComponent>().UpdateScore(info.AllScore);
                }
                else
                {
                    GameTools.GetOtherUser(info.ChairId).GetComponent <GamerUIComponent>().UpdateScore(info.AllScore);
                }
            }

            GameTools.GetRoomComponent().playerOperateComponent.ShowReady();
        }
Exemple #3
0
        /// <summary>
        /// 更新视图
        /// </summary>
        public void UpdateView()
        {
            GameDataComponent GameData = Game.Scene.GetComponent <GameDataComponent>();

            foreach (KeyValuePair <ushort, Gamer> info in GameData.UserInfos)
            {
                //如果是自己就跳过
                if (info.Key == GameTools.GetUser().ChairId)
                {
                    continue;
                }
                ushort ViewId = info.Key.ToView();
                this.PlayerObj[ViewId].SetActive(true);
                info.Value.GetComponent <GamerUIComponent>().SetPanel(PlayerObj[ViewId]);
                info.Value.GetComponent <HandCardComponent>().SetPanel(PlayerPukes[ViewId]);
            }
            PlayerObj[0].SetActive(true);
            GameData.MySelf.GetComponent <GamerUIComponent>().SetPanel(PlayerObj[0]);
            GameData.MySelf.GetComponent <HandCardComponent>().SetPanel(PlayerPukes[0]);
        }
Exemple #4
0
        public void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            txt_GamePlayerSetting = rc.GetComponent <Text>("txt_GamePlayerSetting");
            txt_GameCountSetting  = rc.GetComponent <Text>("txt_GameCountSetting");
            txt_RoomIdSetting     = rc.GetComponent <Text>("txt_RoomIdSetting");
            btn_ReturnLobby       = rc.GetComponent <Button>("btn_Exit");
            Panel_PlayerOopertate = rc.Get <GameObject>("PlayerOperate");
            for (int i = 0; i < GameTools.GetPlayerCount(); i++)
            {
                PlayerPukes.Add(rc.Get <GameObject>($"Puke{i}"));
            }
            for (int i = 0; i < GameTools.GetPlayerCount(); i++)
            {
                PlayerObj.Add(rc.Get <GameObject>($"Player{i}"));
            }
            this.btn_ReturnLobby.onClick.AddListener(OnReturnLobby);
            InitRoomInfo();
        }
Exemple #5
0
        protected override void Run(ETModel.Session session, Actor_SendCard_Ntt message)
        {
            //显示手牌
            Log.Debug($"收到手牌:{message.Cards.BytesToString()}");

            HandCardComponent handCardComponent = GameTools.GetUser().GetComponent <HandCardComponent>();

            handCardComponent.ShowPuke(message.Cards);


            foreach (KeyValuePair <ushort, Gamer> gamer in Game.Scene.GetComponent <GameDataComponent>().UserInfos)
            {
                //如果是自己就跳过
                if (gamer.Key == GameTools.GetUser().ChairId)
                {
                    continue;
                }
                //显示其他玩家的背牌
                gamer.Value.GetComponent <HandCardComponent>().HideAllPuke();
            }

            GameTools.GetRoomComponent().playerOperateComponent.ShowRob();
        }
Exemple #6
0
        protected override void Run(ETModel.Session session, Actor_GamerEnterRoom_Ntt message)
        {
            GameDataComponent GameData = Game.Scene.GetComponent <GameDataComponent>();

            for (int i = 0; i < message.users.Count; i++)
            {
                GamerInfo user = message.users[i];
                //如果User为空  如果已经添加了此玩家的信息               如果是自己的信息
                if (user == null || GameData.IsExist(user.ChairID) || user.ChairID == GameTools.GetUser().ChairId)
                {
                    continue;
                }
                Gamer gamer = GamerFactory.CreateOther(user.ChairID, false);
                gamer.Loses    = user.Loses;
                gamer.Money    = user.Money;
                gamer.NickName = user.NickName;
                gamer.Wins     = user.Wins;
                GameData.Add(user.ChairID, gamer);
                Log.Debug($"存储新来的玩家的信息:{gamer.NickName}");
            }

            Game.EventSystem.Run(EventIdType.UpdateView);
        }
        protected override void Run(ETModel.Session session, Actor_StartShowHand_Ntt message)
        {
            Game.Scene.GetComponent <GameDataComponent>().HideAllImg_Banker();

            GameTools.GetRoomComponent().playerOperateComponent.ShowTanpai();
        }
Exemple #8
0
        /// <summary>
        /// 绑定
        /// </summary>
        /// <param name="panel"></param>
        public void SetPanel(GameObject panel)
        {
            if (Panel != null)
            {
                return;
            }
            Panel = panel;
            ReferenceCollector rc = this.Panel.GetComponent <ReferenceCollector>();

            for (int i = 1; i <= 5; i++)
            {
                RobButtons.Add(rc.GetComponent <Button>($"Rob{i}"));
            }

            for (int i = 1; i <= 3; i++)
            {
                AddRobButtons.Add(rc.GetComponent <Button>($"AddRob{i}"));
            }

            btn_Tanpai  = rc.GetComponent <Button>("btn_tanpai");
            btn_Ready   = rc.GetComponent <Button>("btn_Ready");
            RobPanel    = rc.Get <GameObject>("Rob");
            AddRobPanel = rc.Get <GameObject>("AddRob");


            btn_Ready.onClick.AddListener(OnReady);
            for (int i = 0; i < this.RobButtons.Count; i++)
            {
                int index = i + 1;
                //如果是不抢
                if (index == 5)
                {
                    index = 0;
                }
                RobButtons[i].onClick.AddListener(delegate
                {
                    Log.Error($"抢庄倍数;{index}");
                    SessionComponent.Instance.Session.Call(new Actor_RobBanker_Ntt()
                    {
                        ChairId      = GameTools.GetUser().ChairId,
                        BankerNumber = (byte)index
                    });
                    this.HideRob();
                });
            }


            for (int i = 0; i < this.AddRobButtons.Count; i++)
            {
                int index = i + 1;
                Log.Error($"下注倍数;{index}");
                AddRobButtons[i].onClick.AddListener(delegate
                {
                    SessionComponent.Instance.Session.Call(new Actor_GamerBet_Ntt()
                    {
                        ChairId   = GameTools.GetUser().ChairId,
                        BetNumber = (byte)index
                    });
                    this.HideAddRob();
                });
            }


            btn_Tanpai.onClick.AddListener(delegate
            {
                SessionComponent.Instance.Session.Call(new Actor_ShowHandCard_Ntt()
                {
                    ChairId = GameTools.GetUser().ChairId
                });
                HideTanpai();
            });
        }