Beispiel #1
0
        /// <summary>
        /// -1房间不够
        /// -2必须先创建房间
        /// </summary>
        /// <param name="webPlayer"></param>
        /// <returns></returns>
        public int EnterRoom(WebPlayer webPlayer)
        {
            var ret = -1;
            var rpv = webPlayer.GetIBehaviour <RoomPlayerBv>();

            if (rpv == null)
            {
                return(ret);
            }

            TableRoom tr = null;

            if (rpv.RoomId != string.Empty)
            {
                tr = this.GetTableRoom(rpv.RoomId);
                if (tr.IsAvailable)//没人必须创建房间
                {
                    ret = -2;
                    return(ret);
                }
                ret = tr.EnterRoom(webPlayer);
                return(ret);
            }

            if (rpv.RoomPlayer_Data.RoomId == string.Empty)//创建房间
            {
                ///////////////////////////这部分用于测试,自动匹配有人的房间
                tr = this.GetCanJoinTableRoom();
                if (tr != null)
                {
                    ret = tr.EnterRoom(webPlayer);
                    return(ret);
                }
                /////////////////////////////////////////////////
                //创建新房间
                tr = this.GetAvailableTableRoom();
                if (null == tr)
                {
                    return(ret);
                }



                tr.OpenRoom();//
                ret        = tr.EnterRoom(webPlayer);
                rpv.RoomId = tr.RoomId;
            }
            else//加入别的房间
            {
                tr = this.GetTableRoom(rpv.RoomPlayer_Data.RoomId);
                if (tr.IsAvailable)//没人必须创建房间
                {
                    ret = -2;
                    return(ret);
                }
                ret        = tr.EnterRoom(webPlayer);
                rpv.RoomId = tr.RoomId;
            }
            return(ret);
        }
Beispiel #2
0
 protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message)
 {
     if (tr.RoomState == ERoomState.ERoom_InGame)
     {
         var command_Msg = message.ToObject <Command_Msg>();
         tr.ServerPlayer.SendCommand(command_Msg.Command);
     }
 }
Beispiel #3
0
 protected void CreateRoom()
 {
     this.m_Dict_Room.Clear();
     for (int i = 0; i < GameConstant.RoomTotalNub; ++i)
     {
         var tr = new TableRoom();
         tr.Init(i.ToString());//房间号
         this.m_Dict_Room.Add(i.ToString(), tr);
     }
 }
Beispiel #4
0
        protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message)
        {
            var roomLoading_Req = message.ToObject <RoomLoading_Req>();

            rpb.RoomPlayer_Data.IPercent = roomLoading_Req.IPercent;
            var roomLoading_Res = new RoomLoading_Res();

            roomLoading_Res.Id       = rpb.RoomPlayer_Data.Id;
            roomLoading_Res.IPercent = rpb.RoomPlayer_Data.IPercent;
            tr.SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.RoomLoading_Res, roomLoading_Res));
        }
Beispiel #5
0
        protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message)
        {
            var roomReady_Req = message.ToObject <RoomReady_Req>();

            rpb.RoomPlayer_Data.IsReady = roomReady_Req.IsReady;
            var roomReady_Res = new RoomReady_Res();

            roomReady_Res.Id      = rpb.RoomPlayer_Data.Id;
            roomReady_Res.IsReady = rpb.RoomPlayer_Data.IsReady;
            rpb.StartGame_Data    = roomReady_Req.StartGame_Data;
            tr.SendToAllPlayer(Msg_Json.Create_Msg_Json(NetOpCode.RoomReady_Res, roomReady_Res));
        }
Beispiel #6
0
 protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message)
 {
     if (tr.RoomState == ERoomState.ERoom_InGame ||
         tr.RoomState == ERoomState.ERoom_GameOver)
     {
         GetNextFrame_Req getNextFrame_Req = message.ToObject <GetNextFrame_Req>();
         GetNextFrame_Res getNextFrame_Res = new GetNextFrame_Res();
         var tmp_fms = tr.ServerPlayer.PlayerRecoder.GetCurToEndFrame(getNextFrame_Req.CurFrameId);
         foreach (var fm in tmp_fms)
         {
             getNextFrame_Res.ListFrame.Add(fm);
         }
         webpy.SendAsync(Msg_Json.Create_Msg_Json(NetOpCode.GetNextFrame_Res, getNextFrame_Res));
     }
 }
 protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message)
 {
     rpb.StartGame_Data = message;
 }
Beispiel #8
0
 protected abstract void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message);
Beispiel #9
0
 protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message)
 {
 }
Beispiel #10
0
 protected override void Run(WebPlayer webpy, RoomPlayerBv rpb, TableRoom tr, JObject message)
 {
     rpb.RoomPlayerState = ERoomPlayerState.E_GameOver;
     tr.ChangeToGameOver();
 }