Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var playerName = ConfigurationManager.AppSettings["playerName"];
            var password = ConfigurationManager.AppSettings["password"];
            var hostname = ConfigurationManager.AppSettings["hostname"];
            var port = int.Parse(ConfigurationManager.AppSettings["port"]);

            if (string.IsNullOrWhiteSpace(playerName + password))
            {
                throw new ConfigurationErrorsException("PlayerName and password must be set in App.config to connect to server.");
            }

            using (var client = new TcpClient())
            {
                client.NoDelay = true;
                client.Connect(hostname, port);
                using (var writer = new StreamWriter(client.GetStream()))
                {
                    writer.AutoFlush = true;
                    using (var reader = new StreamReader(client.GetStream()))
                    {
                        var serverGateway = new AgarIoServerGateway(writer, reader);
                        serverGateway.Login(playerName, password);
                        serverGateway.JoinPlayer();

                        var agarIoPlayer = new AgarIoPlayer(serverGateway, playerName);

                        agarIoPlayer.GameLoop();
                    }
                }
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public AgarIoPlayer(AgarIoServerGateway serverGateway, string playerName)
 {
     _serverGateway = serverGateway;
     _playerName = playerName;
 }