示例#1
0
        void checkForPowerUpAcquisition()
        {
            //check for acquisition
            for (int i = 0; i < PowerUp.AlivePowerUps.Count;)
            {
                PowerUp p = PowerUp.AlivePowerUps[i];
                if (isaac.Rectangle.Intersects(p.Rectangle))
                {
                    soundEffectManager.Play(getPowerUp, .5f);
                    isaac.acquirePowerUp(p);
                    PowerUp.AlivePowerUps.Remove(p);
                }
                else
                {
                    i++;
                }
            }

            // update status of active powerups
            isaac.updatePowerUps();
        }
示例#2
0
        public EndBattle1(EventHandler callback)
            : base(callback, false)
        {
            if (!contentLoaded)
            {
                endBattle1Font1     = Content.Load <SpriteFont>("EndBattle1Font1");
                actTitleFont        = Content.Load <SpriteFont>("ActTitleFont");
                keysTexture         = Content.Load <Texture2D>("carkeys");
                rollerBladesTexture = Content.Load <Texture2D>("rollerblades");
                wizardTexture       = Content.Load <Texture2D>("mikewizard");
                mikeTheme           = Content.Load <Song>("miketheme");
            }

            MediaPlayer.Stop();
            bill.speed           = new Vector2(4500, 4500);
            bill.Width          *= 2;
            bill.Height         *= 2;
            billHealthBar.Width *= 2;
            bill.HP              = 0;
            Bullet.Cans.Clear();
            PowerUp.RemoveAlivePowerUps();
            string status = "BAHUHUHUHUHUHUHUH";

            currentBillMessage      = LOWHPMESSAGE;
            Game1.Game.Window.Title = status;
            soundEffectManager.Play(billDeath, 1f);

            keys             = new BaseObject(new Rectangle(0, 0, 50, 50));
            keys.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height / 2);
            keys.Texture     = keysTexture;

            wizard             = new BaseObject(new Rectangle(0, 0, WIZARDWIDTH, WIZARDHEIGHT));
            wizard.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height * .48f);
            wizard.Texture     = wizardTexture;

            rollerBlades             = new BaseObject(new Rectangle(0, 0, ROLLERBLADESWIDTH, ROLLERBLADESHEIGHT));
            rollerBlades.CenterPoint = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height * .9f);
            rollerBlades.Texture     = rollerBladesTexture;
        }
示例#3
0
文件: Battle2.cs 项目: nubington/bill
        void checkForSledgeHammerUse(GameTime gameTime)
        {
            if (sledgeHammerInUse && (!isaac.hasPowerUp(PowerUpType.SledgeHammer) || !isaac.getActivePowerUp(PowerUpType.SledgeHammer).ActiveTimer.IsRunning))
            {
                sledgeHammerInUse = false;
            }

            if (sledgeHammerInUse)
            {
                sledgeHammerOrigin.Rotation += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime);
                sledgeHammer.Rotation       += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime);
                sledgeHammerOrigin.X         = (int)isaac.CenterPoint.X - sledgeHammer.Width;
                sledgeHammerOrigin.Y         = (int)isaac.CenterPoint.Y - sledgeHammer.Height;
                sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2;
                sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner.Y;
                sledgeHammerOrigin.CalculateCorners();
                sledgeHammer.CalculateCorners();
            }

            if (!sledgeHammerInUse &&
                Keyboard.GetState().IsKeyDown(Keys.Space) &&
                isaac.hasPowerUp(PowerUpType.SledgeHammer) &&
                isaac.getActivePowerUp(PowerUpType.SledgeHammer).Charges > 0)// &&
            //!isaacHurtAnimation.IsRunning)
            {
                PowerUp p = isaac.getActivePowerUp(PowerUpType.SledgeHammer);
                p.ActiveTimer.Restart();
                soundEffectManager.Play(useHammerSound, .5f);

                sledgeHammerOrigin.Rotation = 0f;
                sledgeHammer.Rotation       = 0f;
                sledgeHammerOrigin.X        = (int)isaac.CenterPoint.X - sledgeHammer.Width;
                sledgeHammerOrigin.Y        = (int)isaac.CenterPoint.Y - sledgeHammer.Height;
                sledgeHammer.X    = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2;
                sledgeHammer.Y    = (int)sledgeHammerOrigin.UpperRightCorner.Y;
                sledgeHammerInUse = true;
            }
        }
