private void PlayerShot(PlayerDummy player, ByteBufferReader data) { var pos = data.ReadVec2(); var dir = data.ReadVec2(); var hit = new List <Tuple <float, PlayerDummy> >(); foreach (var playerDummy in _players.Values) { if (player == playerDummy || playerDummy.Health <= 0) { continue; } if (RayHelper.Intersects(playerDummy.GetBoundingBox(), pos, dir, out var dist)) { hit.Add(new Tuple <float, PlayerDummy>(dist, playerDummy)); } } var damageToDeal = 35f; foreach (var tuple in hit.OrderBy(el => el.Item1)) { var plr = tuple.Item2; if (plr.Respawning) { continue; } plr.Health -= damageToDeal; if (plr.Health <= 0) { plr.BeginRespawn(); } damageToDeal /= 2; } dir *= float.MaxValue; var payload = new ByteBufferWriter(data.Code); payload.WriteVec2(pos); payload.WriteVec2(dir); SendUdpMessageToAllExcept(player, payload); }
private void LoadMap() { var file = "maps\\map0.ssmap"; if (!File.Exists(file)) { return; } var payload = new ByteBufferReader(File.ReadAllBytes(file)); var count = payload.ReadInt32(); for (int i = 0; i < count; i++) { var min = payload.ReadVec2(); var max = payload.ReadVec2(); _boxes.Add(new AxisAlignedBB(min, max)); } }
private void UpdatePlayer(PlayerDummy player, ByteBufferReader data) { player.SetPos(data.ReadVec2()); player.Rotation = data.ReadVec2(); }