Пример #1
0
    void ReceiveData(byte[] data)
    {
        ByteArray       byteArray   = new ByteArray(data, (short)data.Length);
        ReceiveDataType type        = (ReceiveDataType)byteArray.readChar();
        ReceiveData     receiveData = new ReceiveData();

        switch (type)
        {
        case ReceiveDataType.Response:
            checkConfirm(byteArray.readInt(), byteArray.readChar());
            break;

        case ReceiveDataType.Transform:
            receiveData.cmd       = type;
            receiveData.transform = ReceiveTransformData.readFromBytes(byteArray.readBytes());
            callback(receiveData);
            break;

        case ReceiveDataType.Action:
            receiveData.cmd = type;
            SendResponse(byteArray.readInt());
            receiveData.action = ReceiveActionData.readFromBytes(byteArray.readBytes());
            callback(receiveData);
            break;

        case ReceiveDataType.State:
            receiveData.cmd = type;
            SendResponse(byteArray.readInt());
            receiveData.state = ReceiveStateData.readFromBytes(byteArray.readBytes());
            callback(receiveData);
            break;
        }
    }
Пример #2
0
    public static ReceiveTransformData readFromBytes(byte[] bytes)
    {
        ByteArray            array = new ByteArray(bytes, (short)bytes.Length);
        ReceiveTransformData data  = new ReceiveTransformData();

        data.fd        = array.readInt();
        data.posx      = array.readFloat();
        data.posy      = array.readFloat();
        data.direction = array.readChar();
        data.state     = array.readChar();
        return(data);
    }
Пример #3
0
    public void DispatchRobotTransform(ReceiveTransformData data)
    {
        RobotInputController robot = GameGlobalData.robotList[data.fd];

        robot.ReceiveTransform(data);
    }
Пример #4
0
 public void ReceiveTransform(ReceiveTransformData transformdata)
 {
     movement.target(new Vector2(transformdata.posx, transformdata.posy), (PlayerDirection)transformdata.direction, (PlayerState)transformdata.state);
 }