private void Next() { int index = Ships.FindIndex(x => x.Id == _currentShip.Id); if (index + 1 < Ships.Count) { CurrentShip = Ships[index + 1]; } else { CurrentShip = Ships[0]; } RaisePropertyChanged("CurrentShip"); }
private void Previous() { int index = Ships.FindIndex(x => x.Id == _currentShip.Id); if (index - 1 >= 0) { CurrentShip = Ships[index - 1]; } else { CurrentShip = Ships[Ships.Count - 1]; } RaisePropertyChanged("CurrentShip"); }
/// <summary> /// Handles a shot the other player made at this player /// </summary> /// <param name="shotCoordinate">The coordinate the other player shot at</param> /// <returns>Returns 'True' for a hit and 'False' for a miss</returns> public bool GotShot(ICoordinate shotCoordinate) { // 1 - Check if a ship is occuping the shot space var ship = CheckIfShipGotShot(shotCoordinate); if (ship != null) { // 2 - Handle the damage on the ship var shipIndex = Ships.FindIndex(s => s.OccupiedSpaces == ship.OccupiedSpaces); var isHit = Ships[shipIndex].GotShot(shotCoordinate); return(isHit); // #TODO --> 3 - Check if ship is still alive --> Will be handled by the GameModel by checking the PlayerModel-IsAlive() } else { return(false); } }