Example #1
0
        public static void UpdateMelee(NetPeer client, string body) //.MELEE
        {
            MeleeHitData payload = JsonConvert.DeserializeObject <MeleeHitData>(body);

            foreach (var entry in ServerV2.players)
            {
                if (!entry.Value.active)
                {
                    continue;
                }
                Player player = entry.Value;
                if (player.getHitbox().Contains(payload.position.ToPoint()))
                {
                    player.addHealth(-payload.damage);
                    ServerSenderV2.SendFullPlayerData(new FullPlayerData(player.name, player.active, player.hp, new PlayerData(player.uid, player.position, player.orientation)));
                }
            }
        }
Example #2
0
 public bool Update(ServerTime gameTime)
 {
     position += new Vector2((float)(Math.Sin(angle) * -velocity * gameTime.ElapsedGameTime.TotalSeconds), (float)(Math.Cos(angle) * -velocity * gameTime.ElapsedGameTime.TotalSeconds));
     if (!ServerV2.map.isValidPosition(position))
     {
         return(false);
     }
     foreach (var entry in ServerV2.players)
     {
         Player player = entry.Value;
         if (!player.active)
         {
             continue;
         }
         if (player.getHitbox().Contains(new Point((int)position.X, (int)position.Y)))
         {
             player.addHealth(-damage);
             FullPlayerData payload = new FullPlayerData(player.name, player.active, player.hp, new PlayerData(player.uid, player.position, player.orientation));
             ServerSenderV2.SendFullPlayerData(payload);
             return(false);
         }
     }
     return(true);
 }