private void attackTimer_Tick(object sender, EventArgs e) { for (int i = 0; i < ALL_ALIENS; i++) { //if alien is alive and in attack if (aliens[i].getState() && aliens[i].inAttack()) { if (attackSteps <= 6) { if (attackSteps == 1) { if (attackDir == dir.RIGHT) { //go 20px up and to the right aliens[i].setX(aliens[i].getX() + 20); aliens[i].setY(aliens[i].getY() - 20); } else { //go 20px up and to the left aliens[i].setX(aliens[i].getX() - 20); aliens[i].setY(aliens[i].getY() - 20); } } else if (attackSteps == 2) { if (attackDir == dir.RIGHT) { //continue 20px right aliens[i].setX(aliens[i].getX() + 20); } else { //continue 20px left aliens[i].setX(aliens[i].getX() - 20); } } else if (attackSteps == 3 || attackSteps == 4) { if (attackDir == dir.RIGHT) { //go 20px down and to the right aliens[i].setX(aliens[i].getX() + 20); aliens[i].setY(aliens[i].getY() + 20); } else { //go 20px down and to the left aliens[i].setX(aliens[i].getX() - 20); aliens[i].setY(aliens[i].getY() + 20); } } else if (attackSteps == 5 || attackSteps == 6) { //continue 20px down aliens[i].setY(aliens[i].getY() + 20); } } else { //slow down the attack attackTimer.Stop(); attackTimer.Interval = 300; attackTimer.Start(); if (attackDir == dir.RIGHT) { //go 20px down and to the left aliens[i].setX(aliens[i].getX() - 20); aliens[i].setY(aliens[i].getY() + 20); } else { //go 20px down and to the right aliens[i].setX(aliens[i].getX() + 20); aliens[i].setY(aliens[i].getY() + 20); } //if alien is close enough and still has shots if (alienShots <= 3 && attackSteps >= 9) { missiles[missileCount] = new Missile(); missiles[missileCount].setX(aliens[i].getX() + 7); missiles[missileCount].setY(aliens[i].getY() + 5); missiles[missileCount].setType(1); missiles[missileCount].setImage(Properties.Resources.missile); missileCount++; alienShots++; if (missileTimer.Enabled == false) { missileTimer.Start(); } } } break; } } attackSteps++; parent.Invalidate(); checkAttackState(); }