}//End TravelTo() public void CheckDistanceTo(Planet planet) { //Determines X and Y between ship and planet int x = planet.planetX - this.shipX; int y = planet.planetY - this.shipY; //Calculates Distance round to 2 decimal places double distanceToPlanet = Math.Round(Math.Sqrt(x * x + y * y), 2); //Calculates Traveltime to 2 decimal places using ship level and predetermined travel ratio double travelTime = Math.Round(distanceToPlanet * SpaceGame.travelRatio / this.level, 2); Console.WriteLine($"\t{planet.name} is {distanceToPlanet} TNG Warp Factors away."); Console.Write("It would take "); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write($"{travelTime}"); Console.ResetColor(); Console.WriteLine(" years to get based on your ship level."); Console.Write("\n\tDo you want to go there? [Y/N]: "); string choice = Convert.ToString(Console.ReadLine().ToUpper()); switch (choice) { case "Y": SpaceGame.gameTime += travelTime; break; case "N": Console.WriteLine("\nOk, no problem..."); SpaceGame.Choices(); break; default: Console.WriteLine("\nNot sure what you meant by that?\n"); CheckDistanceTo(planet); break; } }//End CheckDistanceTo
}//End CheckLocation() //Displays a rocket depending on Ship Level when traveling public void TravelTo(Planet planet) { string rocket1 = @" /\ ( ) ( ) /|/\|\ /_||||_\"; string rocket2 = @" | / \ / _ \ |.o '.| |'._.'| | | ,'| | |`. / | | | \ |,-'--|--'-.|"; string rocket3 = @" ! ! ^ / \ /___\ |= =| | | | | | | | | | | | | | | | | | | /|##!##|\ / |##!##| \ / |##!##| \ | / ^ | ^ \ | | / ( | ) \ | |/ ( | ) \| (( )) (( : )) (( : )) (( )) (( )) ( ) . . ."; Console.Clear(); for (int i = 0; i < 40; i++) { Console.WriteLine(""); } switch (this.level) { case 1: Console.WriteLine(rocket1); break; case 2: Console.WriteLine(rocket2); break; case 3: Console.WriteLine(rocket3); break; } for (int i = 0; i < 30; i++) { Console.WriteLine(""); Thread.Sleep(120); } //Sets the ship location to the traveled to planet location this.shipX = planet.planetX; this.shipY = planet.planetY; Console.WriteLine($"You are now on Planet {CheckLocation()}!"); SpaceGame.Continue(); }//End TravelTo()
static void Main(string[] args) { SpaceGame.SpaceGameIntro(); } //End Main()