public override void Play() { var val1 = Player1.Attack(); var val2 = Player2.Attack(); DisplayMessage.NewLine(); ShowResult(val1, val2); }
public void StartGame() { bool playerOneTurn = true; while (true) { if (Player1.Lives == 0) { Console.WriteLine("Player 1 Wins!"); break; } if (Player2.Lives == 0) { Console.WriteLine("Player 2 Wins!"); break; } if (playerOneTurn) { Console.WriteLine("It;s player 1's turn"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Your board"); Player1.board.printBoard(); Console.WriteLine(); Console.WriteLine("Enemy board"); Player1.fireBoard.printFireBoard(); if (Player1.Attack(Player2.board) != "Hit") { //Player1.Attack(Player2.board); playerOneTurn = !playerOneTurn; } Console.WriteLine("Press any key to clear console."); string a = Console.ReadLine(); Console.Clear(); } if (!playerOneTurn) { Console.WriteLine("It's player 2's turn"); Console.WriteLine( ); Console.WriteLine(); playerOneTurn = true; Console.WriteLine("Your board"); Player2.board.printBoard(); Console.WriteLine(); Console.WriteLine("Enemy board"); Player2.fireBoard.printFireBoard(); if (Player2.Attack(Player1.board) != "Hit") { //Player2.Attack(Player1.board); playerOneTurn = true; } Console.WriteLine("Press any key to clear console."); string a = Console.ReadLine(); Console.Clear(); } } }
public override void Play() { DisplayMessage.FirstPlayerTurn(); var val1 = Player1.Attack(); Console.Clear(); DisplayMessage.SecondPlayerTurn(); var val2 = Player2.Attack(); Console.Clear(); ShowResult(val1, val2); }
public void PlayOneRound() { var coordinates = Player1.Attack(); Player2.ProcessAttack(coordinates); //possible that all player 2 ships have been sunk before player 2 launches an attack if (!Player2.hasLost) { coordinates = Player2.Attack(); Player1.ProcessAttack(coordinates); } }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Cyan; Console.OutputEncoding = Encoding.UTF8; Console.WriteLine("这是一个测试:"); Player1 player1 = new Player1(); Player2 player2 = new Player2(); Console.WriteLine(player1); Console.WriteLine(player2); player1.Attack(player2); player2.Attack(player1); Console.ReadLine(); }
public void EndTurn() { if (turnCount % 2 == 0) //turn player1 { Console.WriteLine(player1.UserName + " choose coordinate and attack"); Player2.Attacked(Player1.Attack()); DrawMaps(); } else //turn player2 { DrawMaps(); Console.WriteLine(player2.UserName + " choose coordinate and attack"); Player1.Attacked(Player2.Attack()); DrawMaps(); } Console.WriteLine("press enter for other turn"); Console.ReadLine(); turnCount++; }
//This method is for the battle simulation. private void Battle() { //Generate a random monster based on stats from player. Monster monster = Utility.GenerateRandomMonster(Player1); Console.WriteLine($"Uh oh! A Wild {monster.MonsterType} appeared!"); Console.WriteLine($"His name is {monster.Name}"); Utility.Nani(Player1, monster); bool battling = true; while (battling) { int playerDamage = Player1.Attack(); monster.TakeDamage(playerDamage); Console.WriteLine($"You hit {monster.Name}, dealing {playerDamage} damage"); if (monster.IsDead) { Console.WriteLine($"You killed {monster.Name}, gaining {monster.Exp} experience!"); Player1.UpdateExp(monster.Exp); Player1.LootGold(monster.GetGold()); Console.WriteLine($"You are Level {Player1.Level} and you have {Player1.Exp} exp and {Player1.CurrentHealth} hp"); battling = false; } else { Console.WriteLine("UUooooaah *slurp* "); Console.WriteLine(" MONSTER ATTACK " + monster.Attack()); int monsterDamage = Player1.PlayerTakeDamage(monster.Attack()); Console.WriteLine($"{monster.Name} hit you dealing {monsterDamage}"); if (Player1.IsDead) { Console.WriteLine($"You were killed by {monster.Name} :("); battling = false; } Console.WriteLine($"{Player1.Name}: {Player1.CurrentHealth} hp"); Console.WriteLine($"{monster.Name}: {monster.CurrentHealth} hp"); } Console.WriteLine("[Press enter to continue]"); Console.ReadKey(); Console.Clear(); } }