Beispiel #1
0
        static void SERVER_OnClientConnected(ConnectedClient client)         // this will NOT run in the main thread
        {
            ThreadSafeDebug.Log("Client connected from " + client.TcpConnection.RemoteEndPoint.ToString());

            string levelPath = LevelManager.Instance.GetCurrentLevelDescription().LevelJSONPath;

            byte[] bytes = File.ReadAllBytes(levelPath);
            MapSendingMessge.SendTo(bytes, client.ClientNetworkID);             // send map to other client

            ushort playerID = GetNextPlayerID();

            SetLocalPlayerMessage.SendTo(playerID, client.ClientNetworkID);

            var createdPlayerInfo = new PlayerConnectedMessage.CreatedPlayerInfo()
            {
                CharacterModelOverrideType = EnemyType.None,
                PlayerColor    = HumanFactsManager.Instance.FavouriteColors[HumanFactsManager.Instance.GetRandomColorIndex()].ColorValue,
                PlayerID       = playerID,
                PlayerUpgrades = new Dictionary <UpgradeType, int>()
            };

            PlayerConnectMessage.Send(createdPlayerInfo);

            var spawnPlayerMessage = new SpawnPlayerMessage.SpawnedPlayerInfo()
            {
                PlayerID = playerID,
                Position = new Vector3(0f, 10f, 0f),
                Rotation = 0f
            };

            SpawnPlayerMessage.Send(spawnPlayerMessage);
        }
Beispiel #2
0
        public static void StartClient(string ip, int port = 8606)
        {
            GenericSetup();

            SingleplayerServerStarter.Instance.StartServerThenCall(delegate             // clone drone requires us to start a bolt server to spawn players and such
            {
                NetworkingCore.StartClient(ip, port);
                ThreadSafeDebug.Log("Connected!");

                RegisterNetworkMessageHandelers();

                MapSendingMessge.OnMapSpawnedClient += delegate
                {
                };
            });
        }
Beispiel #3
0
 protected override void OnPackageReceivedClient(byte[] package)
 {
     ThreadSafeDebug.Log("1");
     ServerRunner.LocalPlayerID = BitConverter.ToUInt16(package, 0);
 }
Beispiel #4
0
 protected override void OnPackageReceivedClient(byte[] package)
 {
     ThreadSafeDebug.Log("Got debug message!", UnityEngine.Color.blue);
 }