示例#4
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++;
            }
        }
示例#5
0
        public override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Game1.Game.Exit();
            }
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape))
            {
                PowerUp.RemoveAlivePowerUps();
                returnControl("title");
                return;
            }

            if (part3Started && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Enter))
            {
                returnControl("entercarchase");
                return;
            }

            // mute check
            checkForMute();

            if (billRunning && bill.X >= Graphics.GraphicsDevice.Viewport.Width)
            {
                if ((DateTime.Now - startTime).TotalSeconds < 4)
                {
                    return;
                }
                billRunning  = false;
                part3Started = true;
                MediaPlayer.Play(mikeTheme);
                MediaPlayer.Volume = .5f;
            }

            if (part3Started)
            {
            }
            else
            {
                if ((DateTime.Now - startTime).TotalSeconds < 1)
                {
                    bill.moveTowards(isaac.CenterPoint, gameTime, true);
                    isaac.CalculateCorners();
                    bill.CalculateCorners();
                    checkForIsaacDeath();
                }
                else
                {
                    if (!part2Started)
                    {
                        Game1.Game.Window.Title = "";
                        part2Started            = true;
                    }
                    else
                    {
                        if ((DateTime.Now - startTime).TotalSeconds < 2)
                        {
                            return;
                        }
                        if (!billRunning)
                        {
                            bill.Width      /= 2;
                            bill.Height     /= 2;
                            bill.CenterPoint = new Vector2(-(bill.Width / 2), Graphics.GraphicsDevice.Viewport.Height / 2);
                            billRunning      = true;
                        }
                        else
                        {
                            bill.X += (int)Math.Round(Util.ScaleWithGameTime(1000, gameTime));
                            if (keys.Rectangle.Contains((int)bill.CenterPoint.X, (int)bill.CenterPoint.Y))
                            {
                                keysPickedUp = true;
                            }
                            if (keysPickedUp)
                            {
                                keys.CenterPoint = bill.CenterPoint;
                            }
                        }
                    }
                }
            }

            //SoundEffectManager.Cleanup();
        }
示例#6
0
        public override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Game1.Game.Exit();
            }
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape))
            {
                PowerUp.RemoveAlivePowerUps();
                returnControl("title");
                return;
            }

            // go to EndCarChase1
            if (timer.Elapsed.TotalSeconds >= TIMELIMIT)
            {
                Stats.CarChasePeanutScore = peanutCount;
                returnControl(isaac, bill);
                return;
            }

            // mute check
            checkForMute();

            // pause check
            if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P))
            {
                allowPause = true;
            }
            if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P))
            {
                paused    ^= true;
                allowPause = false;
                if (paused)
                {
                    timer.Stop();
                    MediaPlayer.Pause();
                }
                else
                {
                    timer.Start();
                    MediaPlayer.Resume();
                }
            }
            if (paused)
            {
                return;
            }

            //show fps every 1 second
            fpsElapsedTime += gameTime.ElapsedGameTime;
            if (fpsElapsedTime > TimeSpan.FromSeconds(1))
            {
                fpsElapsedTime         -= TimeSpan.FromSeconds(1);
                Game1.Game.Window.Title = "FPS: " + frameCounter;
                //Game1.Game.Window.Title = "FPS: " + frameCounter + " | Projectiles: " + (Bullet.Peanuts.Count + Bullet.Cans.Count) + " | Powerups: " + PowerUp.AlivePowerUps.Count + " | Sound instances: " + SoundEffectManager.SoundEffectInstances.Count + ".";
                //Game1.Game.Window.Title = "Peanuts: " + Bullet.Peanuts.Length + " Cans: " + Bullet.Cans.Length + " Powerups: " + PowerUp.AlivePowerUps.Count;
                frameCounter = 0;
            }

            actualScrollSpeed = (int)Math.Round(Util.ScaleWithGameTime(scrollSpeed, gameTime));
            scrollBackground(gameTime);

            if (isaac.CenterPoint.X > Graphics.GraphicsDevice.Viewport.Width / 2)
            {
                bill.moveTowards(isaac.CenterPoint, gameTime, true);
            }
            else
            {
                moveBillRandom(gameTime);
            }
            movePeanutGenerator(gameTime);
            if (!wipingOut)
            {
                moveIsaac(gameTime);
            }
            movePeanutsAndCans();

            if (GameSettings.ProjectileRotationCollision)
            {
                isaac.CalculateCorners();
                bill.CalculateCorners();
                foreach (Bullet b in Bullet.Peanuts)
                {
                    b.CalculateCorners();
                }
                foreach (Bullet b in Bullet.Cans)
                {
                    b.CalculateCorners();
                }
            }

            checkForWipeOut(gameTime);
            checkForBillShoot(gameTime);
            checkForPeanutGeneratorShoot(gameTime);
            checkForPeanutPickUp();

            /*if (++cleanupCounter >= 60)
             * {
             *  SoundEffectManager.Cleanup();
             *  cleanupCounter = 0;
             * }*/
        }
