public override void DropBomb() { //get the total time passed //get a random existing column; //needs to create a new random every time to //keep up with current number of columns; Random r = new Random(); int randomColumnIndex = r.Next(0, this.numColumns); ////check that the child exists - can't drop a bomb if no columns/aliens! //Debug.Assert(randomChildColumn != null); ////cast to an alien object; //AlienType randomColumn = (AlienType)randomChildColumn; //todo Clean this up - remove if-else special case for first column bomb drop - without this first column never drops a bomb if (randomColumnIndex != 0) { AlienType randomColumn = privGetRandomColumn(randomColumnIndex); Debug.Assert(randomColumn != null); //drop the bomb from the appropriate spot; //call passed through this->column->alien randomColumn.DropBomb(); } else { GameObject firstColumnObj = (GameObject)this.pChild; AlienType firstColumn = (AlienType)firstColumnObj; Debug.Assert(firstColumn != null); firstColumn.DropBomb(); } }
//called from column ( (GameObject)this.pParent ); //passed to lowest alien ( (GameObject)this.pChild ); public override void DropBomb() { //get the lowest alien - in PCS tree structure that's the child of this column; GameObject childAlien = (GameObject)this.pChild; //cast to an alien object; AlienType lowAlien = (AlienType)childAlien; //drop the bomb from the appropriate spot; lowAlien.DropBomb(); }
private void privTestAlienColumnBombDrop() { //TEST - drop bomb on trigger; //get the grid as a game object GameObject gridGameObj = GameObjectManager.Find(GameObject.Name.Grid); //cast to an alien to drop the bomb AlienType alienGrid = (AlienType)gridGameObj; //drop the bomb - function cascades to first child of first column alienGrid.DropBomb(); }