public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { if (m_animationSpriteDrawer == null) { m_animationSpriteDrawer = new AnimationSpriteDrawer(Game.Content.Load <Texture2D>("Animations/health_recovery"), new Size(400, 400), TimeSpan.FromMilliseconds(50), true, true); } var origin = new Vector2((float)m_animationSpriteDrawer.FrameSize.Width / 2.0f, (float)m_animationSpriteDrawer.FrameSize.Height / 2.0f); var scaleVector = CoordinatesTransformer.CreateScaleVector( StaticObject.AbsoluteGeometry.BoundingRectangle.Size, new Size(m_animationSpriteDrawer.FrameSize.Width, m_animationSpriteDrawer.FrameSize.Height)); m_animationSpriteDrawer.Draw(gameTime, spriteBatch, CoordinatesTransformer.Transform(StaticObject.AbsoluteGeometry.Center), Color.Red, 0f, origin, scaleVector, SpriteEffects.None, LayersDepths.StaticObject); // do every 4 draw if (m_drawCount++ % 8 == 0) { foreach (var affectedObject in StaticObject.AffectedGameObjects) { double crossSize = StaticObject.RecoverySpeed / 4; m_particlesEmitter.Emit(new Particle(Game, CoordinatesTransformer, ParticleType.Cross) { Position = affectedObject.Position, Color = Color.Red, Size = new Size(crossSize, crossSize), Alpha = 0.8f, AlphaVelocity = -0.5f }, 1); } } }
public void WhenApplied(NRPlanes.Core.Common.Plane plane) { // temporary single reaction //if (Bonus is HealthBonus) { BasicSoundEffect effect = Game.GameManager.GameWorldXna.SoundManager.CreateBasicSoundEffect("health_bonus", true); effect.Position = plane.Position; effect.Play(); m_emitter.Emit(new Particle(Game, CoordinatesTransformer, ParticleType.Cross) { Color = Color.Red, Position = Bonus.Position, Size = new Size(2, 2), AlphaVelocity = -0.3f, TimeToLive = TimeSpan.FromSeconds(5), Depth = LayersDepths.BonusesParticles, }, (int)(Math.Max(1, Bonus.RelativeGeometry.BoundingRectangle.Area * PARTICLES_DENSITY))); } }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { if (m_texture == null) { m_texture = Game.Content.Load <Texture2D>("Images/weapon"); } if (m_lastShotDateTime != Equipment.LastShotDateTime) { m_lastShotDateTime = Equipment.LastShotDateTime; m_particlesEmitter.Emit(new Particle(Game, CoordinatesTransformer) { Color = Color.White, Position = Equipment.GetAbsolutePosition(), Size = new Size(1, 1), AlphaVelocity = -3.0f, TimeToLive = TimeSpan.FromSeconds(2), Velocity = Equipment.RelatedGameObject.Velocity + new Vector(0, 10).Rotate(Equipment.GetAbsoluteRotation()), SizeFactorVelocity = new Vector(6, 6) }, 3); } var origin = new Vector2(m_texture.Width / 2.0f, m_texture.Height / 2.0f); var scaleVector = CoordinatesTransformer.CreateScaleVector(Equipment.Size, new Size(m_texture.Width, m_texture.Height)); spriteBatch.Draw(m_texture, CoordinatesTransformer.Transform(Equipment.GetAbsolutePosition()), null, Color.White, MathHelper.ToRadians((float)Equipment.GetAbsoluteRotation()), origin, scaleVector, SpriteEffects.None, LayersDepths.Weapon); }