using System; using System.Diagnostics; namespace SpaceInvaders { public class FallZigzag : FallStrategy { //------------------------------------------------------------------- // FIELDS //------------------------------------------------------------------- private float oldY; //------------------------------------------------------------------- // CLASS METHODS //------------------------------------------------------------------- public FallZigzag() { this.oldY = 0.0f; } //------------------------------------------------------------------- // OVERRIDDEN METHODS //------------------------------------------------------------------- public override void Reset(float y) { this.oldY = y; } public override void Fall(Bomb pBomb) { Debug.Assert(pBomb != null); float targetY = oldY - 1.0f * pBomb.GetBoundingBoxHeight(); if(pBomb.y < oldY) { pBomb.MultiplyScale(-1.0f, 1.0f); oldY = targetY; } } } }