/// <summary> /// Constructs an explosion. /// </summary> /// <param name="pos">Initial position of the explosion.</param> /// <param name="explosionMagnitude">Base strength of the blast as applied in units of impulse.</param> /// <param name="maxDist">Maximum radius of effect.</param> /// <param name="containingSpace">Space in which the explosion resides.</param> public Explosion(Entity entity, float explosionMagnitude, float maxDist, Space containingSpace, Game game) : base(game) { this.entity = entity; Position = entity.WorldTransform.Translation; Magnitude = explosionMagnitude; MaxDistance = maxDist; Space = containingSpace; explosionParticles = Game.Services.GetService(typeof(ExplosionParticleSystem)) as ExplosionParticleSystem; explosionSmokeParticles = Game.Services.GetService(typeof(ExplosionSmokeParticleSystem)) as ExplosionSmokeParticleSystem; }
public TerrainUnit(Game game, ContentManager content, GraphicsDeviceManager graphics) : base(game) { GravityVelocity = 0.0f; IsOnTerrain = false; IsDead = false; needUpdateCollision = true; boost = false; tank = new Tank(game, content, graphics); part1 = new DustParticleSystem(game, content); part1.Initialize(); game.Components.Add(part1); emiter = new ParticleEmitter(part1, 60, tank.Position); part1.DrawOrder = 400; }
/// <summary> /// Constructs a new projectile. /// </summary> public Projectile(ParticleSystem explosionParticles, ParticleSystem explosionSmokeParticles, ParticleSystem projectileTrailParticles, Vector3 position, Vector3 direction) { this.explosionParticles = explosionParticles; this.explosionSmokeParticles = explosionSmokeParticles; // Start at the origin, firing in a random (but roughly upward) direction. this.position = position; //velocity.X = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange; //velocity.Y = (float)(random.NextDouble() + 0.5) * verticalVelocityRange; //velocity.Z = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange; velocity = direction; // Use the particle emitter helper to output our trail particles. trailEmitter = new ParticleEmitter(projectileTrailParticles, trailParticlesPerSecond, position); }
public TanksOnAHeightmapGame() { graphics = new GraphicsDeviceManager(this); device = GraphicsDevice; Content.RootDirectory = "Content"; music = Content.Load<Song>("Sound/windbell"); // Light Manager lightManager = new LightManager(); lightManager.AmbientLightColor = new Vector3(0.2f, 0.2f, 0.2f); Services.AddService(typeof(LightManager), lightManager); // Light 1 lightManager.Add("Light1", new PointLight(new Vector3(0, 1000.0f, 0), Vector3.One)); //tank = new Tank(this, Content, graphics); terrain = new TanksOnAHeightmap.GameBase.Shapes.Terrain(this, Content, graphics); //InputHelper inputHelper = new InputHelper(PlayerIndex.One); Services.AddService(typeof(InputHelper), inputHelper); // Create the chase camera camera = new ChaseCamera(this); // Set the camera offsets //camera.DesiredPositionOffset = new Vector3(0.0f, 600.0f, 800.0f);//150,150 //camera.LookAtOffset = new Vector3(0.0f, 80.0f, 0.0f);//80 camera.DesiredPositionOffset = new Vector3(0.0f, 45.0f, 20.0f);//150,150 camera.LookAtOffset = new Vector3(0.0f, 35.0f, -50.0f);//80 // Set camera perspective camera.NearPlaneDistance = 10.0f; camera.FarPlaneDistance = 4000.0f; this.Services.AddService(typeof(TanksOnAHeightmap.GameBase.Shapes.Terrain), terrain); this.Services.AddService(typeof(ChaseCamera), camera); rand = new Random(0); // Construct our particle system components. explosionParticles = new ExplosionParticleSystem(this, Content); ParticleSettings settings = new ParticleSettings(); this.Services.AddService(typeof(ExplosionParticleSystem), explosionParticles); explosionSmokeParticles = new ExplosionSmokeParticleSystem(this, Content); this.Services.AddService(typeof(ExplosionSmokeParticleSystem), explosionSmokeParticles); projectileTrailParticles = new ProjectileTrailParticleSystem(this, Content); //Trees trees = new Trees[NUMBER_OF_TREES]; for (int i = 0; i < trees.Length; i++) { trees[i] = new Trees(this, Content, graphics); //Components.Add(trees[i]); } explosionSmokeParticles.DrawOrder = 200; projectileTrailParticles.DrawOrder = 300; explosionParticles.DrawOrder = 400; terrain.DrawOrder = 102; //Trees this.graphics.PreferredBackBufferWidth = 1024; this.graphics.PreferredBackBufferHeight = 768; start(); }
public override void Initialize() { camera = Game.Services.GetService(typeof (ChaseCamera)) as ChaseCamera; terrain = Game.Services.GetService(typeof (Terrain)) as Terrain; explosionParticles = Game.Services.GetService(typeof (ExplosionParticleSystem)) as ExplosionParticleSystem; explosionSmokeParticles = Game.Services.GetService(typeof (ExplosionSmokeParticleSystem)) as ExplosionSmokeParticleSystem; base.Initialize(); }