Esempio n. 1
0
        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++;
                }
            }
        }
Esempio n. 2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            GraphicsDevice.Clear(Color.Gray);

            // powerups
            foreach (PowerUp p in PowerUp.AlivePowerUps)
            {
                spriteBatch.Draw(p.Texture, p, Color.White);
            }

            // powerup time bars
            foreach (PowerUp p in PowerUp.AlivePowerUps)
            {
                spriteBatch.Draw(powerUpBarTexture, new Rectangle(p.X, p.Y + p.Height - p.Height / 15, (int)(p.Width * p.RemainingTimeAlive / p.AliveDuration), p.Height / 15), Color.White);
            }

            // bill
            spriteBatch.Draw(bill.Texture, bill, Color.White);

            // bill's health bar
            Color billHpColor = bill.HP <= (bill.MaxHP * .75) ? (bill.HP <= (bill.MaxHP * .25) ? Color.Red : Color.Yellow) : Color.Green;

            spriteBatch.Draw(HealthBar.Texture, new Rectangle(bill.X, bill.Y, billHealthBar.Width, billHealthBar.Height), new Rectangle(0, 45, billHealthBar.Width, 44), Color.Gray);
            spriteBatch.Draw(HealthBar.Texture, new Rectangle(bill.X, bill.Y, (billHealthBar.Width * bill.HP / bill.MaxHP), billHealthBar.Height), new Rectangle(0, 45, billHealthBar.Width, 44), billHpColor);
            spriteBatch.Draw(HealthBar.Texture, new Rectangle(bill.X, bill.Y, billHealthBar.Width, billHealthBar.Height), new Rectangle(0, 0, HealthBar.Texture.Width, 44), Color.White);

            // isaac
            if (sledgeHammerInUse)
            {
                spriteBatch.Draw(isaacUsingHammerTexture, isaac, Color.White);
            }
            else
            {
                spriteBatch.Draw(isaac.Texture, isaac, Color.White);
            }

            // draw shield if active
            if (isaac.hasPowerUp(PowerUpType.CanShield))
            {
                spriteBatch.Draw(shieldTexture, isaac, Color.White);
            }

            // projectiles
            foreach (Bullet b in Bullet.Peanuts)
            {
                spriteBatch.Draw(b.Texture, new Rectangle((int)b.CenterPoint.X, (int)b.CenterPoint.Y, b.Width, b.Height), null, Color.White, b.Rotation, b.TextureCenterOrigin, SpriteEffects.None, 0f);
            }
            foreach (Bullet b in Bullet.Cans)
            {
                spriteBatch.Draw(b.Texture, new Rectangle((int)b.CenterPoint.X, (int)b.CenterPoint.Y, b.Width, b.Height), null, Color.White, b.Rotation, b.TextureCenterOrigin, SpriteEffects.None, 0f);
            }

            // sledgehammer
            if (sledgeHammerInUse)
            {
                //spriteBatch.Draw(isaac.Texture, new Rectangle((int)sledgeHammer.UpperLeftCorner().X, (int)sledgeHammer.UpperLeftCorner().Y, 5, 5), Color.White);
                //spriteBatch.Draw(isaac.Texture, new Rectangle((int)sledgeHammer.UpperRightCorner().X, (int)sledgeHammer.UpperRightCorner().Y, 5, 5), Color.White);
                //spriteBatch.Draw(isaac.Texture, new Rectangle((int)sledgeHammer.LowerLeftCorner().X, (int)sledgeHammer.LowerLeftCorner().Y, 5, 5), Color.White);
                //spriteBatch.Draw(isaac.Texture, new Rectangle((int)sledgeHammer.LowerRightCorner().X, (int)sledgeHammer.LowerRightCorner().Y, 5, 5), Color.White);
                spriteBatch.Draw(sledgeHammer.Texture, new Rectangle((int)isaac.CenterPoint.X, (int)isaac.CenterPoint.Y, sledgeHammer.Width, sledgeHammer.Height), null, Color.White, sledgeHammer.Rotation, new Vector2(sledgeHammer.Texture.Width / 2, sledgeHammer.Texture.Height), SpriteEffects.None, 0f);
            }

            // bill messages
            if (billIsAngry)
            {
                spriteBatch.DrawString(font1, currentBillMessage, new Vector2(bill.X + bill.Width / 2 - font1.MeasureString(currentBillMessage).X / 2, bill.Y + bill.Height), Color.White);
            }

            // active powerup info
            int offset = 1;

            foreach (PowerUp p in isaac.ActivePowerUps)
            {
                string msg = p.ToString();
                spriteBatch.DrawString(powerUpFont, msg, new Vector2(1, offset), Color.White);
                offset += (int)powerUpFont.MeasureString(msg).Y;
            }

            // bill status
            offset = 1;
            Vector2 billHPStringSize = billStatusFont.MeasureString(billHPString);
            int     posX             = Graphics.GraphicsDevice.Viewport.Width - (int)billHPStringSize.X - 3;

            spriteBatch.DrawString(billStatusFont, billHPString, new Vector2(posX, offset), Color.Black);
            offset += (int)billHPStringSize.Y;
            posX    = Graphics.GraphicsDevice.Viewport.Width - (int)billStatusFont.MeasureString(billStatusString).X - 3;
            spriteBatch.DrawString(billStatusFont, billStatusString, new Vector2(posX, offset), Color.Black);

            //pause and fps count
            Vector2 pauseStringSize = billStatusFont.MeasureString("PAUSED");

            if (paused)
            {
                spriteBatch.DrawString(billStatusFont, "PAUSED", new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2 - pauseStringSize.X / 2, Graphics.GraphicsDevice.Viewport.Height / 2 - pauseStringSize.Y / 2), Color.White);
            }
            else
            {
                frameCounter++;
            }

            /*foreach (Vector2 v in isaacSpawnPoints)
             * {
             *  spriteBatch.Draw(isaac.Texture, new Rectangle((int)v.X, (int)v.Y, 2, 2), Color.White);
             */
        }