Beispiel #1
0
    public void ProcessMessage(BinaryMessage t_recvdMsg)
    {
        GameMessageReader t_reader = new GameMessageReader();
        t_reader.InitAdapter(ref t_recvdMsg);

        switch(t_reader.GetFunctionCode())
        {
            case (ushort)Function_Codes.FUNCTION_USER_NEWROOM:
                {
                    string t_name = "";
                    ushort t_roomType = 0;
                    t_reader.Decode_FunctionUserNewRoom(ref t_roomType,
                                                         ref t_name);

                    if(t_roomType == (ushort)Function_Codes.ROOM_TYPE_CHAT)
                    {
                        Debug.Log("NEW ROOM CHAT!");
                        Room t_room = new Room();
                        t_room.SetRoomInfo(ref t_name, ref t_roomType);
                        m_controller.m_liveController.SendRoomStateData(t_room);
                        if(!m_controller.m_liveController.CheckDataSaved())
                        {

                            m_controller.m_liveController.SendClientUserData(m_clientUser);
                        }
                        Application.LoadLevel(0);
                    }
                    break;
                }
        }
    }
    public void ProcessMessage(BinaryMessage t_recvdMsg)
    {
        GameMessageReader t_reader = new GameMessageReader();
        t_reader.InitAdapter(ref t_recvdMsg);
        Debug.Log(t_reader.GetFunctionCode().ToString() + " tank movement recd\n");
        switch( t_reader.GetFunctionCode ())
        {

            case (ushort)Function_Codes.FUNCTION_TANKROOM_USER_MOVE_TANK:
                {
                    float x = 0;
                    float y = 0;
                    float z = 0;
                    float h = 0;
                    float p = 0;
                    float r = 0;
                    t_reader.Decode_FunctionTankUpdatePOSHPR(ref x ,
                                                           ref y ,
                                                           ref z ,
                                                           ref h ,
                                                           ref p ,
                                                           ref r );
                    transform.position = new Vector3(x, y, z);
                    print(h.ToString() + p.ToString() + r.ToString());
                    Quaternion newOrientation = Quaternion.Euler(new Vector3(h,p,r));
                    transform.rotation = newOrientation;
                    break;
                }
            //case (ushort)Function_Codes.FUNCTION_TANKROOM_USER_ROTATE_TANK:
            //    {
            //        short direction = 0;
            //        t_reader.Decode_FunctionTankUpdateRotation(ref direction);

            //        if(direction == 1 )
            //        {
            //            transform.RotateAroundLocal(Vector3.up, -.02F);
            //        }
            //        if(direction == -1)
            //        {
            //            transform.RotateAroundLocal(Vector3.up, .02F);
            //        }

            //        break;
            //    }
        }
    }
Beispiel #3
0
    //End message specific process functions-----------------------------------
    public void ProcessMessage(BinaryMessage t_recvdMsg)
    {
        GameMessageReader msgReader = new GameMessageReader();
        msgReader.InitAdapter(ref t_recvdMsg);
        print("FunctionCode " + msgReader.GetFunctionCode());
        switch (msgReader.GetFunctionCode())
        {

            case (ushort)Function_Codes.FUNCTION_USER_LOGIN_RESP:
                {
                    int return_code = 0;
                    msgReader.Decode_FunctionUserLoginResp(ref return_code,
                                                               ref ClientUser.m_id,
                                                               ref ClientUser.m_username);
                    m_currentRoom.AddUserToWindow(ref ClientUser.m_username);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_NEWROOM:
                {
                    ProcessFunctionUserNewRoom(ref msgReader);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_IN_ROOM:
                {
                    ProcessClientUserInRoom(ref msgReader);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_OUT_ROOM:
                {
                    ProcessUserOutRoom(ref msgReader);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_CHAT:
                {
                    ProcessClientChatMsg(ref msgReader);
                    break;
                }
        }
    }
Beispiel #4
0
    //Function: PumpRPCQueue()
    //Argument: none
    //Purpose: Function checks the socket for a buffered message. If yes then
    //         check the code of the message through the current function
    //         codes and then send the message off to the Intrested Objects
    //         of that function code.
    private void PumpRPCQueue()
    {
        BinaryMessage t_msg = new BinaryMessage();
           t_msg.Init();
           int pumped = m_reader.PumpMessageReader(ref m_sock, ref t_msg);
           if (pumped == 1)
           {
           GameMessageReader t_readerAdapter = new GameMessageReader();
           t_readerAdapter.InitAdapter(ref t_msg);

           List<IntrestedObj> t_list;
           if (m_funcCodeIntrestList.TryGetValue(t_readerAdapter.GetFunctionCode(),
                                                out t_list))
           {
               t_readerAdapter.ResetToFuncCode();
               foreach (IntrestedObj t_obj in t_list)
               {
                   t_obj.ProcessMessage(t_msg);
               }
           }

           }
    }