public List <Shot> Play() { bool isHunting = true; Shot result; while (ShipsDestroyed != Ship.NUM_OF_SHIPS) { Display.Grid(Board); //DISPLAY PURPOSE if (isHunting) { result = Hunt(); if (result.ShotTypeId == (int)ShotType.Hit) { TargetCoords.Add(new Coordinates { X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault() }); isHunting = false; } } else { result = Target(); if (result.ShotTypeId != (int)ShotType.Missed) { if (result.ShotTypeId == (int)ShotType.Hit) { TargetCoords.Add(new Coordinates { X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault() }); } else if (result.ShotTypeId == (int)ShotType.Destroyed) { isHunting = true; ShipsDestroyed++; TargetDirection = DirectionTaken.Random; TargetOrientation = Orientation.Random; PossibleTargets.Clear(); TargetCoords.Clear(); } } } if (result.ShotTypeId != (int)ShotType.Duplicate) { Shots.Add(result); ShotNumber++; } } Console.WriteLine("----------------"); //Display Purpose return(Shots); }
public override string ToString() { if (Type == SCPointOfInterestType.Warp) { return(Coords.ToString() + "->Warp"); } else if (Type == SCPointOfInterestType.Exit) { return(Coords.ToString() + "->Exit"); } { return(Coords.ToString() + "->" + TargetMap.ToString() + TargetCoords.ToString()); } }