public void AddAsteroid(Vector3 position, asteroidInfo asteroidType) { Hulk item = new Hulk(); item.modelMesh = asteroidType.model; item.Position = position; item.Rotation = Quaternion.CreateFromYawPitchRoll( Helpers.randFloat(-3, 3), Helpers.randFloat(-3, 3), Helpers.randFloat(-3, 3)); item.permanent = true; item.BSphere = new BoundingSphere(item.Position, FrameworkCore.ModelArray[(int)item.modelMesh].Meshes[0].BoundingSphere.Radius); item.CollisionSpheres = new CollisionSphere[asteroidType.collisionSpheres.Length]; for (int i = 0; i < asteroidType.collisionSpheres.Length; i++) { item.CollisionSpheres[i] = new CollisionSphere(asteroidType.collisionSpheres[i].sphere, asteroidType.collisionSpheres[i].offset); } item.UpdateCollisionSpheres(); hulks.Add(item); }
public void Update(GameTime gameTime) { //check if we have any hulks in our list. if (hulks.Count <= 0) { return; } float dt = (float)gameTime.ElapsedGameTime.TotalSeconds; for (int i = 0; i < hulks.Count; i++) { if (!Helpers.IsHulk(hulks[i])) { continue; } Hulk item = (Hulk)hulks[i]; //update position. item.Position += (item.speed * item.moveDir) * dt; if (item.angularVelocity != Vector3.Zero) { float time = item.lifeTime; item.Rotation = Quaternion.CreateFromYawPitchRoll( item.angularVelocity.X * time, item.angularVelocity.Y * time, item.angularVelocity.Z * time); } if (item.speed > 0) { if (item.debrisTimer <= 0) { item.debrisTimer = FrameworkCore.r.Next(200, 500); FrameworkCore.debrisManager.AddHulkTrail(item.Position, item.moveDir); } else { item.debrisTimer -= (int)gameTime.ElapsedGameTime.TotalMilliseconds; } } item.UpdateCollisionSpheres(); if (item.emitter != null) { item.emitter.Update(gameTime, item.Position); } //update lifetime. Remove from list if it expires. if (!item.permanent) { item.lifeTime -= (int)gameTime.ElapsedGameTime.TotalMilliseconds; if (item.lifeTime <= 0) { KillHulk(item); //hulks.Remove(item); //FrameworkCore.playbackSystem.KillItem(item); } } } }