private void CPUMove() { Point p = BoatFinder.GetPoint(); Button tempButton = PlayerButtons[p.X, p.Y]; Cell c = (Cell)tempButton.Tag; if (c.BoatType != Boat.None) { CPUStatus.Content = "CPU Hit!"; tempButton.Background = Brushes.Red; BoatFinder.BoatFound(p, c); c.BoatState = State.Sunk; if (CheckSunk(PlayerButtons, tempButton)) { //MessageBox.Show("You lost your: " + c.BoatType.ToString()); CPUStatus.Content = "You lost your " + EnumHelper.ToString(c.BoatType); BoatFinder.BoatSunk(c); PlayerBoatsSunk++; if (CheckWins(Player.CPU)) { //MessageBox.Show("The compuuter won!"); CPUStatus.Content = "You lost"; GameOver(Player.CPU); } } } else { CPUStatus.Content = "CPU Missed!"; tempButton.Background = Brushes.Blue; BoatFinder.BoatNotFound(c); } }
public static void BoatSunk(Cell cellSunk) { BoatFinder bf = locatedBoats.Where(x => x.cellPoint.BoatType == cellSunk.BoatType).First(); bf.PointsSunk(); locatedBoats.Remove(bf); boatsSunk.Add(cellSunk.BoatType); }