public static void SendData(byte[] _data)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((_data.GetUpperBound(0) - _data.GetLowerBound(0)) + 1);
            _buffer.WriteBytes(_data);

            m_Stream.BeginWrite(_buffer.ToArray(), 0, _buffer.ToArray().Length, null, null);

            _buffer.Dispose();
        }
Ejemplo n.º 2
0
        public static void SendRequestServerData()
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.RequestServerData);

            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
        public static void SendInstantiateLocalPlayer()
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.InstantiateLocalPlayer);

            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
Ejemplo n.º 4
0
        public static void SendNetworkName(string _networkName)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.SetNetworkName);
            _buffer.WriteString(_networkName);

            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
Ejemplo n.º 5
0
        public static void SendAuthenticationToServer(string _clientVersion)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.Authentication);
            _buffer.WriteString(_clientVersion);

            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
Ejemplo n.º 6
0
        public static void SendAuthenticationConfirmed(int _connectionID)
        {
            r_ByteBuffer _ByteBuffer = new r_ByteBuffer();

            _ByteBuffer.WriteInteger((int)ServerPackets.SendAuthenticationConfirmed);
            _ByteBuffer.WriteInteger(_connectionID);

            r_ClientManager.SendDataTo(_connectionID, _ByteBuffer.ToArray());

            _ByteBuffer.Dispose();
        }
        public static void SendDestoryNetworkPlayer(int _index)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ServerPackets.DestoryPlayer);
            _buffer.WriteInteger(_index);

            r_ClientManager.SendDataToAllExcept(_index, _buffer.ToArray());

            _buffer.Dispose();
        }
        public static void SendInstantiateRemotePlayer(int _index, int _connectionID, string _networkName)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ServerPackets.InstantiateRemotePlayer);
            _buffer.WriteInteger(_index);
            _buffer.WriteString(_networkName);

            r_ClientManager.SendDataTo(_connectionID, _buffer.ToArray());

            _buffer.Dispose();
        }
        public static void SendNetworkName(int _index, string _networkName)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ServerPackets.SetNetworkName);
            _buffer.WriteInteger(_index);
            _buffer.WriteString(_networkName);

            r_ClientManager.SendDataToAll(_buffer.ToArray());

            _buffer.Dispose();
        }
Ejemplo n.º 10
0
        public static void SendAnimatorValue(string _paramaterName, bool _value)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.UpdatePlayerAnimator);

            _buffer.WriteInteger((int)AnimatorValueType.Bool);
            _buffer.WriteString(_paramaterName);
            _buffer.WriteBool(_value);

            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
        public static void SendDataToAll(byte[] _data)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((_data.GetUpperBound(0) - _data.GetLowerBound(0)) + 1);
            _buffer.WriteBytes(_data);

            if (m_Clients.Count == 0)
            {
                _buffer.Dispose();
                return;
            }

            if (m_Clients.Count > 0)
            {
                foreach (var _client in m_Clients)
                {
                    _client.Value.m_Stream.BeginWrite(_buffer.ToArray(), 0, _buffer.ToArray().Length, null, null);
                }
            }

            _buffer.Dispose();
        }
Ejemplo n.º 12
0
        public static void SendAnimatorValue(string _paramaterName, float _value)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.UpdatePlayerAnimator);

            _buffer.WriteInteger((int)AnimatorValueType.Float);
            _buffer.WriteString(_paramaterName);
            _buffer.WriteFloat(_value);

            UnityEngine.Debug.Log($"[SENDING][FLOAT] ({_value}) to server");
            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
        public static void HandlePlayerAnimatorUpdate(int _index, string _paramaterName, float _value)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ServerPackets.UpdatePlayerAnimator);
            _buffer.WriteInteger(_index);

            //send to clients
            _buffer.WriteInteger((int)AnimatorValueType.Float);
            _buffer.WriteString(_paramaterName);
            _buffer.WriteFloat(_value);

            r_ClientManager.SendDataToAll(_buffer.ToArray());

            _buffer.Dispose();
        }
        public static void SendEntityUpdate(string _guid, Vector3 _position)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.UpdateEntity);

            _buffer.WriteString(_guid);

            _buffer.WriteFloat(_position.x);
            _buffer.WriteFloat(_position.y);
            _buffer.WriteFloat(_position.z);

            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
