Example #1
0
		public void plantBomb( Character character ) {

			Bomb bomb = new Bomb( this );
			bomb.CreateBomb( character.PlayerPosition );
			character.CurrentBombs++;
		}
Example #2
0
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            sb.Begin();
            #region Frames Per Second Stuff
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            frameCount++;
            timeSinceLastUpdate += elapsed;
            if (timeSinceLastUpdate > updateInterval)
            {
                fps                  = frameCount / timeSinceLastUpdate;
                frameCount           = 0;
                timeSinceLastUpdate -= updateInterval;
            }
            string FPS = String.Empty;
            FPS += "FPS: " + fps.ToString();
            //FPS += " - RT: " + gameTime.ElapsedRealTime.TotalSeconds.ToString();
            //FPS += " - GT: " + gameTime.ElapsedGameTime.ToString();
            sb.DrawString(font, FPS, new Vector2(60, 70), Color.Black);
            #endregion


            // Begin Debug Info
            sb.DrawString(font, "Player X: " + player.playerPosition.X.ToString(), new Vector2(60, 30), Color.Black);
            sb.DrawString(font, "Player Y: " + player.playerPosition.Y.ToString(), new Vector2(60, 50), Color.Black);
            sb.DrawString(font, "Bombs: " + player.CurrentBombs.ToString(), new Vector2(60, 90), Color.Black);
            sb.DrawString(font, "Player Collision: " + collision.ToString(), new Vector2(60, 110), Color.Black);
            // End Debug Info

            if (collision != true && player.IsDead != true)
            {
                switch (player.currentDirection)
                {
                case MoveDirection.Up:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Up, gameTime, 0.5f);
                    break;

                case MoveDirection.Right:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Right, gameTime, 0.5f);
                    break;

                case MoveDirection.Down:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Down, gameTime, 0.5f);
                    break;

                case MoveDirection.Left:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Left, gameTime, 0.5f);
                    break;

                default:
                    Animation.DrawAnimation(sb, playerSprite, player, player.Idle, gameTime, 0.5f);
                    break;
                }
                // Draw Bombs
                for (int i = 0; i < bombs.Count; i++)
                {
                    Bomb bomb = (Bomb)bombs[i];
                    if (bomb.Detonate == false)
                    {
                        Animation.DrawAnimation(sb, bombsTexture, bomb.TimerAnimation, gameTime, bomb.Position, true, 0.5f);
                    }
                    else
                    {
                        bombs.RemoveAt(i);
                    }
                }
                for (int j = 0; j < explosions.Count; j++)
                {
                    Explosion exp = (Explosion)explosions[j];
                    if (exp.Elapsed < exp.ExplosionTime)
                    {
                        Animation.DrawAnimation(sb, bombsTexture, exp.FlameMiddle, gameTime, exp.Position, false, 0.1f);
                        Animation.DrawAnimation(sb, bombsTexture, exp.FlameLeft, gameTime, exp.positionLeft, false, 0.1f);
                        Animation.DrawAnimation(sb, bombsTexture, exp.FlameRight, gameTime, exp.positionRight, false, 0.1f);
                    }
                    else
                    {
                        explosions.RemoveAt(j);
                    }
                }
            }
            else
            {
                player.IsDead = true;
                sb.DrawString(font, "PWNED", new Vector2(380, 200), Color.Red);
            }

            sb.End();
            base.Draw(gameTime);
        }