//public Player Player //{ // get { return player; } // set { player = value; } //} public RemoteGameController(Player player, ClientSide clientSide, UDPClientServerCommons.Packets.GameInfoPacket gameInfo) { gameStatus = GameStatus.WaitingForStart; clientNetworkLayer = clientSide; this.player = player; this.gameInfo = gameInfo; }
void ClientSideNetworking_PacketReceivedEvent(UDPClientServerCommons.Interfaces.IPacket packet) { if (packet.PacketType == UDPClientServerCommons.Constants.PacketTypeEnumeration.StandardServerPacket) { lock (serverPacketLock) { this.serverPacket = (UDPClientServerCommons.Packets.ServerPacket)packet; } } this.Invoke(new RefreshEvent(RefreshForm), null); }
public GameplayForm(UDPClientServerCommons.Client.ClientSide clientSide) { InitializeComponent(); System.Threading.TimerCallback tc = new System.Threading.TimerCallback(timerCallback); gameLoopTimer = new System.Threading.Timer(tc); gameLoopTimer.Change(1000, 1000); network = clientSide; //gameLoopTimer = new System.Threading.Timer(new System.Threading.TimerCallback(timerCallback), null, 0, 1000); }
public ChooseTeamForm(UDPClientServerCommons.Packets.GameInfoPacket gameInfo) { InitializeComponent(); packet = (UDPClientServerCommons.Packets.GameInfoPacket)gameInfo.Clone(); dataGridView1.DataSource = packet.TeamScoreList; dataGridView2.DataSource = packet.PlayerStatusList; dataGridView2.Enabled = false; this.DialogResult = DialogResult.Cancel; this.textBox1.Text += textBox1.Text.GetHashCode().ToString(); }
public WeaponClass GetWeaponClassByID(UDPClientServerCommons.Constants.WeaponEnumeration weapon, GameTeam team) { if (team == GameTeam.Assassins) { if (weapon == UDPClientServerCommons.Constants.WeaponEnumeration.CrossBow) return ObjectCache.Instance.GetWeapon("Pipe"); if (weapon == UDPClientServerCommons.Constants.WeaponEnumeration.Sword) return ObjectCache.Instance.GetWeapon("Fireball"); } else if (team == GameTeam.Knights) { if (weapon == UDPClientServerCommons.Constants.WeaponEnumeration.CrossBow) return ObjectCache.Instance.GetWeapon("Crossbow"); if (weapon == UDPClientServerCommons.Constants.WeaponEnumeration.Sword) return ObjectCache.Instance.GetWeapon("Grenade"); } return null; }
private void showData(UDPClientServerCommons.Usefull.PlayerData data) { if(data.Shoot || data.Jump) txtSend.Text = data.ToString() + System.Environment.NewLine + txtSend.Text; }
/// <summary> Send new playerData /// /// </summary> /// <param name="playerData">info about the current player state</param> public void UpdatePlayerData(UDPClientServerCommons.Interfaces.IPlayerDataWrite playerData) { Usefull.PlayerData pdata = (Usefull.PlayerData)playerData; lock (clientPacketLock) { try { clientPacket.TimeStamp = DateTime.Now; clientPacket.PlayerJumping = pdata.Jump; clientPacket.PlayerShooting = pdata.Shoot; clientPacket.PlayerPosition = Translator.TranslateBetweenVectorAndVector(pdata.Position); clientPacket.PlayerMovementDirection = Translator.TranslateBetweenVectorAndVector(pdata.Velocity); clientPacket.PlayerLookingDirection = Translator.TranslateBetweenVectorAndVector(pdata.LookingDirection); switch (pdata.Weapon) { case WeaponEnumeration.CrossBow: clientPacket.PlayerCarringWeponOne = true; clientPacket.PlayerCarringWeponTwo = false; break; case WeaponEnumeration.None: clientPacket.PlayerCarringWeponOne = false; clientPacket.PlayerCarringWeponTwo = false; break; case WeaponEnumeration.Sword: clientPacket.PlayerCarringWeponOne = false; clientPacket.PlayerCarringWeponTwo = true; break; } } catch (Exception ex) { Diagnostic.NetworkingDiagnostics.Logging.Error("UpdatePlayerData S", ex); } } }
private void clientForServer_AddMessageToServer(UDPClientServerCommons.Interfaces.IPacket packet) { if (packet.PacketType == PacketTypeEnumeration.StandardClientPacket) { // adding client info to server packet ClientPacket cp = (ClientPacket)packet; lock (serverPacketLock) { for (int i = 0; i < serverPacket.PlayerInfoList.Count; i++) if (serverPacket.PlayerInfoList[i].PlayerId == cp.PlayerId) { serverPacket.PlayerInfoList[i] = Translator.TranslateBetweenClientPacketAndPlayerInfo(cp); break; } } } if (packet.PacketType == PacketTypeEnumeration.JoinPacket) { JoinPacket joinPacket = (JoinPacket)packet; lock (serverPacketLock) { for (int i = 0; i < gameInfoPacket.PlayerStatusList.Count; i++) { if (gameInfoPacket.PlayerStatusList[i].PlayerId == joinPacket.PlayerId) { // we update playerName gameInfoPacket.PlayerStatusList[i].PlayerName = joinPacket.PlayerName; // change team request gameInfoPacket.PlayerStatusList[i].PlayerTeam = joinPacket.TeamId; break; } } } } }
void clientSideNetworking_PacketReceivedEvent(UDPClientServerCommons.Interfaces.IPacket serverPacket) { if (serverPacket.PacketType == UDPClientServerCommons.Constants.PacketTypeEnumeration.GameInfoPacket) { dataGridView1.Invoke(new RefreshDelegate(RefreshGrid)); } }