public void Start()
        {
            Connection = new YGOClient();
            _behavior  = new GameBehavior(this);

            Connection.Connected      += OnConnected;
            Connection.PacketReceived += OnPacketReceived;

            Connection.Connect(IPAddress.Parse(_serverHost), _serverPort);
        }
Exemple #2
0
        public void Start()
        {
            Connection = new YGOClient();
            _behavior = new GameBehavior(this);

            Connection.Connected += OnConnected;
            Connection.PacketReceived += OnPacketReceived;

            Connection.Connect(IPAddress.Parse(_serverHost), _serverPort);
        }
Exemple #3
0
        public void Start()
        {
            Connection = new YGOClient();
            _behavior  = new GameBehavior(this);

            Connection.Connected      += OnConnected;
            Connection.PacketReceived += OnPacketReceived;
            IPAddress target_address;

            try {
                target_address = IPAddress.Parse(_serverHost);
            } catch (System.Exception e) {
                IPHostEntry _hostEntry = Dns.GetHostEntry(_serverHost);
                target_address = _hostEntry.AddressList[0];
            }
            Connection.Connect(target_address, _serverPort);
        }
Exemple #4
0
        public void Start()
        {
            Connection = new GameConnection(IPAddress.Parse(_serverHost), _serverPort);
            _behavior  = new GameBehavior(this);

            GameClientPacket packet = new GameClientPacket(CtosMessage.PlayerInfo);

            packet.Write(Username, 20);
            Connection.Send(packet);

            byte[] junk = { 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00 };
            packet = new GameClientPacket(CtosMessage.JoinGame);
            packet.Write(Program.ProVersion);
            packet.Write(junk);
            packet.Write(_roomInfos, 30);
            Connection.Send(packet);
        }
Exemple #5
0
        public void Start()
        {
            Connection = new AIGameConnection(IPAddress.Parse(_serverHost), _serverPort);
            _behavior  = new GameBehavior(this);

            GameClientPacket packet = new GameClientPacket(CtosMessage.PlayerInfo);

            packet.Write(Username, 20);
            Connection.Send(packet);

            byte[] junk = { 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00 };
            packet = new GameClientPacket(CtosMessage.JoinGame);
            packet.Write((short)Program.ProVersion);
            packet.Write(junk);

            packet.Write(_roomInfos, 30);


            Deck deck = Deck.Load(Deck_);

            if (deck == null)
            {
                Logger.WriteLine("read deck fail.");
                Connection.Close();
                return;
            }

            packet.Write((byte)CtosMessage.UpdateDeck);

            packet.Write(deck.Cards.Count);
            packet.Write(deck.SideCards.Count);

            foreach (var k in deck.Cards)
            {
                packet.Write(k.Id);
            }

            foreach (var k in deck.SideCards)
            {
                packet.Write(k.Id);
            }

            packet.Write((byte)CtosMessage.HsReady);
            Connection.Send(packet);
            Logger.WriteLine("send deck");
        }
Exemple #6
0
        public void Start()
        {
            Connection = new CoreClient(_serverHost, _serverPort);
            Connection.MessageReceived += OnMessageReceived;

            _behavior = new GameBehavior(this);

            GamePacketWriter packet = new GamePacketWriter(CtosMessage.PlayerInfo);
            packet.Write(Username, 20);
            Connection.Send(packet);

            byte[] junk = { 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00 };
            packet = new GamePacketWriter(CtosMessage.JoinGame);
            packet.Write(Program.ProVersion);
            packet.Write(junk);
            packet.Write(_roomInfos, 30);
            Connection.Send(packet);
        }
Exemple #7
0
		public void Start()
		{
			Connection = new AIGameConnection(IPAddress.Parse(_serverHost), _serverPort);
			_behavior = new GameBehavior(this);

			GameClientPacket packet = new GameClientPacket(CtosMessage.PlayerInfo);
			packet.Write(Username, 20);
			Connection.Send(packet);

			byte[] junk = { 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00 };
			packet = new GameClientPacket(CtosMessage.JoinGame);
			packet.Write((short)Program.ProVersion);
			packet.Write(junk);

			packet.Write(_roomInfos, 30);

			
			Deck deck = Deck.Load(Deck_);
			if(deck == null) {
				Logger.WriteLine("read deck fail.");
				Connection.Close();
				return;
			}

			packet.Write((byte)CtosMessage.UpdateDeck);

			packet.Write(deck.Cards.Count);
			packet.Write(deck.SideCards.Count);

			foreach (var k in deck.Cards) {
				packet.Write(k.Id);
			}

			foreach (var k in deck.SideCards) {
				packet.Write(k.Id);
			}

			packet.Write((byte)CtosMessage.HsReady);
			Connection.Send(packet);
			Logger.WriteLine("send deck");
		}
Exemple #8
0
        public void Start()
        {
            Connection = new YGOClient();
            _behavior  = new GameBehavior(this);

            Connection.Connected      += OnConnected;
            Connection.PacketReceived += OnPacketReceived;

            IPAddress target_address;

            try
            {
                target_address = IPAddress.Parse(_serverHost);
            }
            catch (System.Exception)
            {
                IPHostEntry _hostEntry = Dns.GetHostEntry(_serverHost);
                target_address = _hostEntry.AddressList.FirstOrDefault(findIPv4 => findIPv4.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
            }

            Connection.Connect(target_address, _serverPort);
        }