private void AIAttackDelay(object sender, EventArgs e) { string fileName = STRINGNULL; int shipSize = 0; int aiTarget = makeGame.aiAttack(); foreach (PictureBox pb in playerSHPPanel.Controls) { Globals.SHPBox = breakUpName(pb.Tag.ToString()); Globals.SHPType = breakUpName(pb.Name); if (Convert.ToInt32(Globals.SHPBox[1]) == aiTarget) { Globals.makeHit = (Globals.SHPType[0] != SHPBX.ToString()) ? true : false; fireSound(); if (Convert.ToChar(Globals.SHPType[0]) != SHPBX) { shipSize = (getShipSize(Convert.ToChar(Globals.SHPType[0])) * 2); fileName = (FILENAME[0] + Globals.SHPType[0] + FILENAME[3] + ((((Convert.ToInt32(Globals.SHPType[1]) + shipSize)) < 10) ? FILENAME[2] : FILENAME[4]) + ((Convert.ToInt32(Globals.SHPType[1]) + shipSize).ToString()) + FILENAME[5]); playerActionLabel.Text = Globals.stringTheme[4] + ((Convert.ToChar(Globals.SHPType[0]) == AIRCRAFTCARRIER) ? Globals.stringTheme[5] : (Convert.ToChar(Globals.SHPType[0]) == BATTLESHIP) ? Globals.stringTheme[6] : (Convert.ToChar(Globals.SHPType[0]) == DESTROYER) ? Globals.stringTheme[7] : (Convert.ToChar(Globals.SHPType[0]) == SUBMARINE) ? Globals.stringTheme[8] : Globals.stringTheme[9]); } else { fileName = MISS; //tells user the ai hit nothing playerActionLabel.Text = Globals.stringTheme[10]; } try { pb.Image = Image.FromFile(Globals.imgPath + fileName); pb.Name = (Globals.SHPType[0] + (Convert.ToInt32(Globals.SHPType[1]) + shipSize).ToString()); } catch { //do nothing *meaning not let game crash :P } } } //this checks to see if the AI wins if (makeGame.hasWon() == AI) { playSound(Globals.soundPath + GAMEOVER); //this tell player if they lost. playerActionLabel.Text = Globals.stringTheme[19]; //destroy all ATKPanel Picktureboxs destroy_Grid(); //show failed image playerATKPanel.BackgroundImage = Image.FromFile(Globals.imgPath + FAILED); } //stops ai aiTimer.Stop(); }