using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace FuelCell { public class Barrier : GameObject { public string BarrierType { get; set; } public Barrier() : base() { BarrierType = null; } public void LoadContent(ContentManager content, string modelName) { Model = content.Load(modelName); BarrierType = modelName; BoundingSphere = CalculateBoundingSphere(); Position = Vector3.Down; BoundingSphere scaledSphere; scaledSphere = BoundingSphere; scaledSphere.Radius *= GameConstants.BarrierBoundingSphereFactor; BoundingSphere = new BoundingSphere(scaledSphere.Center, scaledSphere.Radius); } public void Draw(Matrix view, Matrix projection) { Matrix translateMatrix = Matrix.CreateTranslation(Position); Matrix worldMatrix = translateMatrix; foreach (ModelMesh mesh in Model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.World = worldMatrix; effect.View = view; effect.Projection = projection; effect.EnableDefaultLighting(); effect.PreferPerPixelLighting = true; } mesh.Draw(); } } } }