示例#1
0
 void Awake()
 {
     screenWidth  = Screen.width;
     screenHeight = Screen.height;
     spm          = (ServerPlayerManager)gameObject.GetComponent(typeof(ServerPlayerManager));
     maxClients   = int.Parse(SceneProperties.playerSize);
 }
示例#2
0
        public void SendFrom(string clientId, Vector3 _position, Quaternion _rotation)
        {
            GameObject prefab = Instantiate(References.defaults.SERVER_PLAYER_PREFAB, _position, _rotation);

            ServerPlayerManager.AddPlayerPrefab(prefab, clientId);

            // spawn new client onn all existing clients
            SendPackageFrom(clientId, new SpawnFlowServerPackage()
            {
                position = _position,
                rotation = _rotation
            }).SendAll(SendMethod.ReliableOrdered);

            // spawn already existing clients on the newly connected client
            FlowServer.IterateConnectedClients((FlowClientServer client) => {
                if (client.id != clientId)
                {
                    SendPackageFrom(client.id, new SpawnFlowServerPackage()
                    {
                        position = _position,
                        rotation = _rotation
                    }).Send(SendMethod.ReliableOrdered, clientId);
                }
                return(true);
            });
        }
示例#3
0
 void Awake()
 {
     screenWidth = Screen.width;
     screenHeight = Screen.height;
     spm = (ServerPlayerManager) gameObject.GetComponent(typeof(ServerPlayerManager));
     maxClients = int.Parse(SceneProperties.playerSize);
 }
        public void SendFrom(string clientId)
        {
            ServerPlayerManager.RemovePlayerPrefab(clientId);

            SendPackageFrom(clientId, new DisconnectFlowServerPackage()
            {
                message = $"Client ({clientId}) has disconnected.",
            }).SendExcept(SendMethod.ReliableUnordered, new string[] { clientId });
        }
示例#5
0
        public NetworkEntityProcessor()
        {
            _networkMessageWriter = new NetworkMessageWriter(new LiteNetLib.Utils.NetDataWriter());
            _serverPlayerManager  = new ServerPlayerManager(4, this);
            _clientPlayerManager  = new ClientPlayerManager(this);

            Order = -20000;         // Ensure this occurs before other processors
            // Not using Enabled property, because that completely disables the processor, where it doesn't even pick up newly added entities
            IsEnabled = true;
        }
示例#6
0
 void Awake()
 {
     spm = (ServerPlayerManager)gameObject.GetComponent(typeof(ServerPlayerManager));
 }
示例#7
0
 void Awake()
 {
     spm = (ServerPlayerManager) gameObject.GetComponent(typeof(ServerPlayerManager));
 }