Ejemplo n.º 1
0
        protected override BMSByte SerializeDirtyFields()
        {
            if (firstFrame)
            {
                BMSByte bmsByte = new BMSByte();
                bmsByte = WritePayload(bmsByte);

                PTK.ArenaObservable.PlayerData _playerData = new PTK.ArenaObservable.PlayerData();
                _playerData.BMSData   = Convert.ToBase64String(bmsByte.CompressBytes());
                _playerData.UID       = PTK.Ansuz.Instance.UID;
                _playerData.RequestID = (int)PTK.AnsuzRequestID.CreatePlayer;
                PTK.ArenaObservable.PlayerData[] objs = { _playerData };
                string json = _playerData.ToJson <PTK.ArenaObservable.PlayerData>(objs, false);
                PTK.Ansuz.Instance.PublishToTopic("arena/playerData/all", json, 0);
                firstFrame = false;
            }

            dirtyFieldsData.Clear();
            dirtyFieldsData.Append(_dirtyFields);

            if ((0x1 & _dirtyFields[0]) != 0)
            {
                UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _position);
            }
            if ((0x2 & _dirtyFields[0]) != 0)
            {
                UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _rotation);
            }
            if ((0x4 & _dirtyFields[0]) != 0)
            {
                UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _spineRotation);
            }
            if ((0x8 & _dirtyFields[0]) != 0)
            {
                UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _vertical);
            }
            if ((0x10 & _dirtyFields[0]) != 0)
            {
                UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _horizontal);
            }
            if ((0x20 & _dirtyFields[0]) != 0)
            {
                UnityObjectMapper.Instance.MapBytes(dirtyFieldsData, _isMoving);
            }

            // Reset all the dirty fields
            for (int i = 0; i < _dirtyFields.Length; i++)
            {
                _dirtyFields[i] = 0;
            }


            return(dirtyFieldsData);
        }