示例#1
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());
        }
        public void SetItemInfo(FriendRoomInfo info)
        {
            this.info = info;
            //Log.Info("info.IsPublic" + info.IsPublic);

            if (info.IsPublic == 1)
            {
                RoomIdTxt.text = "房号:" + info.RoomId;
            }
            else if (info.IsPublic == 2)
            {
                RoomIdTxt.text = "私密房间";
            }
            juTxt.text  = info.Ju + "局";
            huaTxt.text = info.Hua + "/花";
            if (info.Icons.Count >= 4)
            {
                EnterBtn.gameObject.SetActive(false);
            }
            else
            {
                EnterBtn.gameObject.SetActive(true);
            }
            CreateItems(info.Icons);
        }
示例#3
0
        public static Room CreateFriendRoom(G2M_CreateFriendRoom message)
        {
            try
            {
                FriendRoomInfo friendRoomInfo = message.FriendRoomInfo;
                Room           room           = ComponentFactory.Create <Room>();
                room.AddComponent <DeskComponent>();
                room.AddComponent <OrderControllerComponent>();
                room.IsFriendRoom = true;

                GameControllerComponent controllerComponent = room.AddComponent <GameControllerComponent>();
                RoomConfig roomConfig = new RoomConfig();
                roomConfig.FriendRoomId        = RandomHelper.RandomNumber(100000, 1000000);
                roomConfig.JuCount             = friendRoomInfo.Ju;
                roomConfig.Multiples           = friendRoomInfo.Hua;
                roomConfig.MinThreshold        = 500;
                roomConfig.IsPublic            = friendRoomInfo.IsPublic == 1;
                roomConfig.MasterUserId        = message.UserId;
                roomConfig.Id                  = 3;
                roomConfig.Name                = "好友房";
                roomConfig.KeyCount            = friendRoomInfo.KeyCount;
                controllerComponent.RoomConfig = roomConfig;
                controllerComponent.RoomName   = RoomName.Friend;

                return(room);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            return(null);
        }
示例#4
0
        protected override async void Run(Session session, G2M_FriendRoomInfo message, Action <M2G_FriendRoomInfo> reply)
        {
            M2G_FriendRoomInfo response = new M2G_FriendRoomInfo();

            //Log.Info("G2M_FriendRoomInfo");
            try
            {
                //获取房间信息
                {
                    //获取所有空闲房间接口
                    RoomComponent roomComponent = Game.Scene.GetComponent <RoomComponent>();
                    foreach (var room in roomComponent.rooms.Values)
                    {
                        if (!room.IsFriendRoom)
                        {
                            continue;
                        }

                        GameControllerComponent gameControllerComponent = room.GetComponent <GameControllerComponent>();
                        FriendRoomInfo          friendRoomInfo          = new FriendRoomInfo();
                        friendRoomInfo.Hua      = gameControllerComponent.RoomConfig.Multiples;
                        friendRoomInfo.Ju       = gameControllerComponent.RoomConfig.JuCount;
                        friendRoomInfo.RoomId   = gameControllerComponent.RoomConfig.FriendRoomId;
                        friendRoomInfo.IsPublic = gameControllerComponent.RoomConfig.IsPublic ? 1 : 2;
                        //设置头像
                        foreach (var gamer in room.GetAll())
                        {
                            if (gamer == null)
                            {
                                continue;
                            }
                            friendRoomInfo.Icons.Add(gamer.playerBaseInfo.Icon);
                        }
                        response.Info.Add(friendRoomInfo);
                    }
                }
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }

            await Task.CompletedTask;
        }