示例#7
0
        public void acquirePowerUp(PowerUp p)
        {
            if (p.Charges == 0)
                p.ActiveTimer.Start();

            // remove previous powerup of same type or increase charges
            for (int i = 0; i < ActivePowerUps.Count; )
            {
                if (ActivePowerUps[i].Type == p.Type)
                {
                    if (p.Type == PowerUpType.SledgeHammer || p.Type == PowerUpType.CanShield)
                        ActivePowerUps[i].Charges += p.Type.Charges;
                    else
                    {
                        ActivePowerUps.RemoveAt(i);
                        ActivePowerUps.Insert(i, p);
                    }
                    return;
                }
                else
                    i++;
            }
            if (p.Charges == 0)
                p.ActiveTimer.Start();
            this.ActivePowerUps.Add(p);
        }
示例#8
0
文件: Battle2.cs 项目: nubington/bill
        void checkForPowerUpSpawnExpire(GameTime gameTime)
        {
            //spawn
            timeSinceLastPowerUpSpawn += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (timeSinceLastPowerUpSpawn >= powerUpSpawnDelay)
            {
                PowerUp p;
                if (((AlexEnchanter)alex).HasPeanutShield && !isaac.hasPowerUp(PowerUpType.SledgeHammer) && !PowerUp.IsPowerUpAlive(PowerUpType.SledgeHammer))
                {
                    p = PowerUp.SledgeHammer;
                }
                else
                {
                    do
                    {
                        p = PowerUp.Random;
                    }while (p.Type == PowerUpType.CanShield);
                }
                do
                {
                    p.X = rand.Next(p.maxX + 1);
                    p.Y = rand.Next(p.maxY + 1);
                }while (isaac.IsNear(p, 1f));
                p.AliveDuration = (int)(powerUpAliveDuration * 1000);
                PowerUp.AlivePowerUps.Add(p);
                timeSinceLastPowerUpSpawn = 0;
            }

            //expire
            for (int i = 0; i < PowerUp.AlivePowerUps.Count;)
            {
                PowerUp p = PowerUp.AlivePowerUps[i];
                if (p.AliveTimer.Elapsed.TotalMilliseconds >= p.AliveDuration)
                {
                    PowerUp.AlivePowerUps.Remove(p);
                }
                else
                {
                    i++;
                }
            }
        }
