private void DisposeExplosion(ExplodingBean explosion) { if (_selectedBean != null && _selectedBean.Bean == explosion.Bean) { //TODO: Remove any other selection visuals (leave the popup though) if (_selectedBean.Viewer != null) { //TODO: This will get very annoying _selectedBean.Viewer.Close(); } _selectedBean = null; } _explosions.Remove(explosion); explosion.Dispose(); //_winnerManager.ShipDied(explosion.Bean); // this was done when creating the explosion _map.RemoveItem(explosion.Bean, true); //_beans.Remove(explosion.Bean); // this was done when creating the explosion explosion.Bean.Dispose(); }
private ExplodingBean ExplodeBean(Bean bean, bool isExplode, double sizeMultiplier, double forceMultiplier) { double explodeStartRadius = 1d; // Don't remove visuals. Wait until the explosion is complete // Turn it into a ghost bean.PhysicsBody.ApplyForceAndTorque -= new EventHandler<BodyApplyForceAndTorqueArgs>(Bean_ApplyForceAndTorque); bean.PhysicsBody.MaterialGroupID = _material_ExplodingBean; // the body now won't collide with anything double mass = bean.PhysicsBody.Mass; // Create the explosion ExplodingBean retVal = null; if (isExplode) { // Explode retVal = new ExplodingBean(bean, mass * sizeMultiplier * 60d, mass * forceMultiplier * 4000d, mass * sizeMultiplier * 16d, _viewport, explodeStartRadius); } else { // Implode retVal = new ExplodingBean(bean, mass * sizeMultiplier * 60d, mass * forceMultiplier * -3d, mass * sizeMultiplier * 16d, _viewport, explodeStartRadius); } _explosions.Add(retVal); // Exit Function return retVal; }