Exemple #1
0
        protected void updateBullets(GameTime gameTime, Vector2 bulletDirection)
        {
            if (ShootingBullets || BulletMade)
            {
                bulletTimer += gameTime.ElapsedGameTime.Milliseconds;

                if (bulletTimer > timeBetweenBullets)
                {
                    // Reset bulletTimer
                    bulletMade = true;
                    bulletTimer = 0;

                    Projectile tempBullet = new Projectile(
                        texture_bullet,
                        this.position.X,
                        this.position.Y,
                        bulletDirection,
                        2000,   // ActiveTime in miliseconds (2 secs)
                        40,     // Damage amount Inge pulled out of his ass
                        bulletSpeed);

                    tempBullet.Identifier = bulletCounter++;

                    bullets.Add(tempBullet);
                }
                else
                {
                    if (bulletMade)
                        bulletMade = false;
                }
            }

            // Updates the bullets and removes them if they go over their activeTime
            for (int i = 0; i < bullets.Count(); i++)
            {
                bullets[i].update(gameTime);

                if (bullets[i].TotalActiveTime > bullets[i].ActiveTime)
                    bullets.RemoveAt(i);
            }
        }
Exemple #2
0
        public void updateRockets(GameTime gameTime)
        {
            if (ShootingRockets || RocketMade)
            {
                rocketTimer += gameTime.ElapsedGameTime.Milliseconds;

                Console.Out.WriteLine(rocketTimer);

                if ((rocketTimer > timeBetweenRockets) && RocketAmmo > 0)
                {
                    // reset RocketTimer
                    rocketTimer = 0;
                    RocketMade = true;

                    Projectile tempRocket = new Projectile(
                        texture_rocket,
                        this.Position.X,
                        this.Position.Y,
                        this.Velocity,
                        1500,
                        60,
                        rocketSpeed);

                    tempRocket.Identifier = bulletCounter++;

                    bullets.Add(tempRocket);

                    RocketAmmo--;
                }
                else
                {
                    if (RocketMade)
                        RocketMade = false;
                }
            }
        }