예제 #1
0
        public void receive_damage_request(NetIncomingMessage m, Display d, World w)
        {
            d.add_message("@05Attack message length: " + m.LengthBytes);
            int num_attack = m.ReadUInt16();

            for (int i = 0; i < num_attack; i++)
            {
                DamageMove t           = new DamageMove(m);
                Rectangle  target_rect = new Rectangle();
                if (t.target == TargetType.Player)
                {
                    target_rect = new Rectangle((int)w.players[t.target_id].avatar.world_loc.X - w.players[t.target_id].avatar.bounding_box.Width / 2,
                                                (int)w.players[t.target_id].avatar.world_loc.Y - w.players[t.target_id].avatar.bounding_box.Height / 2,
                                                w.players[t.target_id].avatar.bounding_box.Width, w.players[t.target_id].avatar.bounding_box.Height);
                }
                else
                {
                    target_rect = new Rectangle((int)w.npcs[t.target_id].world_loc.X - w.npcs[t.target_id].bounding_box.Width / 2,
                                                (int)w.npcs[t.target_id].world_loc.Y - w.npcs[t.target_id].bounding_box.Height / 2, w.npcs[t.target_id].bounding_box.Width, w.npcs[t.target_id].bounding_box.Height);
                }
                Circle c = new Circle(new Point((int)w.players[t.attacker_id].avatar.world_loc.X, (int)w.players[t.attacker_id].avatar.world_loc.Y), t.range);
                if (c.intersects_rectangle(target_rect))
                {
                    damages.Add(t);
                }
            }
        }
예제 #2
0
 public void receive_death_notice(NetIncomingMessage p, World w)
 {
     if (!Exilania.game_server)
     {
         DamageMove t = new DamageMove(p);
         if (t.target == TargetType.Player)
         {
             Exilania.display.fading_text.Add(new FadeText("@08-" + t.damage, 800, (int)w.players[t.target_id].avatar.world_loc.X + (Exilania.rand.Next(0, 40) - 20),
                                                           (int)w.players[t.target_id].avatar.world_loc.Y - (Exilania.rand.Next(20, 40)), true, true));
             w.players[t.target_id].avatar.world_loc.X = w.world_spawn_loc.X;
             w.players[t.target_id].avatar.world_loc.Y = w.world_spawn_loc.Y;
             w.players[t.target_id].avatar.dloc_server = w.players[t.target_id].avatar.world_loc;
             w.players[t.target_id].avatar.stats.life.change_val(w.players[t.target_id].avatar.stats.life.max_val);
             w.players[t.target_id].avatar.stats.power.change_val(w.players[t.target_id].avatar.stats.power.max_val);
             w.players[t.target_id].avatar.stats.ammo.change_val(w.players[t.target_id].avatar.stats.ammo.max_val);
             w.players[t.target_id].avatar.stats.breath.change_val(w.players[t.target_id].avatar.stats.breath.max_val);
             w.players[t.target_id].avatar.damages.Clear();
             Exilania.display.add_message("@08" + w.players[t.target_id].avatar.name + " has " + t.damage_code.ToString().ToLower() + "!");
         }
         else
         {
             w.npcs[t.target_id].empty = true;
         }
     }
 }
예제 #3
0
 public void receive_damage_notice(NetIncomingMessage p, World w)
 {
     if (!Exilania.game_server && w.players.Count > 0)
     {
         DamageMove t   = new DamageMove();
         int        num = p.ReadUInt16();
         for (int i = 0; i < num; i++)
         {
             t = new DamageMove(p);
             if (t.target == TargetType.Player)
             {
                 w.players[t.target_id].avatar.damages.Add(t);
             }
             else if (t.target == TargetType.NPC)
             {
                 w.npcs[t.target_id].damages.Add(t);
             }
         }
     }
 }
예제 #4
0
        public void send_death_notice(DamageMove t, World w)
        {
            NetOutgoingMessage m = udp_server.CreateMessage();

            if (t.target == TargetType.Player)
            {
                w.players[t.target_id].avatar.world_loc.X = w.world_spawn_loc.X;
                w.players[t.target_id].avatar.world_loc.Y = w.world_spawn_loc.Y;
                w.players[t.target_id].avatar.dloc_server = w.players[t.target_id].avatar.world_loc;
                w.players[t.target_id].avatar.stats.life.change_val(w.players[t.target_id].avatar.stats.life.max_val);
                w.players[t.target_id].avatar.stats.power.change_val(w.players[t.target_id].avatar.stats.power.max_val);
                w.players[t.target_id].avatar.stats.ammo.change_val(w.players[t.target_id].avatar.stats.ammo.max_val);
                w.players[t.target_id].avatar.stats.breath.change_val(w.players[t.target_id].avatar.stats.breath.max_val);
                Exilania.display.add_message("@08" + w.players[t.target_id].avatar.name + " has " + t.damage_code.ToString().ToLower() + "!");
            }
            else
            {
                w.npcs[t.target_id].empty = true;
            }
            m.Write((byte)22);
            t.send_damage(m);
            udp_server.SendToAll(m, NetDeliveryMethod.ReliableOrdered);
        }