Esempio n. 1
0
    //点击加入房间按钮
    public void OnJoinClick(string idString)
    {
        MsgEnterRoom msg = new MsgEnterRoom();

        msg.id = int.Parse(idString);
        NetManager.Send(msg);
    }
Esempio n. 2
0
    public static void MsgEnterRoom(ClientState c, MsgBase msgBase)
    {
        MsgEnterRoom msg    = (MsgEnterRoom)msgBase;
        Player       player = c.player;

        if (player == null)
        {
            return;
        }
        if (player.roomId >= 0)
        {
            msg.result = 1;
            player.Send(msg);
            return;
        }
        Room room = RoomManager.GetRoom(msg.id);

        if (room == null)
        {
            msg.result = 1;
            player.Send(msg);
            return;
        }
        if (!room.AddPlayer(player.id))
        {
            msg.result = 1;
            player.Send(msg);
            return;
        }
        msg.result = 0;
        player.Send(msg);
    }
Esempio n. 3
0
	//进入房间
	public static void MsgEnterRoom(ClientState c, MsgBase msgBase)
	{
		Player currentPlayer = c.player;
		if (currentPlayer == null)
		{
			return;
		}
		playersInRoom.Add(currentPlayer);
		playersID.Add(currentPlayer.id);
		MsgEnterRoom msg = (MsgEnterRoom)msgBase;
		msg.result = 1;
		msg.playerID = playersID;
		foreach (Player player in playersInRoom)
		{
			player.Send(msg);
		}
		if (playersInRoom.Count == 3)
		{
			string[] sendList = new string[3]{"", "", ""};
			serverCreater sc = new serverCreater();
			sc.CreateCard();
			sc.Shuffle();
			int cardCnt = 0;
			foreach (cardData data in sc.dealcards)
			{
				if (cardCnt >= 51)
				{
					sendList[0] += data.ToString();
					sendList[1] += data.ToString();
					sendList[2] += data.ToString();
				}
				else
				{
					sendList[cardCnt / 17] += data.ToString();
				}
				cardCnt++;
				// 17 + 3
			}
			
			Random r = new Random();
			int first = r.Next(0, 3);
			for (int i = 0; i < playersInRoom.Count; i++)
			{
				MsgAllReady msg1 = new MsgAllReady();
				msg1.cardData = sendList[i];
				msg1.num = (first + i) % 3;
				playersInRoom[i].Send(msg1);
			}
		}
	}
Esempio n. 4
0
    //收到进入房间协议
    public void OnMsgEnterRoom(MsgBase msgBase)
    {
        MsgEnterRoom msg = (MsgEnterRoom)msgBase;

        //成功进入房间
        if (msg.result == 0)
        {
            PanelManager.Open <RoomPanel>();
            Close();
        }
        //进入房间失败
        else
        {
            PanelManager.Open <TipPanel>("进入房间失败");
        }
    }
Esempio n. 5
0
        private static void OnEnterRoom(MsgBase msgBase)
        {
            MsgEnterRoom msg = (MsgEnterRoom)msgBase;

            if (msg.code == HttpStatusCode.OK)
            {
                RoomDetailScence roomDetailScence = ContainerBuilder.Resolve <RoomDetailScence>();
                roomDetailScence.Room = JsonConvert.DeserializeObject <Room>(msg.result);
                RoomScence roomScence = ContainerBuilder.Resolve <RoomScence>();
                roomScence.IsEnterRoomCallBack = true;
                ScenceController.curScence     = ScenceController.scenceDict["roomDetail"];
            }
            else
            {
                Console.WriteLine(msg.result);
            }
        }
Esempio n. 6
0
        //进入房间
        public static void MsgEnterRoom(ClientState c, MsgBase msgBase)
        {
            MsgEnterRoom msg  = (MsgEnterRoom)msgBase;
            User         user = c.user;

            if (user == null)
            {
                msg.code   = HttpStatusCode.Unauthorized;
                msg.result = "请先登录";
                NetManager.Send(c, msg);
                return;
            }
            //已经在房间里
            if (user.RoomId > 0)
            {
                msg.code   = HttpStatusCode.InternalServerError;
                msg.result = "已经在房间里";
                NetManager.Send(c, msg);
                return;
            }
            //获取房间
            Room room = RoomManager.GetRoom(msg.roomId);

            if (room == null)
            {
                msg.code   = HttpStatusCode.NotFound;
                msg.result = "房间不存在";
                return;
            }
            //进入
            if (!room.AddUser(user))
            {
                msg.code   = HttpStatusCode.InternalServerError;
                msg.result = "加入房间失败";
                NetManager.Send(c, msg);
                return;
            }

            //返回协议
            msg.code   = HttpStatusCode.OK;
            msg.result = JsonConvert.SerializeObject(room);
            room.Broadcast(msg);
        }