public void draw(GameTime gameTime) { //Clear the previous frame graphics.GraphicsDevice.Clear(Color.Black); particleEngine.Update(); spritebatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); //Particles spritebatch.Draw(background, new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height), Color.White); particleEngine.Draw(); menuManager.Draw(spritebatch); if (!baseModel.Tower.Dead) { if (simpleMid) { //middle Color c = Color.DeepPink; c.A = (byte)100; spritebatch.Draw(middle, new Rectangle((int)baseModel.Tower.Location.X, (int)baseModel.Tower.Location.Y, (int)baseModel.Tower.Shape.Width, (int)baseModel.Tower.Shape.Height), null, c, 0, new Vector2(middle.Width / 2, middle.Height / 2), SpriteEffects.None, 0); } else { int width = (int)baseModel.Tower.Shape.Width; int height = (int)baseModel.Tower.Shape.Height; frameId = (frameId + 0.2f) % 50; int healthId = 7 - (int)(((float)baseModel.Tower.Health / baseModel.Tower.MaxHealth) * 7); if (healthId > 6) { healthId = 6; } Color c = Color.White; c.A = 200; Texture2D t = frameId < 20 ? middle0 : (frameId < 40 ? middle1 : middle2); Rectangle frame = new Rectangle(width * (((int)frameId) % 20), height * healthId, width, height); spritebatch.Draw(t, new Rectangle((int)baseModel.Tower.Location.X, (int)baseModel.Tower.Location.Y, width, height), frame, c, 0, new Vector2(width / 2, height / 2), SpriteEffects.None, 0); } //Guns drawGuns(spritebatch); } //Living foreach (Enemy e in baseModel.Living) { Texture2D tex = (e is Invader) ? boss : enemy; Color col = Color.BlanchedAlmond; col.A = 200; if (e.Player != -1) { col = player_colors[e.Player]; col.A = 230; } Rectangle rect = new Rectangle((int)e.Location.X, (int)e.Location.Y, (int)e.Shape.Width, (int)e.Shape.Height); spritebatch.Draw(tex, rect, new Rectangle(0, 0, tex.Width, tex.Height), col, e.Orientation, new Vector2(tex.Width / 2, tex.Height / 2), SpriteEffects.None, 1); } //dying foreach (EnemyTimeWho et in baseModel.Dying) { Enemy e = et.enemy; Texture2D tex = (e is Invader) ? boss : enemy; Color col = Color.BlanchedAlmond; if (e.Player != -1) { col = player_colors[e.Player]; } col.A = 200; Rectangle rect = new Rectangle((int)e.Location.X, (int)e.Location.Y, (int)e.Shape.Width, (int)e.Shape.Height); spritebatch.Draw(tex, rect, new Rectangle(0, 0, tex.Width, tex.Height), col, e.Orientation, new Vector2(tex.Width / 2, tex.Height / 2), SpriteEffects.None, 1); } //bullets foreach (Bullet b in baseModel.Bullets) { Texture2D bullet = null; if ((b.Effects & Effects.Disc) != 0) { bullet = bulletDisc; } else if ((b.Effects & Effects.Wide) != 0) { bullet = bulletWide; } else { bullet = bulletNorm; } Rectangle rect = new Rectangle((int)b.Location.X, (int)b.Location.Y, (int)(2 * b.Shape.Width), (int)(2 * b.Shape.Height)); spritebatch.Draw(bullet, rect, new Rectangle(0, 0, bullet.Width, bullet.Height), player_colors[b.PlayerId], b.Orientation, new Vector2(bullet.Width / 2, bullet.Height / 2), SpriteEffects.None, 1); } spritebatch.End(); return; }
/// <summary> /// called every frame draw event /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { Engine.Draw(spriteBatch); base.Draw(gameTime); }
public void Draw_Timer(object sender, ElapsedEventArgs e) { GameEngine_.Draw(Buffer_, Count_); Buffer_.Render(); }