示例#9
0
        public Battle1(EventHandler callback, bool startMusic)
            : base(callback)
        {
            // initialize
            Game1.Game.IsMouseVisible = false;
            bill          = new Character(new Rectangle(0, 0, BILLWIDTH, BILLHEIGHT), new Vector2(GameSettings.BillSpeed, GameSettings.BillSpeed));
            isaac         = new Character(new Rectangle(Graphics.GraphicsDevice.Viewport.Width / 2 - ISAACWIDTH / 2, 0, ISAACWIDTH, ISAACHEIGHT), new Vector2(GameSettings.IsaacSpeed, GameSettings.IsaacSpeed));
            billHealthBar = new HealthBar(new Rectangle(0, 0, bill.Width, bill.Height / 12));
            billTarget    = new Vector2(rand.Next(BILLWIDTH / 2, Graphics.GraphicsDevice.Viewport.Width - BILLWIDTH / 2), rand.Next(BILLHEIGHT / 2, Graphics.GraphicsDevice.Viewport.Height - BILLHEIGHT / 2));
            Bullet.Peanuts.Clear();
            Bullet.Cans.Clear();
            PowerUp.RemoveAlivePowerUps();
            startTime               = timeOfLastDeath = DateTime.Now;
            bill.HP                 = bill.MaxHP = GameSettings.BillHP;
            bill.ShootDelay         = (int)(1000 / GameSettings.BillShootSpeed);
            isaac.ShootDelay        = (int)(250 / GameSettings.IsaacShootSpeed);
            isaac.TimeSinceLastShot = isaac.ShootDelay;
            isaac.Y                 = Graphics.GraphicsDevice.Viewport.Height - ISAACHEIGHT;
            billMessages            = new string[] { "MUH", "MEH", "R U DUMB" };
            billHPString            = "";
            billStatusString        = "";
            sledgeHammer            = new BaseObject(new Rectangle(0, 0, SLEDGEHAMMERWIDTH, SLEDGEHAMMERHEIGHT), 0f);
            sledgeHammerOrigin      = new BaseObject(new Rectangle(0, 0, 1, SLEDGEHAMMERHEIGHT), 0f);
            allowPause              = true;
            cleanupCounter          = 0;
            generateIsaacSpawnPoints();

            // load content
            if (!contentLoaded)
            {
                deathSound  = Content.Load <SoundEffect>("death");
                billHit     = Content.Load <SoundEffect>("billhit");
                billDeath   = Content.Load <SoundEffect>("billdeath");
                getPowerUp  = Content.Load <SoundEffect>("getpowerup");
                canDeath    = Content.Load <SoundEffect>("candeath");
                useHammer   = Content.Load <SoundEffect>("usehammersound");
                music       = Content.Load <Song>("battlemusic");
                billTexture = Content.Load <Texture2D>("bill");
                //billTexture = Content.Load<Texture2D>("billtransparent");
                //billTexture2 = Content.Load<Texture2D>("bill2transparent");
                isaacTexture            = Content.Load <Texture2D>("isaac");
                isaacUsingHammerTexture = Content.Load <Texture2D>("isaacusinghammer");
                font1               = Content.Load <SpriteFont>("Battle1Font1");
                powerUpFont         = Content.Load <SpriteFont>("Battle1PowerUpFont");
                billStatusFont      = Content.Load <SpriteFont>("Battle1BillStatusFont");
                shieldTexture       = Content.Load <Texture2D>("shield");
                powerUpBarTexture   = Content.Load <Texture2D>("poweruptimebar");
                sledgeHammerTexture = Content.Load <Texture2D>("sledgehammer");
                contentLoaded       = true;
            }

            bill.Texture         = billTexture;
            isaac.Texture        = isaacTexture;
            sledgeHammer.Texture = sledgeHammerTexture;

            if (startMusic)
            {
                MediaPlayer.Play(music);
                MediaPlayer.Volume      = .25f;
                MediaPlayer.IsRepeating = true;
            }
        }
