public BombBlock(SerializationInfo info, StreamingContext context) : base(info, context) { BlockImageKey = "BOMB"; mShotDirections = (BombBlockShotDirections)(info.GetValue("ShotDirection", typeof(BombBlockShotDirections))); }
public BombBlock(XElement Source,Object pPersistenceData) : base(Source, pPersistenceData) { mShotDirections = (BombBlockShotDirections)Source.GetAttributeInt("ShotDirection"); BlockImageKey = "BOMB"; }
//accepts a BombBlockShotDirections enumeration, and returns a list of the appropriate //set of balls that would be "exploded" from the bomb block when hit by impactball. private List<cBall> GetBallsForDirections(BombBlockShotDirections bbdirection, cBall impactBall) { PointF usepoint = new PointF(BlockRectangle.Left + BlockRectangle.Width / 2, BlockRectangle.Top + BlockRectangle.Height / 2); cBall ballhit = impactBall; cBall LeftShoot = new cBall(usepoint, new PointF(-ballhit.getMagnitude(), 0)) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; cBall RightShoot = new cBall(usepoint, new PointF(ballhit.getMagnitude(), 0)) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; cBall TopShoot = new cBall(usepoint, new PointF(0, -ballhit.getMagnitude())) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; cBall BottomShoot = new cBall(usepoint, new PointF(0, ballhit.getMagnitude())) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; float usevel = (float)Math.Sqrt(Math.Pow(ballhit.getMagnitude(), 2) * 2); cBall UpLeftShoot = new cBall(usepoint, new PointF(-usevel, -usevel)) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; cBall UpRightShoot = new cBall(usepoint, new PointF(usevel, -usevel)) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; cBall DownLeftShoot = new cBall(usepoint, new PointF(-usevel, usevel)) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; cBall DownRightShoot = new cBall(usepoint, new PointF(usevel, usevel)) { Radius = 3, isTempBall = true, DrawColor = Color.Gray }; List<cBall> returnballs = new List<cBall>(); List<cBall> ballsadded = new List<cBall>(); ballsadded.AddRange(new cBall[] { LeftShoot, RightShoot, TopShoot, BottomShoot, UpLeftShoot, UpRightShoot, DownLeftShoot, DownRightShoot }); for (int i = 0; i < ballsadded.Count; i++) { BombBlockShotDirections checkit = ((BombBlockShotDirections)(Math.Pow(2, i + 1))); if (((bbdirection & ((BombBlockShotDirections)checkit)) == checkit)) returnballs.Add(ballsadded[i]); } return returnballs; }