public override bool PerformFrame(BCBlockGameState gamestate) { BCBlockGameState.IncrementLocation(gamestate, ref _Location, Velocity); framecounter++; if (framecounter >= NextDeployment) { framecounter = 0; NextDeployment = BCBlockGameState.rgen.Next(10, 30); ExplosionEffect ee = new ExplosionEffect(Location, 10 + (float)(BCBlockGameState.rgen.NextDouble() * 20)); ee.DamageBlocks = false; //doesn't hurt blocks... ee.ShowOrbs = false; gamestate.Defer(() => { gamestate.GameObjects.AddLast(ee); BCBlockGameState.Soundman.PlaySound("explode"); }); } return !gamestate.GameArea.Contains(new Point((int)Location.X, (int)Location.Y)); }
public override bool PerformFrame(BCBlockGameState gamestate) { //What happens here? //not a whole lot, actually. //all we really need to check for is whether the two aggregates are "touching". If they are, create a explosion in that spot and remove them. if (Aggregates[0].ObjectRectangle.IntersectsWith(Aggregates[1].ObjectRectangle)) { float explosionsize = (BCBlockGameState.Distance(PointF.Empty, Aggregates[0].Velocity) + BCBlockGameState.Distance(PointF.Empty, Aggregates[1].Velocity)) / 2; //intersection. //get the midpoint between the two centers... PointF explosionzero = BCBlockGameState.MidPoint(Aggregates[0].ObjectRectangle.CenterPoint(), Aggregates[1].ObjectRectangle.CenterPoint()); BCBlockGameState.Soundman.PlaySound("bomb"); ExplosionEffect explode = new ExplosionEffect(explosionzero, explosionsize); //add it... gamestate.Defer(()=> { gamestate.GameObjects.AddLast(explode); gamestate.GameObjects.Remove(Aggregates[0]); gamestate.GameObjects.Remove(Aggregates[1]); gamestate.GameObjects.Remove(this); }); } return base.PerformFrame(gamestate); }
public override bool HitBlock(BCBlockGameState currentstate, cBall ballobject, Block blockhit) { //increment NumExplosions: _TimesExploded++; float useradius = GetExplosionRadius(); ExplosionEffect ee = new ExplosionEffect(ballobject.Location, useradius); currentstate.GameObjects.AddLast(ee); //if we reached the max, replace this behaviour with a temporary ball behaviour. if (_TimesExploded == MaxRadius) { //in order to remove a behaviour from the ball here, we need to set a proxy object... RemoveFromBall=ballobject; ProxyObject po = new ProxyObject(PerformFrameProxyRemove, null); //add it... currentstate.GameObjects.AddLast(po); } //if we also havea linear gravity behaviour and are going down, make us go up... if (ballobject.Behaviours.Any((w) => w.GetType() == typeof(LinearGravityBallBehaviour))) { ballobject.Velocity = new PointF(ballobject.Velocity.X,-Math.Abs(ballobject.Velocity.Y)); } return base.HitBlock(currentstate, ballobject, blockhit); }