예제 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Intersects. </summary>
        ///
        /// <remarks>   Frost, 16.11.2010. </remarks>
        ///
        /// <param name="bullet">   The bullet. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public void Intersects(Bullet bullet)
        {
            if (Vector2.Distance(center, bullet.Center) <= 12)
            {
                health -= (float)bullet.Damage;
                bullet.Kill();
            }
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            // if (attacking && bulletTimer >= 1.7f)
            if (attacking && bulletTimer >= 0.3f)
            {
                if (target == null || !IsInRange(target.Center))
                {
                    attacking = false;
                }
                else
                {
                    GetTarget();

                    Bullet bullet = new Bullet(bulletTexture, Vector2.Subtract(center,
                                                                               new Vector2(bulletTexture.Width / 2)), rotation, damage);

                    bulletList.Add(bullet);

                    soundBank.PlayCue("91572__steveygos93__layeredgunshot");

                    bulletTimer = 0;
                }
            }

            if (target != null)
            {
                GetTarget();
            }

            for (int i = 0; i < bulletList.Count; i++)
            {
                Bullet b = bulletList[i];
                b.SetRotation(rotation);
                b.Update(gameTime);

                if (target != null)
                {
                    target.Intersects(b);
                }

                if (!IsInRange(b.Center))
                {
                    b.Kill();
                }

                if (b.IsDead() || target == null)
                {
                    bulletList.Remove(b);
                }
            }
        }
예제 #3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Updates the given gameTime. </summary>
        ///
        /// <remarks>   Frost, 16.11.2010. </remarks>
        ///
        /// <param name="gameTime"> Time of the game. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (attacking && bulletTimer >= 3)
            {
                if (targets.Count == 0)
                {
                    attacking = false;
                }
                else
                {
                    for (int i = 0; i < directions.Length; i++)
                    {
                        Bullet bullet = new Bullet(bulletTexture, Vector2.Subtract(center,
                                                                                   new Vector2(bulletTexture.Width / 2)), directions[i], damage);

                        bulletList.Add(bullet);
                    }
                    soundBank.PlayCue("flame2");
                    bulletTimer = 0;
                }
            }

            for (int i = 0; i < bulletList.Count; i++)
            {
                Bullet b = bulletList[i];
                b.Update(gameTime);

                for (int t = 0; t < targets.Count; t++)
                {
                    if (targets[t] != null || !targets[t].IsDead)
                    {
                        targets[t].Intersects(b);
                    }
                }

                if (!IsInRange(b.Center))
                {
                    b.Kill();
                }

                if (b.IsDead() || targets.Count == 0)
                {
                    bulletList.Remove(b);
                }
            }
        }
예제 #4
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>   Intersects. </summary>
 ///
 /// <remarks>   Frost, 16.11.2010. </remarks>
 ///
 /// <param name="bullet">   The bullet. </param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public void Intersects(Bullet bullet)
 {
     if (Vector2.Distance(center, bullet.Center) <= 12)
     {
         health -= (float)bullet.Damage;
         bullet.Kill();
     }
 }