Ejemplo n.º 15
0
        public static void SendPlayerUpdate(float _pX, float _pY, float _pZ, float _rX, float _rY, float _rZ, float _rW)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ClientPackets.UpdatePlayer);

            _buffer.WriteFloat(_pX);
            _buffer.WriteFloat(_pY);
            _buffer.WriteFloat(_pZ);

            _buffer.WriteFloat(_rX);
            _buffer.WriteFloat(_rY);
            _buffer.WriteFloat(_rZ);
            _buffer.WriteFloat(_rW);

            r_Client.SendData(_buffer.ToArray());

            _buffer.Dispose();
        }
        /// <summary>
        /// Handles the player's position and rotation update
        /// </summary>
        public static void HandlePlayerUpdate(int _index, r_Vector3 _position, r_Quaternion _rotation)
        {
            r_ByteBuffer _buffer = new r_ByteBuffer();

            _buffer.WriteInteger((int)ServerPackets.UpdatePlayer);
            _buffer.WriteInteger(_index);

            _buffer.WriteFloat(_position.x);
            _buffer.WriteFloat(_position.y);
            _buffer.WriteFloat(_position.z);

            _buffer.WriteFloat(_rotation.x);
            _buffer.WriteFloat(_rotation.y);
            _buffer.WriteFloat(_rotation.z);
            _buffer.WriteFloat(_rotation.w);

            r_ClientManager.SendDataToAll(_buffer.ToArray());

            _buffer.Dispose();
        }
Ejemplo n.º 17
0
        public static void SendWorldObjectUpdateToClient(string _guid, r_Vector3 _position, r_Quaternion _rotation, EntityType _entityType)
        {
            r_ByteBuffer _ByteBuffer = new r_ByteBuffer();

            _ByteBuffer.WriteInteger((int)ServerPackets.UpdateEntity);

            _ByteBuffer.WriteString(_guid);

            _ByteBuffer.WriteFloat(_position.x);
            _ByteBuffer.WriteFloat(_position.y);
            _ByteBuffer.WriteFloat(_position.z);

            _ByteBuffer.WriteFloat(_rotation.x);
            _ByteBuffer.WriteFloat(_rotation.y);
            _ByteBuffer.WriteFloat(_rotation.z);
            _ByteBuffer.WriteFloat(_rotation.w);

            _ByteBuffer.WriteInteger((int)_entityType);

            r_ClientManager.SendDataToAll(_ByteBuffer.ToArray());

            _ByteBuffer.Dispose();
        }
Ejemplo n.º 18
0
        public static void SendWorldObjectsToClient(int _connectionID, string _prefab, string _guid, r_Vector3 _position, r_Quaternion _rotation, EntityType _entityType)
        {
            r_ByteBuffer _ByteBuffer = new r_ByteBuffer();

            _ByteBuffer.WriteInteger((int)ServerPackets.InstantiateWorldObjects);

            _ByteBuffer.WriteString(_prefab);
            _ByteBuffer.WriteString(_guid);

            _ByteBuffer.WriteFloat(_position.x);
            _ByteBuffer.WriteFloat(_position.y);
            _ByteBuffer.WriteFloat(_position.z);

            _ByteBuffer.WriteFloat(_rotation.x);
            _ByteBuffer.WriteFloat(_rotation.y);
            _ByteBuffer.WriteFloat(_rotation.z);
            _ByteBuffer.WriteFloat(_rotation.w);

            _ByteBuffer.WriteInteger((int)_entityType);

            r_ClientManager.SendDataTo(_connectionID, _ByteBuffer.ToArray());

            _ByteBuffer.Dispose();
        }