public override bool PerformFrame(BCBlockGameState gamestate) { bool returnvalue = base.PerformFrame(gamestate); switch (_ShotState) { case BuilderShotState.BSS_Projectile: List<Block> resulthittest = BCBlockGameState.Block_HitTest(gamestate.Blocks, getfullsize(), false); returnvalue = !returnvalue || resulthittest.Any(); if (returnvalue) { _ShotState = BuilderShotState.BSS_Expand; Velocity = new PointF(0, 0.01f); gamestate.Forcerefresh = true; } return false; case BuilderShotState.BSS_Expand: //if our size is the desired size of the block, create that block and return true. //otherwise, change out size and location to emulate "growing". if (this.ShotSize.Width >= BuildSize.Width && ShotSize.Height >= BuildSize.Height) { //grow phase completed. //create the block in the desired location. RectangleF desiredlocation = new RectangleF(Location.X, Location.Y, BuildSize.Width, BuildSize.Height); Block builtblock = (Block) Activator.CreateInstance(this.BuildBlock, desiredlocation); //add it to the game... gamestate.Blocks.AddLast(builtblock); //make sure to force a refresh, too. gamestate.Forcerefresh = true; gamestate.Defer( () => gamestate.GameObjects.AddLast(new ProxyObject(forcerefresher, null))); //return true to destroy outselves. //todo: maybe add "effects" here, too? return true; } else { //otherwise, we are in the growing phase. //growincrement could be null, if so, initialize it... if (Growincrement == null) { //initialize it to the difference between the final size and the current shot size, divided //by increments. Growincrement = new SizeF((BuildSize.Width - ShotSize.Width)/increments, (BuildSize.Height - ShotSize.Height)/increments); } //change size by growincrement. Location = new PointF(Location.X - Growincrement.Value.Width, Location.Y - Growincrement.Value.Height); ShotSize = new SizeF(ShotSize.Width + Growincrement.Value.Width*2, ShotSize.Height + Growincrement.Value.Height*2); } return false; } return false; }
public void ExpandPhase() { //enter expansion phase. _ShotState = BuilderShotState.BSS_Expand; _Velocity = new PointF(0, 0); //full stop, ensign. }