/// <summary>Processes the specified entity.</summary> /// <param name="entity">The entity.</param> public override void Process(Entity entity, SpatialFormComponent spatialFormComponent, TransformComponent transformComponent) { if (spatialFormComponent != null) { this.spatialName = spatialFormComponent.SpatialFormFile; if (transformComponent.X >= 0 && transformComponent.Y >= 0 && transformComponent.X < this.spriteBatch.GraphicsDevice.Viewport.Width && transformComponent.Y < this.spriteBatch.GraphicsDevice.Viewport.Height) { ///very naive render ... if (string.Compare("PlayerShip", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { PlayerShip.Render(this.spriteBatch, this.contentManager, transformComponent); } else if (string.Compare("Missile", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Missile.Render(this.spriteBatch, this.contentManager, transformComponent); } else if (string.Compare("EnemyShip", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { EnemyShip.Render(this.spriteBatch, this.contentManager, transformComponent); } else if (string.Compare("BulletExplosion", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Explosion.Render(this.spriteBatch, this.contentManager, transformComponent, Color.Red, 10); } else if (string.Compare("ShipExplosion", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { ShipExplosion.Render(this.spriteBatch, this.contentManager, transformComponent, Color.Yellow, 30); } } } }
public override void Draw(GameTime gameTime) { foreach (var entityId in ActiveEntities) { var entity = GetEntity(entityId); var spatial = entity.Get <SpatialFormComponent>(); var transform = entity.Get <Transform2>(); var spatialName = spatial.SpatialFormFile; var worldPosition = transform.WorldPosition; if (!(worldPosition.X >= 0) || !(worldPosition.Y >= 0) || !(worldPosition.X < _spriteBatch.GraphicsDevice.Viewport.Width) || !(worldPosition.Y < _spriteBatch.GraphicsDevice.Viewport.Height)) { return; } // very naive render ... if (string.Compare("PlayerShip", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { PlayerShip.Render(_spriteBatch, _contentManager, transform); } else if (string.Compare("Missile", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Missile.Render(_spriteBatch, _contentManager, transform); } else if (string.Compare("EnemyShip", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { EnemyShip.Render(_spriteBatch, _contentManager, transform); } else if (string.Compare("BulletExplosion", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Explosion.Render(_spriteBatch, _contentManager, transform, Color.Red, 10); } else if (string.Compare("ShipExplosion", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { ShipExplosion.Render(_spriteBatch, _contentManager, transform, Color.Yellow, 30); } } }
private void CreateSpatial(Entity e) { if (String.Compare("PlayerShip", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { PlayerShip.Render(spriteBatch, contentManager, transform); } else if (String.Compare("Missile", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Missile.Render(spriteBatch, contentManager, transform); } else if (String.Compare("EnemyShip", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { EnemyShip.Render(spriteBatch, contentManager, transform); } else if (String.Compare("BulletExplosion", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Explosion.Render(spriteBatch, contentManager, transform, Color.Red, 10); } else if (String.Compare("ShipExplosion", spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { ShipExplosion.Render(spriteBatch, contentManager, transform, Color.Yellow, 30); } }