| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 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<Model>(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();
- }
- }
- }
- }
|