Exemplo n.º 1
0
        public Weapon(Func <int, int, double, teamEnum, bool> function, Sprite sh)
        {
            this.team = team;
            fireFunc  = new fireMode(function);
            shooter   = sh;

            String imagePath = System.IO.Directory.GetCurrentDirectory() + "/../../Images/cropped_contra_images/hero/bullet.png";

            bulletImage = (Bitmap)Image.FromFile(imagePath, true);
            bulletImage = Utilities.ScaleImage(bulletImage, 10, 10);
        }
Exemplo n.º 2
0
        public static bool fireWeapon(int x, int y, double degrees, teamEnum team)
        {
            double rads = (2 * Math.PI * degrees) / 360;

            double offset = .1;

            create_bullet(x, y, Math.Cos(rads + 2 * offset), Math.Sin(rads + 2 * offset));
            create_bullet(x, y, Math.Cos(rads + offset), Math.Sin(rads + offset));
            create_bullet(x, y, Math.Cos(rads), Math.Sin(rads));
            create_bullet(x, y, Math.Cos(rads - offset), Math.Sin(rads - offset));
            create_bullet(x, y, Math.Cos(rads - 2 * offset), Math.Sin(rads - 2 * offset));

            return(true);
        }
Exemplo n.º 3
0
        public void create_bullet(int x, int y, double incX, double incY, teamEnum team)
        {
            Sprite sprite = new Sprite(bulletImage, (int)timeEnum.BULLET_LIFE);

            sprite.setTeam(shooter.getTeam());

            sprite.setPosition(new Pair(x, y));
            sprite.calculatePosition();

            double c        = Math.Sqrt(incX * incX + incY * incY);
            Pair   velocity = new Pair(incX * velocityMagnitude / c, incY * velocityMagnitude / c);

            sprite.setVelocity(velocity);

            Scene.getLevel().addSprite(sprite);
        }
Exemplo n.º 4
0
 public void setTeam(teamEnum t)
 {
     this.team = t;
 }