Ejemplo n.º 1
0
        public void Fire(Vector2 Position, float Angle)
        {
            FireRate = (1 / Mod.Weapons[Weapon].RoundsPerSecond);
            Vector2 Start = (Position + Globe.Rotate((Mod.Weapons[Weapon].Bullet * Scale), Angle)), End = Globe.Move(Start, Angle, 2500);
            Line    Bullet = new Line(Start, End);

            for (int x = 0; x < Map.Tiles.GetLength(0); x++)
            {
                for (int y = 0; y < Map.Tiles.GetLength(1); y++)
                {
                    if (Map.Tiles[x, y].HasFore && (Mod.Fore[Map.Tiles[x, y].Fore].Type == Mod.Tile.Types.Wall))
                    {
                        Polygon Mask = Polygon.CreateCross(new Vector2(Tile.Width, Tile.Height), Vector2.Zero);
                        Mask.Position = new Vector2(((x * Tile.Width) + (Tile.Width / 2f)), ((y * Tile.Height) + (Tile.Height / 2f)));
                        Vector2 Intersection = Vector2.Zero;
                        if (Mask.Intersects(Bullet, ref Intersection))
                        {
                            Bullet.End = Intersection;
                        }
                    }
                }
            }
            if (this == Self)
            {
                if (MultiPlayer.Type() == MultiPlayer.Types.Client)
                {
                    MultiPlayer.Send(MultiPlayer.Construct(Packets.Fire, Position, Angle));
                }
                else if (MultiPlayer.Type() == MultiPlayer.Types.Server)
                {
                    MultiPlayer.Send(MultiPlayer.Construct(Packets.Fire, Slot, Position, Angle));
                }
            }
            else
            {
                for (byte i = 0; i < Players.Length; i++)
                {
                    if ((Players[i] != null) && (Players[i] != this) && (Players[i] != Self) && ((Players[i].Team == 0) || (Team == 0) || (Players[i].Team != Team)))
                    {
                        Vector2 Intersection = Vector2.Zero;
                        if (Players[i].Mask.Intersects(Bullet, ref Intersection))
                        {
                            Bullet.End = Intersection;
                        }
                    }
                }
                if (((Team == 0) || (Self.Team == 0) || (Team != Self.Team)) && Self.Mask.Intersects(Bullet))
                {
                    Self.Health -= Mod.Weapons[Weapon].Damage; Self.Killer = this;
                }
            }
            //Bullets.Add(Bullet);
        }