// int count = 0; public ZeroGPacket SendNewPlayerInfo() { try { GameLevelInfo levelnfo = new GameLevelInfo(); levelnfo.Generate("Urban_02", 4, 2, false); // GamePacket packet = new GamePacket(); //packet.packetType = "LevelInfo"; // LoadingComplete packetSecond = new LoadingComplete(); // packetSecond.Generate(true, "yo"); // if(count == 2) // { // packet.Generate("LevelInfo", levelnfo, packetSecond); // } // else // { // packet.Generate("LevelInfo", levelnfo,packetSecond); // } // count = count + 1; ZeroGPacket packet = PacketGenerator.Generate("LevelInfo", levelnfo); return(packet); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message + ex.StackTrace); return(null); } }
public void SendPlayerUpdate(Vector3 position, Quaternion rotation) { PlayerPosition packet = new PlayerPosition(); packet.Generate(userName, ConvertCustomTypes.ConvertVectorSerializable(position), ConvertCustomTypes.ConvertQuaternionSerializable(rotation)); ZeroGPacket mainPacket = PacketGenerator.Generate("PlayerPosition", packet); gClient.Send(mainPacket, LiteNetLib.DeliveryMethod.Unreliable); }
private void EventSender_AllPlayersLoaded(object sender, EventArgs e) { // throw new NotImplementedException(); AllPlayersLoaded packet = new AllPlayersLoaded(); packet.Generate(true); ZeroGPacket fullPacket = PacketGenerator.Generate("AllLoaded", packet); serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered); }
public void SendLoadingComplete() { WriteLog.Verbose("Sending loading complete message to server"); LoadingComplete completePacket = new LoadingComplete(); completePacket.Generate(true, userName); // GamePacket mainPacket = new GamePacket(); // mainPacket.Generate("LoadingComplete", null, completePacket); ZeroGPacket packet = PacketGenerator.Generate("LoadingComplete", completePacket); gClient.Send(packet, LiteNetLib.DeliveryMethod.ReliableOrdered); }
private void CountDownTimer_Elapsed(object sender, ElapsedEventArgs e) { // throw new NotImplementedException(); Console.WriteLine("60 sec elapsed, starting game"); GameLevelInfo packet = new GameLevelInfo(); packet.Generate(levelname, players.PlayersCount() - 1, 3, false); ZeroGPacket fullPacket = PacketGenerator.Generate("LevelInfo", packet); serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered); countDownTimer.Stop(); }
private void Listener_PeerConnectedEvent(NetPeer peer) { //throw new NotImplementedException(); resetEvent.Set(); WriteLog.Debug("Successfully connected to server, sending info: " + peer.EndPoint); ClientInfo packet = new ClientInfo(); packet.Generate(playername); ZeroGPacket mainPacket = PacketGenerator.Generate("ClientInfo", packet); peer.Send(netPackProc.Write(mainPacket), DeliveryMethod.ReliableOrdered); }
private void OnMaxPlayersReached(object sender, EventArgs e) { Console.WriteLine("max players reached"); PlayerNames packet2 = new PlayerNames(); List <string> playerName = new List <string>(); foreach (Player player in players.PlayersList) { playerName.Add(player.PlayerName); } packet2.Generate(playerName); ZeroGPacket mainPacket2 = PacketGenerator.Generate("PlayerNames", packet2); serverInst.SendToAll(mainPacket2, DeliveryMethod.ReliableOrdered); GameLevelInfo packet = new GameLevelInfo(); packet.Generate(levelname, players.PlayersCount() - 1, 3, isReverse); ZeroGPacket fullPacket = PacketGenerator.Generate("LevelInfo", packet); serverInst.SendToAll(fullPacket, DeliveryMethod.ReliableOrdered); countDownTimer.Stop(); }