private void updateCols() { Color color; int scoreWorth; Rectangle sourceRectangle; float top = k_EnemiesStartingY; for (int row = 0; row < k_MatrixRows; row++) { float left = k_EnemiesStartingX; bool isStartAnimationFromSecondCell = row % 2 == 0; initPropertiesForEnemy(out sourceRectangle, out color, out scoreWorth, row); for (int col = 0; col < k_MatrixCols; col++) { AlienMatrixEnemy enemy = new AlienMatrixEnemy(sourceRectangle, scoreWorth, color, r_GameScreen); r_EnemyMatrix[row].Add(enemy); setVisibility(enemy, row, col); initEnemy( enemy, left, top, new CellAnimator(isStartAnimationFromSecondCell, TimeSpan.FromSeconds(k_CellTime), k_NumOfAnimationCells, TimeSpan.Zero)); this.Add(enemy); left += enemy.Width + k_SpaceBetweenEnemies; r_SoundManager.AddSoundEmitter(enemy); } top += k_EnemyHeight + k_SpaceBetweenEnemies; } }
private void initEnemy(AlienMatrixEnemy i_Enemy, float i_PositionX, float i_PositionY, CellAnimator i_CellAnimator = null) { i_Enemy.MaxShotsInMidAir = MaxShotsInMidAir; i_Enemy.CellAnimation = i_CellAnimator; i_Enemy.StartPosition = new Vector2(i_PositionX, i_PositionY); i_Enemy.StartVelocity = new Vector2(k_AlienEnemyVelocity, 0); i_Enemy.VisibleChanged += enemy_VisibleChanged; i_Enemy.GroupRepresentative = this; }