Esempio n. 1
0
    public void RoomOwnerReadyStartGameRequest(int fd)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.ROOMOWNERREADYSTARTGAME;
        RoomOwnerReadyStartGame roomOwnerReadyStartGame = new RoomOwnerReadyStartGame();

        roomOwnerReadyStartGame.fd = fd;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 2
0
    public void GetRoomListRequest(int fd)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.GETROOMLIST;
        GetRoomList getRoomList = new GetRoomList();

        getRoomList.fd = fd;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 3
0
    public void RoomOwnerExitRequest(int fd)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.ROOMOWNEREXIT;
        RoomOwnerExit roomOwnerExit = new RoomOwnerExit();

        roomOwnerExit.fd = fd;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 4
0
    public void JoinRoomRequest(int fd, int roomOwnerFd)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.JOINROOM;
        JoinRoom joinRoom = new JoinRoom();

        joinRoom.fd = fd;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 5
0
    public void PlayerExitGameRequest(int fd)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.PLAYEREXITGAME;
        PlayerExitGame playerExitGame = new PlayerExitGame();

        playerExitGame.fd = fd;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 6
0
    //不处理退出

    public void PlayerGameClick()
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.ROOMOWNERREADYSTARTGAME;
        RoomOwnerReadyStartGame data = new RoomOwnerReadyStartGame();

        data.fd = ownerFd;
        req.roomOwnerReadyStartGame = data;
        ConnectSocket.getSocketInstance().sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 7
0
    public void ReloadGameScene()
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.PLAYERRELOADSCENE;
        PlayerReLoadScene reload = new PlayerReLoadScene();

        reload.fd             = GameGlobalData.fd;
        req.playerReloadScene = reload;
        ConnectSocket.getSocketInstance().sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 8
0
    public void ExitRoomRequest(int fd, int roomOwnerFd)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.EXITROOM;
        ExitRoom exitRoom = new ExitRoom();

        exitRoom.fd          = fd;
        exitRoom.roomOwnerFd = roomOwnerFd;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 9
0
    public void ConnectToServerRequest(string name)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.CONNECTTOSERVER;
        ConnectToServer connectToServer = new ConnectToServer();

        connectToServer.name = name;
        req.connectToServer  = connectToServer;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 10
0
    public void GameResultRequest(int fd, bool result)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.GAMERESULT;
        GameResult gameResult = new GameResult();

        gameResult.fd     = fd;
        gameResult.result = result;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 11
0
    public void flushRoomListRequest()
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.GETROOMLIST;
        GetRoomList getRoomList = new GetRoomList();

        getRoomList.fd  = GameGlobalData.fd;
        req.getRoomList = getRoomList;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 12
0
    IEnumerator StartGameRequest()
    {
        yield return(new WaitForSeconds(3));

        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.ROOMOWNERSTARTGAME;
        RoomOwnerStartGame data = new RoomOwnerStartGame();

        data.fd = ownerFd;
        req.roomOwnerStartGame = data;
        ConnectSocket.getSocketInstance().sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 13
0
    public void CreateRoomRequest(int fd, string roomOwner, int maxMan, string roomName)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.CREATEROOM;
        CreateRoom createRoom = new CreateRoom();

        createRoom.fd        = fd;
        createRoom.roomOwner = roomOwner;
        createRoom.maxMan    = maxMan;
        createRoom.roomName  = roomName;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 14
0
    public void ButtonClick()
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.JOINROOM;
        JoinRoom joinRoom = new JoinRoom();

        joinRoom.fd                  = GameGlobalData.fd;
        joinRoom.roomOwnerFd         = ownerFd;
        GameGlobalData.roomOwnerFd   = ownerFd;
        GameGlobalData.roomOwnerName = OwnerNameText.text;
        GameGlobalData.roomName      = RoomNameText.text;
        GameGlobalData.currentMan    = this.manCount;
        GameGlobalData.maxManCount   = this.maxManCount;
        req.joinRoom                 = joinRoom;
        ConnectSocket.getSocketInstance().sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 15
0
    public void ReadyCreateRoomClick()
    {
        createRoomPanel.gameObject.SetActive(false);
        roomName    = createRoomPanel.Find("roomName").GetComponent <InputField>().text;
        maxManCount = int.Parse(createRoomPanel.Find("maxManCount").GetComponent <InputField>().text);
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.CREATEROOM;
        CreateRoom createRoom = new CreateRoom();

        createRoom.fd        = GameGlobalData.fd;
        createRoom.roomOwner = roomOwner;
        createRoom.maxMan    = maxManCount;
        createRoom.roomName  = roomName;
        req.createRoom       = createRoom;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Esempio n. 16
0
 void dealPbcMessage(ProtocolNetResponse resp)
 {
     if (resp.cmd == (int)NetRequestType.HEARTBEAT)
     {
         ProtocolNetRequest req = new ProtocolNetRequest();
         req.cmd = (int)NetRequestType.HEARTBEAT;
         socket.sendMSG(PBCSerialize.Serialize(req));
     }
     else if (resp.cmd == (int)NetRequestType.FORECEEXITGAME)
     {
         Debug.Log("服务器已断开连接,强制退出游戏");
         Application.Quit();
     }
     else
     {
         callback(resp);
     }
 }