public static void StartNewGame() { PlayerMatrix pM = new PlayerMatrix(); PlayerMatrix eM = new PlayerMatrix(); EnenemyPlans eP = new EnenemyPlans(); Methods.EnterNicknameP1(); PlaceShips(pM, true); EnemyPlaceShips(eM); Methods.CreateScreen(eM, true); Console.Clear(); Methods.GameScreen2(0, 0, pM, Const.COMPUTER_NICKNAME); //W GAME SCREEN ZROBIC 2 OBRAZY while (game) { Methods.GameScreen2(0, 0, pM, Const.COMPUTER_NICKNAME); if (turn == false) { eM = Methods.PlaceBomb(eM); Methods.GameScreen(0, 0, eM); if (eM.playerMatrix[playerHit.X, playerHit.Y] == 999 || eM.playerMatrix[playerHit.X, playerHit.Y] == 321) //to nie działa { turn = false; g1 += state * combo; combo++; } else { turn = true; combo = 1; } } else { coordinate = eP.Shoot(hit, pM); pM = ShootEnemy(pM, coordinate.X, coordinate.Y); Methods.GameScreen2(0, 0, pM, Const.COMPUTER_NICKNAME); if (pM.playerMatrix[coordinate.X, coordinate.Y] == 999 || pM.playerMatrix[coordinate.X, coordinate.Y] == 321) { turn = true; g2 += state * combo; combo++; } else { turn = false; combo = 1; } } if (defeat == true) { eP.IsDefeat(defeat, pM, defeatlenght, defeaty, defeatx, defeatr); defeat = false; } int count = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (pM.playerMatrix[i, j] == 999) { count++; } } } if (count == 20) { game = false; Methods.SetCursor(35, 16); Methods.ColorText(String.Format("Wygrał: {0}", Const.COMPUTER_NICKNAME)); DAL.HighscoreModel.InsertInto(Const.COMPUTER_NICKNAME, g2); } else { count = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (eM.playerMatrix[i, j] == 999) { count++; } } } if (count == 20) { game = false; Methods.SetCursor(35, 16); Methods.ColorText(String.Format("Wygrał: {0}", Variable.PLAYER1_NICKNAME)); DAL.HighscoreModel.InsertInto(Variable.PLAYER1_NICKNAME, g1); Console.Read(); //MATKO JAKI PRL } } } }
public static void StartNewGame2Players() { PlayerMatrix pM = new PlayerMatrix(); PlayerMatrix eM = new PlayerMatrix(); EnenemyPlans eP = new EnenemyPlans(); //NIE MAM POJECIA DLACZEGO DOUBLE ENTER Methods.EnterNicknameP2(); PlaceShips(pM, true); PlaceShips(eM, false); //EnemyPlaceShips(eM); //EnemyPlaceShips(pM); Console.Clear(); Methods.GameScreen2(0, 0, pM, Variable.PLAYER2_NICKNAME); while (game) { if (turn == false) { eM = Methods.PlaceBomb(eM); Methods.GameScreen(0, 0, eM); if (eM.playerMatrix[playerHit.X, playerHit.Y] == 999 || eM.playerMatrix[playerHit.X, playerHit.Y] == 321) //to nie działa { turn = false; g1 += state * combo; combo++; } else { turn = true; combo = 1; } } else { pM = Methods.PlaceBomb2(pM); Methods.GameScreen2(0, 0, pM, Variable.PLAYER2_NICKNAME); if (pM.playerMatrix[playerHit.X, playerHit.Y] == 999 || pM.playerMatrix[playerHit.X, playerHit.Y] == 321) { turn = true; g2 += state * combo; combo++; } else { turn = false; combo = 1; } } int count = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (pM.playerMatrix[i, j] == 999) { count++; } } } if (count == 20) { game = false; Methods.SetCursor(35, 16); Methods.ColorText(String.Format("Wygrał: {0}", Variable.PLAYER2_NICKNAME)); DAL.HighscoreModel.InsertInto(Variable.PLAYER2_NICKNAME, g2); Console.Read(); } else { count = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (eM.playerMatrix[i, j] == 999) { count++; } } } if (count == 20) { game = false; Methods.SetCursor(35, 16); Methods.ColorText(String.Format("Wygrał: {0}", Variable.PLAYER1_NICKNAME)); DAL.HighscoreModel.InsertInto(Variable.PLAYER1_NICKNAME, g1); Console.Read(); //MATKO JAKI PRL } } } }