Пример #1
0
        private static void Connect(Connection client, NetworkMessage msg)
        {
            uint id = msg.ReadUInt();

            client.SetId(id);

            protocol.ConnectUdp();
        }
Пример #2
0
        private static void MoveDirection(Connection client, NetworkMessage msg)
        {
            uint    id       = msg.ReadUInt();
            Vector3 position = msg.ReadVector3();
            float   speed    = msg.ReadFloat();

            Player player = Protocol.players[id];

            player.position  = position;
            player.moveSpeed = speed;
        }
Пример #3
0
        private static void PlayerData(Connection client, NetworkMessage msg)
        {
            Prefab  prefab   = protocol.playerPrefab;
            uint    id       = msg.ReadUInt();
            Vector3 position = msg.ReadVector3();

            Actor actor = PrefabManager.SpawnPrefab(prefab, position);

            actor.Name = $"Player[{id}]";
            Protocol.players.TryAdd(id, actor.GetScript <Player>());

            if (client.GetId() == id)
            {
                protocol.ExecuteAction(() =>
                {
                    var inputManager   = actor.AddScript <InputManager>();
                    inputManager.owner = actor.GetScript <Player>();
                });
            }
        }