Beispiel #1
0
        bool checkForIsaacHurt()
        {
            if (sledgeHammerInUse || isaacHurtAnimation.IsRunning)
            {
                return(false);
            }

            if ((alex is AlexEnchanter && !((AlexEnchanter)alex).IsWarping) &&
                alex.Rectangle.Intersects(isaac.Rectangle))
            {
                return(isaacHurt(ALEX_DAMAGE));
            }

            // big fireball
            foreach (Fireball fireball in Fireball.Fireballs)
            {
                if (fireball.Width == AlexEnchanter.SUPERFIREBALLSIZE && fireball.Intersects(isaac))
                {
                    isaacHurtAngle = (float)Math.Atan2(isaac.CenterPoint.Y - fireball.CenterPoint.Y, isaac.CenterPoint.X - fireball.CenterPoint.X);
                    //isaacIsHurtBad = true;
                    soundEffectManager.Play(fireballHitSound, .5f);
                    return(isaacHurt(SUPERFIREBALL_DAMAGE, isaacHurtBadSound, .25f));
                }
            }

            foreach (MouseSeeker mouse in MouseSeeker.MouseSeekers)
            {
                mouse.FrontBit.CalculateCorners();
                if (mouse.FrontBit.IsNear(isaac, .5f) && mouse.FrontBit.Intersects(isaac))
                {
                    return(isaacHurt(MOUSE_DAMAGE));
                }
            }

            foreach (Laser2 laser in Laser2.Lasers)
            {
                if (laser.IsNear(isaac, laser.Width) &&
                    isaac.Intersects(laser))
                {
                    return(isaacHurt(LASER_DAMAGE));
                }
            }

            // small fireballs
            foreach (Fireball fireball in Fireball.Fireballs)
            {
                //if (isaac.Rectangle.Intersects(fireball.Rectangle))
                if (fireball.Width != AlexEnchanter.SUPERFIREBALLSIZE && fireball.Intersects(isaac))
                {
                    return(isaacHurt(FIREBALL_DAMAGE));
                }
            }

            return(false);
        }
Beispiel #2
0
        protected void checkForIsaacDeath()
        {
            if (sledgeHammerInUse)
            {
                return;
            }

            if (bill.Rectangle.Intersects(isaac.Rectangle))
            {
                isaacDeath();
                return;
            }

            for (int i = 0; i < Bullet.Cans.Count;)
            {
                Bullet b = Bullet.Cans[i];
                if (isaac.Intersects(b))
                {
                    if (isaac.hasPowerUp(PowerUpType.CanShield))
                    {
                        PowerUp p = isaac.getActivePowerUp(PowerUpType.CanShield);
                        if (--p.Charges <= 0)
                        {
                            isaac.removePowerUp(PowerUpType.CanShield);
                        }
                        Bullet.Cans.Remove(b);
                        continue;
                    }
                    else
                    {
                        isaacDeath();
                        return;
                    }
                }
                i++;
            }
        }
Beispiel #3
0
        void checkForBulletHits()
        {
            if (frameCounter % 2 == 0)
            {
                Util.SortByX(Bullet.Cans);
                foreach (Bullet p in Bullet.Peanuts)
                {
                    updatePotentialCollisions(p, Bullet.Cans);
                }
            }

            // hits on cans
            if (GameSettings.CansBlockPeanuts)
            {
                for (int i = 0; i < Bullet.Peanuts.Count;)
                {
                    Bullet p = Bullet.Peanuts[i];

                    foreach (Bullet c in p.PotentialCollisions)
                    {
                        if (c.Intersects(p))
                        {
                            Bullet.Peanuts.Remove(p);
                            Stats.PeanutShots--;
                            goto nextPeanut;
                        }
                    }

                    /*foreach (Bullet c in Bullet.Cans)
                     * {
                     *  if (GameSettings.ProjectileRotationCollision)
                     *  {
                     *      if (c.IsNear(p.CenterPoint) && c.Intersects(p))
                     *      {
                     *          Bullet.Peanuts.Remove(p);
                     *          Stats.PeanutShots--;
                     *          goto nextPeanut;
                     *      }
                     *  }
                     *  else
                     *  {
                     *      if (c.Rectangle.Intersects(p.Rectangle))
                     *      {
                     *          Bullet.Peanuts.Remove(p);
                     *          Stats.PeanutShots--;
                     *          goto nextPeanut;
                     *      }
                     *  }
                     * }*/
                    i++;
                    nextPeanut :;
                }
            }

            // hits on bill
            for (int i = 0; i < Bullet.Peanuts.Count;)
            {
                Bullet b = Bullet.Peanuts[i];
                if ((GameSettings.ProjectileRotationCollision && bill.Intersects(b)) ||
                    bill.Rectangle.Intersects(b.Rectangle))
                {
                    Bullet.Peanuts.Remove(b);
                    soundEffectManager.Play(billHit, 1f);
                    bill.HP -= GameSettings.PeanutDamage;
                    Stats.PeanutHits++;
                }
                else
                {
                    i++;
                }
            }
        }