public void OnConsoleCommand_mplayer(NotificationCenter.Notification n)
        {
            if (client.IsConnected())
            {
                ClientLogger.IngameMessage("Already connected to a server");
            }
            else if (n?.data?.Count > 0)
            {
                PacketSender.PlayerId = (string)n.data[0];

                String ip = DEFAULT_IP_ADDRESS;

                if (n.data.Count >= 2)
                {
                    ip = (string)n.data[1];
                }

                StartMultiplayer(ip);
                InitMonoBehaviours();
            }
            else
            {
                ClientLogger.IngameMessage("Command syntax: mplayer USERNAME [SERVERIP]");
            }
        }
示例#2
0
 public void Stop()
 {
     connection.Close(); // Server will clean up pretty quickly
     Multiplayer.PacketSender.Active = false;
     Multiplayer.RemoveAllOtherPlayers();
     ClientLogger.IngameMessage("Disconnected from server.");
 }
        public override void Process(Disconnect disconnect)
        {
            //TODO: don't remove right away... maybe grey out and start
            //      a coroutine to finally remove.
            vitalsManager.RemovePlayer(disconnect.PlayerId);

            remotePlayerManager.RemovePlayer(disconnect.PlayerId);

            ClientLogger.IngameMessage(disconnect.PlayerId + " disconnected");
        }
 public void StartMultiplayer(String ipAddress)
 {
     client.Start(ipAddress);
     if (client.IsConnected())
     {
         PacketSender.Active = true;
         PacketSender.Authenticate();
         ClientLogger.IngameMessage("Connected to server");
     }
     else
     {
         ClientLogger.IngameMessage("Unable to connect to server");
     }
 }
示例#5
0
 public override void Process(Disconnect disconnect)
 {
     remotePlayerManager.RemovePlayer(disconnect.PlayerId);
     ClientLogger.IngameMessage(disconnect.PlayerId + " disconnected");
 }
示例#6
0
 public override void Process(ChatMessage message)
 {
     ClientLogger.IngameMessage(message.PlayerId + ": " + message.Text);
 }