Пример #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            sceneManager = new SceneManager();
            Mouse = new VirtualMouse(this);
            spriteFont = Content.Load<SpriteFont>("font");

            client = new GameClient("127.0.0.1", 9958);

            GameService.AddService(this);
            GameService.AddService(Content);
            GameService.AddService(GraphicsDevice);
            GameService.AddService(graphics);
            GameService.AddService(spriteBatch);
            GameService.AddService(sceneManager);
            GameService.AddService(Mouse);
            GameService.AddService(client);

          //   sceneManager.NextScene(new EntraceScene());
            sceneManager.NextScene(new LoginScene());
            sceneManager.NextScene(new GameScene());

            client.Connect();

            client.Send(new LoginPacket("tete", "231").Data);
        }
 private static void Process_ConnectPacket(ConnectPacket packet, GameClient socket)
 {
     if (packet.LoginSucess)
     {
         GameService.GetService<SceneManager>().ForceScene(new GameScene());
     }
     else
     {
         Console.WriteLine("Erro: username and/or password invalid");
     }
 }
        private static void Handle(byte[] packet, GameClient socket)
        {
            ushort packetLength = BitConverter.ToUInt16(packet, 0);
            ushort packetType = BitConverter.ToUInt16(packet, 2);

            Console.WriteLine("Package received! Length: {0} | Type: {1}", packetLength, (PacketType) packetType);

            switch ((PacketType) packetType)
            {
                case PacketType.Connect:
                    Process_ConnectPacket(new ConnectPacket(packet), socket);
                    break;
            }
        }
 public static void Add(byte[] packet, GameClient clientSocket)
 {
     Packets.ThreadSafeQueue(new PacketProcess(packet, clientSocket));
 }