Exemplo n.º 1
0
        private Bullet[] shards; //array of shards

        #endregion Fields

        #region Constructors

        public ExplodingBullet(int n, double sAngle, double eAngle, int x, int y, int v, Texture2D loadSprite, float scale)
            : base(loadSprite, scale)
        {
            numShards = n;
            exploded = false;
            explodeX = x;
            explodeY = y;
            explodeVelocity = v;
            angles = new double[numShards];
            shards = new Bullet[numShards];
            double angleIncrement = (eAngle - sAngle) / (numShards - 1);
            for (int i = 0; i < numShards; i++)
            {
                angles[i] = sAngle + (angleIncrement * i);
                shards[i] = new Bullet(sprite, scaleFactor);
            }
        }
Exemplo n.º 2
0
        public Enemy(AnimatedTexture spriteA, AnimatedTexture spriteD, Texture2D loadedBullet,
            int numBullets, float scale, Vector2 initialPosition,
            int mpattern, int fpattern, bool foodDrop, bool left)
        {
            // Assign essential textures.
            spriteAlive = spriteA;
            spriteDead = spriteD;
            width = (int)((spriteA.myTexture.Width / (spriteA.framecount / spriteA.rows)) * spriteA.Scale);
            height = (int)((spriteA.myTexture.Height / spriteA.rows) * spriteA.Scale);
            rotation = 0.0f;            // No initial rotation.
            animating = true;
            alive = true;         // Enemies start alive when they are added to the enemy list.
            maxBullets = numBullets;
            position = initialPosition;
            center = new Vector2(width / 2, height / 2);      // Center value assigned.
            movePattern = mpattern;
            firePattern = fpattern;
            dropsFood = foodDrop;
            //            time = new fireTimer();
            enemyTime = new Timer();
            isLeft = left;

            // Save textures for copying enemies.
            aliveTex = spriteA.myTexture;
            deadTex = spriteD.myTexture;
            bulletText = loadedBullet;

            // Initializae new array of bullets.
            bullets = new Bullet[maxBullets];
            for (int i = 0; i < maxBullets; i++)
            {
                bullets[i] = new Bullet(loadedBullet, scale);
            }
            rand = new Random();
        }