Exemplo n.º 1
0
    public UWBObjectData Deserialize(string _json)
    {
        UWBObjectData uwb = new UWBObjectData();

        uwb = JsonUtility.FromJson <UWBObjectData>(_json);

        return(uwb);
    }
Exemplo n.º 2
0
    public string Serialize(UWBObjectData _obj)
    {
        string json = JsonUtility.ToJson(_obj);

        //print(json);

        return(json);
    }
Exemplo n.º 3
0
    public void UpdateUWBObject(UWBObjectData _newUWBObject)
    {
        if (!SceneHasObjectWithAddress(_newUWBObject.UWBAddress))
        {
            CreateNewUWBObject(_newUWBObject.UWBAddress);
        }

        UWBObjectSync.instance.UpdateSettingsFromServer(FindObjectByAddress(_newUWBObject.UWBAddress), _newUWBObject);
    }
Exemplo n.º 4
0
    public void UpdateSettingsFromServer(UWBObjectData _newSettings)
    {
        m_OverridePosition      = _newSettings.m_OverridePosition;
        m_OverridePositionState = _newSettings.m_OverridePositionState;
        allowRotation           = _newSettings.allowRotation;
        m_InvertPositionState   = _newSettings.m_InvertPositionState;
        m_OffsetPosition        = _newSettings.m_OffsetPosition;
        position = _newSettings.position;

        UpdateObjectPosition(position);
    }
Exemplo n.º 5
0
    public void UpdateSettingsFromClient(int _sender, UWBObject _target, UWBObjectData _newSettings)
    {
        _target.m_OverridePosition      = _newSettings.m_OverridePosition;
        _target.m_OverridePositionState = _newSettings.m_OverridePositionState;
        _target.allowRotation           = _newSettings.allowRotation;
        _target.m_InvertPositionState   = _newSettings.m_InvertPositionState;
        _target.m_OffsetPosition        = _newSettings.m_OffsetPosition;
        _target.position = _newSettings.position;

        _target.UpdateObjectPosition(_target.position);

        // TODO: Send this data to other clients
        ServerSend.UWBObjectDataExcludeUser(_sender, UWBObjectSerializer.instance.Serialize(_newSettings));
    }
Exemplo n.º 6
0
    public void SendUpdateToClients(UWBObject _senderObj)
    {
        UWBObjectData data = new UWBObjectData();

        data.UWBAddress              = _senderObj.UWBAddress;
        data.m_OverridePosition      = _senderObj.m_OverridePosition;
        data.m_OverridePositionState = _senderObj.m_OverridePositionState;
        data.allowRotation           = _senderObj.allowRotation;
        data.m_InvertPositionState   = _senderObj.m_InvertPositionState;
        data.m_OffsetPosition        = _senderObj.m_OffsetPosition;
        data.position = _senderObj.position;

        ServerSend.UWBObjectData(UWBObjectSerializer.instance.Serialize(data));
    }
Exemplo n.º 7
0
    public void UpdateSettingsFromServer(UWBObject _target, UWBObjectData _newSettings)
    {
        _target.m_OverridePosition      = _newSettings.m_OverridePosition;
        _target.m_OverridePositionState = _newSettings.m_OverridePositionState;
        _target.allowRotation           = _newSettings.allowRotation;
        _target.m_InvertPositionState   = _newSettings.m_InvertPositionState;
        _target.m_OffsetPosition        = _newSettings.m_OffsetPosition;
        _target.position = _newSettings.position;

        _target.UpdateObjectPosition(_target.position);

        // TEST:
        if (UWBObjectManager.i.activeSelectedUWBObject.UWBAddress == _target.UWBAddress)
        {
            GameObject.FindObjectOfType <ActiveUWBObjectDataOutputUI>().InitNewSelectedObject();
        }
    }
Exemplo n.º 8
0
    public static void UpdateUWBData(int _fromClient, Packet _packet)
    {
        string _data = _packet.ReadString();
        //Debug.Log($"New data {_data} from user <{_fromClient}>.");

        UWBObjectData data = UWBObjectSerializer.instance.Deserialize(_data);

        //if (!UWBObjectManager.SceneHasObjectWithAddress(_newUWBObject.UWBAddress))
        //{
        //    CreateNewUWBObject(_newUWBObject.UWBAddress);
        //}

        UWBObjectSync.instance.UpdateSettingsFromClient(_fromClient, UWBObjectManager.i.FindObjectByAddress(data.UWBAddress), data);


        //UWBObjectSync.instance.UpdateSettingsFromClient();
    }
Exemplo n.º 9
0
    public void SendUpdateToServer(UWBObject _senderObj)
    {
        // UWBServer_Client.ClientSend.UWBObjectData(UWBObjectSerializer.instance.Serialize(UWBObjectManager.i.activeSelectedUWBObject))

        UWBObjectData data = new UWBObjectData();

        data.UWBAddress              = _senderObj.UWBAddress;
        data.m_OverridePosition      = _senderObj.m_OverridePosition;
        data.m_OverridePositionState = _senderObj.m_OverridePositionState;
        data.allowRotation           = _senderObj.allowRotation;
        data.m_InvertPositionState   = _senderObj.m_InvertPositionState;
        data.m_OffsetPosition        = _senderObj.m_OffsetPosition;

        //data.position = new Vector3(Mathf.Abs(_senderObj.transform.position.x), Mathf.Abs(_senderObj.transform.position.y), Mathf.Abs(_senderObj.transform.position.z));
        data.position = _senderObj.position;

        print("Sending updated data to server");
        ClientSend.UWBObjectData(UWBObjectSerializer.instance.Serialize(data));
    }