示例#10
0
        void checkForSledgeHammerUse(GameTime gameTime)
        {
            /*if (sledgeHammerInUse)
             * {
             *  if (sledgeHammerDirection == Direction.West)
             *  {
             *      sledgeHammerOrigin.Rotation -= SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
             *      sledgeHammer.Rotation -= SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
             *      //if (sledgeHammer.Rotation <= -10.99f)
             *      if (sledgeHammer.Rotation <= -3.14f)
             *      {
             *          sledgeHammerInUse = false;
             *          return;
             *      }
             *  }
             *  else if (sledgeHammerDirection == Direction.East)
             *  {
             *      sledgeHammerOrigin.Rotation += SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
             *      sledgeHammer.Rotation += SLEDGEHAMMERROTATIONSPEED * (float)gameTime.ElapsedGameTime.TotalSeconds;
             *      //if (sledgeHammer.Rotation >= 10.99f)
             *      if (sledgeHammer.Rotation >= 3.14f)
             *      {
             *          sledgeHammerInUse = false;
             *          return;
             *      }
             *  }
             *  sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width;
             *  sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height;
             *  sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner().X + sledgeHammer.Width / 2;
             *  sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner().Y;
             *  //4.71f
             * }
             *
             * if (!sledgeHammerInUse && Keyboard.GetState().IsKeyDown(Keys.Q))
             * {
             *  //sledgeHammerOrigin.Rotation = 1.62f;
             *  //sledgeHammer.Rotation = 1.62f;
             *  sledgeHammerOrigin.Rotation = 0f;
             *  sledgeHammer.Rotation = 0f;
             *  sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width;
             *  sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height;
             *  sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner().X + sledgeHammer.Width / 2;
             *  sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner().Y;
             *  sledgeHammerInUse = true;
             *  sledgeHammerDirection = Direction.West;
             * }
             * else if (!sledgeHammerInUse && Keyboard.GetState().IsKeyDown(Keys.E))
             * {
             *  //sledgeHammerOrigin.Rotation = -1.62f;
             *  //sledgeHammer.Rotation = -1.62f;
             *  sledgeHammerOrigin.Rotation = 0f;
             *  sledgeHammer.Rotation = 0f;
             *  sledgeHammerOrigin.X = (int)isaac.CenterPoint.X - sledgeHammer.Width;
             *  sledgeHammerOrigin.Y = (int)isaac.CenterPoint.Y - sledgeHammer.Height;
             *  sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner().X + sledgeHammer.Width / 2;
             *  sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner().Y;
             *  sledgeHammerInUse = true;
             *  sledgeHammerDirection = Direction.East;
             * }*/

            if (sledgeHammerInUse && (!isaac.hasPowerUp(PowerUpType.SledgeHammer) || !isaac.getActivePowerUp(PowerUpType.SledgeHammer).ActiveTimer.IsRunning))
            {
                sledgeHammerInUse = false;
            }

            if (sledgeHammerInUse)
            {
                sledgeHammerOrigin.Rotation += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime);
                sledgeHammer.Rotation       += Util.ScaleWithGameTime(SLEDGEHAMMERROTATIONSPEED, gameTime);
                sledgeHammerOrigin.X         = (int)isaac.CenterPoint.X - sledgeHammer.Width;
                sledgeHammerOrigin.Y         = (int)isaac.CenterPoint.Y - sledgeHammer.Height;
                sledgeHammer.X = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2;
                sledgeHammer.Y = (int)sledgeHammerOrigin.UpperRightCorner.Y;
                sledgeHammerOrigin.CalculateCorners();
                sledgeHammer.CalculateCorners();
            }

            if (!sledgeHammerInUse &&
                Keyboard.GetState().IsKeyDown(Keys.Space) &&
                isaac.hasPowerUp(PowerUpType.SledgeHammer) &&
                isaac.getActivePowerUp(PowerUpType.SledgeHammer).Charges > 0 &&
                (DateTime.Now - timeOfLastDeath).TotalSeconds > .5)
            {
                PowerUp p = isaac.getActivePowerUp(PowerUpType.SledgeHammer);
                p.ActiveTimer.Restart();
                soundEffectManager.Play(useHammer, .5f);

                sledgeHammerOrigin.Rotation = 0f;
                sledgeHammer.Rotation       = 0f;
                sledgeHammerOrigin.X        = (int)isaac.CenterPoint.X - sledgeHammer.Width;
                sledgeHammerOrigin.Y        = (int)isaac.CenterPoint.Y - sledgeHammer.Height;
                sledgeHammer.X    = (int)sledgeHammerOrigin.UpperRightCorner.X + sledgeHammer.Width / 2;
                sledgeHammer.Y    = (int)sledgeHammerOrigin.UpperRightCorner.Y;
                sledgeHammerInUse = true;
            }
        }