public static void ColorPosition2(int x, int y, PlayerMatrix pM) { Console.BackgroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.White; SetCursor(x, y); if (pM.playerMatrix[(x - Const.EM_X - 31) / 2, y - Const.EM_Y] == 999) { Console.Write("&"); } else if (pM.playerMatrix[(x - Const.EM_X - 31) / 2, y - Const.EM_Y] == 123) { Console.Write("*"); } else if (pM.playerMatrix[(x - Const.EM_X - 31) / 2, y - Const.EM_Y] == 321) { Console.Write("$"); } else { Console.Write("~"); } Console.ResetColor(); Console.Write(" "); }
public PlayerMatrix PlaceShip(int size, PlayerMatrix pM, bool player) { s = new Ship(size); pM = SetShip(pM, s); if (!CheckAllPosition(pM)) // jeżeli okazuje się że są nakładki { AcceptButton.IsEnabled = false; } else { AcceptButton.IsEnabled = true; } CreateScreen(pM); return(pM); }
private void StartTcpGame(object sender, RoutedEventArgs e) { try { proxy = new Proxy(); Console.WriteLine("Connecting....."); proxy.Connect("192.168.1.103"); // use the ipaddress as in the server program Console.WriteLine("Connected"); // String str = Console.ReadLine(); // proxy.Send(str); byte[] bb = new byte[200]; bb = proxy.Recived(); Message msg = Methods.ReadMessage(bb); // Console.Write(Convert.ToChar(bb[i])); GridStart.Visibility = Visibility.Hidden; tb.Text = msg.flag; if (msg.flag == "STRT") { GridStart.Visibility = Visibility.Hidden; PlaceShipScreen.Visibility = Visibility.Visible; playerMatrix = new PlayerMatrix(); enemyMatrix = new PlayerMatrix(); builder = new ImageBuilder(); strategy = new PointerMover(); PlaceShip(4, playerMatrix = new PlayerMatrix(), false); } else { proxy.Close(); Console.Read(); } } catch (Exception error) { Console.WriteLine("Error..... " + error.StackTrace); } }
public static int[] MIS(PlayerMatrix pM) { counter = 0; int[] tab = new int[160]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (pM.playerMatrix[i, j] == 123) { tab[(counter * 2)] = i; tab[1 + (2 * counter)] = j; counter++; } } } return(tab); }
public static PlayerMatrix ClearShip(PlayerMatrix pM, Ship s) { if (s.rotate) { for (int i = s.y; i < s.y + s.size; i++) { pM.playerMatrix[i, s.x] -= (s.size * 2) - 1; } } else { for (int j = s.x; j < s.x + s.size; j++) { pM.playerMatrix[s.y, j] -= (s.size * 2) - 1; } } return(pM); }
public static bool End(PlayerMatrix pM) { 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) { Console.Write("KONIEC GRY\n"); return(true); } return(false); }
public static bool CheckAllPosition(PlayerMatrix pM) { try { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if ((pM.playerMatrix[i, j] != 0) && (pM.playerMatrix[i, j] != 1) && (pM.playerMatrix[i, j] != 3) && (pM.playerMatrix[i, j] != 5) && (pM.playerMatrix[i, j] != 7) && (pM.playerMatrix[i, j] != 9)) { return(false); } } } return(true); } catch { return(false); } }
public void CreateScreen(PlayerMatrix pM) { MainWindow1.Height = 600; MainWindow1.Width = 600; GridStart.Visibility = Visibility.Hidden; PlaceShipScreen.Visibility = Visibility.Visible; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (pM.playerMatrix[i, j] == 0) { builder.BuildWather(); playerGameBoard[i, j] = builder.GetImage(); } else if (pM.playerMatrix[i, j] == 9) { builder.BuildMiss(); playerGameBoard[i, j] = builder.GetImage(); } else if (pM.playerMatrix[i, j] == 1 || pM.playerMatrix[i, j] == 3 || pM.playerMatrix[i, j] == 5 || pM.playerMatrix[i, j] == 7) { builder.BuildShip(); playerGameBoard[i, j] = builder.GetImage(); } else { builder.BuildColide(); playerGameBoard[i, j] = builder.GetImage(); } Grid.SetColumn(playerGameBoard[i, j], i + 1); Grid.SetRow(playerGameBoard[i, j], j + 1); PlaceShipScreen.Children.Add(playerGameBoard[i, j]); } } }
public static PlayerMatrix SuroundShip(PlayerMatrix pM, Ship s) { if (s.rotate) { for (int i = s.x - 1; i <= s.x + 1; i++) { for (int j = s.y - 1; j <= s.y + s.size; j++) { if (i < 10 && j < 10 && i >= 0 && j >= 0) { if (pM.playerMatrix[j, i] == 0) { pM.playerMatrix[j, i] = 9; } } } } } else { for (int i = s.x - 1; i <= s.x + s.size; i++) { for (int j = s.y - 1; j <= s.y + 1; j++) { if (i < 10 && j < 10 && i >= 0 && j >= 0) { if (pM.playerMatrix[j, i] == 0) { pM.playerMatrix[j, i] = 9; } } } } } return(pM); }
public static void GameScreen2(int x, int y, PlayerMatrix pM, string nickname) { //DA FAK try { int vector = 31; SetCursor(Const.NICKNAME1_X + vector + (20 - nickname.Length) / 2, Const.NICKNAME1_Y); Console.WriteLine(nickname); SetCursor(Const.EM_X + vector, Const.EM_Y); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (pM.playerMatrix[i, j] == 999) { Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.Black; Console.Write("& "); Console.ResetColor(); } else if (pM.playerMatrix[i, j] == 123) { Console.Write("* "); } else if (pM.playerMatrix[i, j] == 321) { Console.BackgroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Black; Console.Write("$ "); Console.ResetColor(); } else { Console.Write("~ "); } } SetCursor(Const.EM_X + vector, Const.EM_Y + i + 1); } SetCursor(Const.EM_X + vector, Const.EM_Y); if (x != 0 && y != 0) { ColorPosition2(x, y, pM); } //SetCursor(0, 50); //for(int i=0 ;i<10;i++) //pokazuje jak jest zapisana macierz w pamięci i jest chujowo po 1 strzale //{ // for(int j=0;j<10;j++) // { // Console.Write(pM.playerMatrix[i, j]); // } // Console.Write("\n"); //} } catch { Console.WriteLine(Messages.GAME_SCREEN_ALERT); } }
public static void GameScreen(int x, int y, PlayerMatrix pM) { //DA FAK try { SetCursor(Const.NICKNAME1_X + (20 - Variable.PLAYER1_NICKNAME.Length) / 2, Const.NICKNAME1_Y); Console.WriteLine(Variable.PLAYER1_NICKNAME); SetCursor(Const.VS_X, Const.VS_Y); Console.WriteLine("vs"); SetCursor(Const.EM_X, Const.EM_Y); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (pM.playerMatrix[i, j] == 999) { Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.Black; Console.Write("& "); Console.ResetColor(); } else if (pM.playerMatrix[i, j] == 123) { Console.Write("* "); } else if (pM.playerMatrix[i, j] == 321) { Console.BackgroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Black; Console.Write("$ "); Console.ResetColor(); } else { Console.Write("~ "); } } SetCursor(Const.EM_X, Const.EM_Y + i + 1); } SetCursor(Const.EM_X, Const.EM_Y); if (x != 0 && y != 0) { ColorPosition(x, y, pM); } SetCursor(Const.MENU_CONTROL_X + 1, Const.MENU_CONTROL_Y); Console.WriteLine(Messages.CONTROL); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 1); Console.WriteLine(Messages.CONTROLS_GAME_UP); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 2); Console.WriteLine(Messages.CONTROLS_GAME_DOWN); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 3); Console.WriteLine(Messages.CONTROLS_GAME_LEFT); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 4); Console.WriteLine(Messages.CONTROLS_GAME_RIGHT); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 5); Console.WriteLine(Messages.CONTROLS_GAME_ENTER); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 6); Console.WriteLine(Messages.CONTROLS_GAME_TILDE); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 7); Console.WriteLine(Messages.CONTROLS_GAME_STAR); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 8); Console.WriteLine(Messages.CONTROLS_GAME_DOLAR); SetCursor(Const.MENU_CONTROL_X - 2, Const.MENU_CONTROL_Y + 9); Console.WriteLine(Messages.CONTROLS_GAME_ET); //SetCursor(0, 50); //for(int i=0 ;i<10;i++) //pokazuje jak jest zapisana macierz w pamięci i jest chujowo po 1 strzale //{ // for(int j=0;j<10;j++) // { // Console.Write(pM.playerMatrix[i, j]); // } // Console.Write("\n"); //} } catch { Console.WriteLine(Messages.GAME_SCREEN_ALERT); } }
public static PlayerMatrix PlaceShip(int size, PlayerMatrix pM, bool player) //prawdopodobnie czesc interfejsu { Game.Ship s = new Game.Ship(size); int x = 23; int y = 3; pM = Game.SetShip(pM, s); Methods.CreateScreen(pM, player); Methods.SetCursor(23, 3); while (true) { string selected = Console.ReadKey().Key.ToString(); if (selected == "Enter") { if (!Game.CheckAllPosition(pM)) { Methods.SetCursor(15, Const.MENU_CONTROL_Y + 10); Console.WriteLine(Messages.SET_ALERT); Methods.SetCursor(23, Const.MENU_CONTROL_Y + 11); Console.WriteLine(Messages.SET_ALERT2); } else { pM = Game.SuroundShip(pM, s); Methods.CreateScreen(pM, player); break; } } if (selected == "F1") { if ((s.rotate == false && y + s.size - 1 < 13) || (s.rotate == true && x + s.size * 2 - 1 < 43)) { Game.ClearShip(pM, s); s.rotate = !s.rotate; Game.SetShip(pM, s); Methods.CreateScreen(pM, player); } else { Methods.CreateScreen(pM, player); } } if (selected == "UpArrow") { if (y > 3) { Game.ClearShip(pM, s); y--; s.y--; Game.SetShip(pM, s); Methods.CreateScreen(pM, player); } else { Methods.CreateScreen(pM, player); } } if (selected == "DownArrow") { if ((y < 12 && s.rotate == false) || (s.rotate == true && y + s.size - 1 < 12)) { Game.ClearShip(pM, s); y++; s.y++; Game.SetShip(pM, s); Methods.CreateScreen(pM, player); } else { Methods.CreateScreen(pM, player); } } if (selected == "RightArrow") { if ((x < 41 && s.rotate == true) || (s.rotate == false && x + s.size * 2 - 1 < 41)) { Game.ClearShip(pM, s); x += 2; s.x++; Game.SetShip(pM, s); Methods.CreateScreen(pM, player); } else { Methods.CreateScreen(pM, player); } } if (selected == "LeftArrow") { if (x > 23) { Game.ClearShip(pM, s); x -= 2; s.x--; Game.SetShip(pM, s); Methods.CreateScreen(pM, player); } else { Methods.CreateScreen(pM, player); } } } return(pM); }
public int [] Move(PlayerMatrix enemyMatrix, Image[,] enemyGameBoard, bool approved, int x, int y, ImageBuilder builder) { int[] tab; tab = strategy.Move(enemyMatrix, enemyGameBoard, approved, x, y, builder); return(tab); }
public abstract int[] Move(PlayerMatrix enemyMatrix, Image[,] enemyGameBoard, bool approved, int x, int y, ImageBuilder builder);
public static PlayerMatrix PlaceBomb2(PlayerMatrix pM) { int vector = 31; int x = Const.EM_X + vector; int trueX = Const.EM_X; int y = Const.EM_Y; ColorPosition2(x, y, pM); GameScreen2(0, 0, pM, Variable.PLAYER2_NICKNAME); Methods.SetCursor(26, Const.MENU_CONTROL_Y + 15); Console.Write(" "); Console.TreatControlCAsInput = true; while (true) { string selected = Console.ReadKey().Key.ToString(); if (selected == "Enter") { if (pM.playerMatrix[y - Const.EM_Y, trueX - Const.EM_X] == 123 || pM.playerMatrix[y - Const.EM_Y, trueX - Const.EM_X] == 321 || pM.playerMatrix[y - Const.EM_Y, trueX - Const.EM_X] == 999) { Methods.SetCursor(26, Const.MENU_CONTROL_Y + 15); Console.Write(Messages.SET_BOMB_ALERT); } else { pM = Game.Shoot(pM, y - Const.EM_Y, /*(x - 23) / 2*/ trueX - Const.EM_X); GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); break; } } if (selected == "UpArrow") { if (y > 5) { y = y - 1; GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } else { GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } } if (selected == "DownArrow") { if (y < 14) { y = y + 1; GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } else { GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } } if (selected == "RightArrow") { if (x < 35 + vector) { x = x + 2; trueX++; GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } else { GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } } if (selected == "LeftArrow") { if (x > 18 + vector) { trueX--; x = x - 2; GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } else { GameScreen2(x, y, pM, Variable.PLAYER2_NICKNAME); } } } return(pM); }
public static void CreateScreen(PlayerMatrix pM, bool player) { try { Console.Clear(); SetCursor(Const.MENU_NICKNAME_X, Const.MENU_NICKNAME_Y); if (player) { Console.WriteLine(Variable.PLAYER1_NICKNAME); } else { Console.WriteLine(Variable.PLAYER2_NICKNAME); } SetCursor(Const.MENU_SET_X, Const.MENU_SET_Y); Console.WriteLine(Messages.SET_SHIP_MESSAGE); #region MATRIX SetCursor(Const.MATRIX_X, Const.MATRIX_Y); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (pM.playerMatrix[i, j] == 1 || pM.playerMatrix[i, j] == 3 || pM.playerMatrix[i, j] == 5 || pM.playerMatrix[i, j] == 7) { Console.Write("# "); } else if (pM.playerMatrix[i, j] == 10 || pM.playerMatrix[i, j] == 12 || pM.playerMatrix[i, j] == 14 || pM.playerMatrix[i, j] == 16 || pM.playerMatrix[i, j] == 4 || pM.playerMatrix[i, j] == 8 || pM.playerMatrix[i, j] == 10 || pM.playerMatrix[i, j] == 12 || pM.playerMatrix[i, j] == 6) { ColorWrongPlace(Console.CursorLeft, Console.CursorTop); } else if (pM.playerMatrix[i, j] == 9 || pM.playerMatrix[i, j] == 18) { Console.Write("X "); } else { Console.Write("~ "); } } SetCursor(Const.MATRIX_X, Const.MATRIX_Y + i + 1); } #endregion SetCursor(Const.LOST_SHIP_X, Const.LOST_SHIP_Y1); Console.WriteLine(Variable.CZTEROMASZTOWCE + " - ####"); SetCursor(Const.LOST_SHIP_X, Const.LOST_SHIP_Y2); Console.WriteLine(Variable.TRZYMASZTOWCE + " - ###"); SetCursor(Const.LOST_SHIP_X, Const.LOST_SHIP_Y3); Console.WriteLine(Variable.DWUMASZTOWCE + " - ##"); SetCursor(Const.LOST_SHIP_X, Const.LOST_SHIP_Y4); Console.WriteLine(Variable.JEDNOMASZTOWIEC + " - #"); SetCursor(Const.MENU_CONTROL_X, Const.MENU_CONTROL_Y); Console.WriteLine(Messages.CONTROL); SetCursor(Const.MENU_CONTROL_X - 10, Const.MENU_CONTROL_Y + 1); Console.WriteLine(Messages.CONTROLS_PLACE_SHIP_UP); SetCursor(Const.MENU_CONTROL_X - 10, Const.MENU_CONTROL_Y + 2); Console.WriteLine(Messages.CONTROLS_PLACE_SHIP_DOWN); SetCursor(Const.MENU_CONTROL_X - 10, Const.MENU_CONTROL_Y + 3); Console.WriteLine(Messages.CONTROLS_PLACE_SHIP_LEFT); SetCursor(Const.MENU_CONTROL_X - 10, Const.MENU_CONTROL_Y + 4); Console.WriteLine(Messages.CONTROLS_PLACE_SHIP_RIGHT); SetCursor(Const.MENU_CONTROL_X - 10, Const.MENU_CONTROL_Y + 5); Console.WriteLine(Messages.CONTROLS_PLACE_SHIP_F1); SetCursor(Const.MENU_CONTROL_X - 10, Const.MENU_CONTROL_Y + 6); Console.WriteLine(Messages.CONTROLS_PLACE_SHIP_ENTER); SetCursor(Const.MATRIX_X, Const.MATRIX_Y); } catch { Console.WriteLine(Messages.CREATE_SCREEN_ALERT); } }
private void SetShipOnPlace(object sender, RoutedEventArgs e) { if (Variable2.TRZYMASZTOWCE > 0) { playerMatrix = SuroundShip(playerMatrix, s); Variable2.TRZYMASZTOWCE--; PlaceShip(3, playerMatrix, false); } else { if (Variable2.DWUMASZTOWCE > 0) { playerMatrix = SuroundShip(playerMatrix, s); Variable2.DWUMASZTOWCE--; PlaceShip(2, playerMatrix, false); } else { if (Variable2.JEDNOMASZTOWIEC > 0) { playerMatrix = SuroundShip(playerMatrix, s); Variable2.JEDNOMASZTOWIEC--; PlaceShip(1, playerMatrix, false); } else { playerMatrix = SuroundShip(playerMatrix, s); string msg = "NTAB100"; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { msg += playerMatrix.playerMatrix[i, j]; } } proxy.Send(msg); tb.Text = "Oczekiwanie na 2 gracza"; //tu czekanie na zezwolenie od servera normalnie byte[] bb = new byte[150]; bb = proxy.Recived(); Message mssg = Methods.ReadMessage(bb); if (mssg.flag == "TURN") { tb.Text = "Twoja tura"; GameScreen(); turns = 1; return; } else { tb.Text = "Tura 2 gracza"; GameScreen(); turns = 0; // ApprovedShot.Visibility = Visibility.Hidden; // enemyTour(); } } } } }
public override int[] Move(PlayerMatrix enemyMatrix, Image[,] enemyGameBoard, bool approved, int x, int y, ImageBuilder builder) { int[] tab = new int[2]; if (x > 0) { enemyMatrix.playerMatrix[x, y] -= 1000; x--; enemyMatrix.playerMatrix[x, y] += 1000; if (enemyMatrix.playerMatrix[x, y] == 1000 || enemyMatrix.playerMatrix[x, y] == 1009 || enemyMatrix.playerMatrix[x, y] == 1001 || enemyMatrix.playerMatrix[x, y] == 1003 || enemyMatrix.playerMatrix[x, y] == 1005 || enemyMatrix.playerMatrix[x, y] == 1007) { builder.BuildWaterPointer(); enemyGameBoard[x, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x, y] == 1123) { builder.BuildMissPointer(); enemyGameBoard[x, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x, y] == 1321) { builder.BuildShipPointer(); enemyGameBoard[x, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x, y] == 1999) { builder.BuildHitPointer(); enemyGameBoard[x, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x + 1, y] == 123) { builder.BuildMiss(); enemyGameBoard[x + 1, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x + 1, y] == 321) { builder.BuildShipHit(); enemyGameBoard[x + 1, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x + 1, y] == 999) { builder.BuildHit(); enemyGameBoard[x + 1, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x + 1, y] == 0 || enemyMatrix.playerMatrix[x + 1, y] == 9 || enemyMatrix.playerMatrix[x + 1, y] == 1 || enemyMatrix.playerMatrix[x + 1, y] == 3 || enemyMatrix.playerMatrix[x + 1, y] == 5 || enemyMatrix.playerMatrix[x + 1, y] == 7) { builder.BuildWather(); enemyGameBoard[x + 1, y].Source = builder.GetImage().Source; } if (enemyMatrix.playerMatrix[x, y] == 1000 || enemyMatrix.playerMatrix[x, y] == 1009 || enemyMatrix.playerMatrix[x, y] == 1001 || enemyMatrix.playerMatrix[x, y] == 1003 || enemyMatrix.playerMatrix[x, y] == 1005 || enemyMatrix.playerMatrix[x, y] == 1007) { tab[0] = x; tab[1] = 1; return(tab); } else { tab[0] = x; tab[1] = 0; return(tab); } } if (enemyMatrix.playerMatrix[x, y] == 1000 || enemyMatrix.playerMatrix[x, y] == 1009 || enemyMatrix.playerMatrix[x, y] == 1001 || enemyMatrix.playerMatrix[x, y] == 1003 || enemyMatrix.playerMatrix[x, y] == 1005 || enemyMatrix.playerMatrix[x, y] == 1007) { tab[0] = x; tab[1] = 1; return(tab); } else { tab[0] = x; tab[1] = 0; return(tab); } }
public static PlayerMatrix Shoot(PlayerMatrix pM, int x, int y) { int tx = x; int ty = y; if (pM.playerMatrix[x, y] == 1 || pM.playerMatrix[x, y] == 3 || pM.playerMatrix[x, y] == 5 || pM.playerMatrix[x, y] == 7) { if (pM.playerMatrix[x, y] == 1) { pM.playerMatrix[x, y] = 999; // zatopiony int truey = y; int truex = x; int rotate = 2; // pozioma int lenght = 0; y--; //zatapiamy pozostałe maszty if (y >= 0) { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { rotate = 2;//poziom pM.playerMatrix[x, y] = 999; y--; if (y < 0) { break; } } } y = truey + 1; if (y <= 9) { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { rotate = 2;//poziom pM.playerMatrix[x, y] = 999; y++; if (y > 9) { break; } } } x--; y = truey; if (x >= 0) { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { rotate = 1;//pionowa pM.playerMatrix[x, y] = 999; x--; if (x < 0) { break; } } } x = truex + 1; if (x <= 9) { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { rotate = 1;//pionowa pM.playerMatrix[x, y] = 999; x++; if (x > 9) { break; } } } x = truex; y = truey; if (rotate == 1) //pionowa { while (x > 0 && pM.playerMatrix[x, y] == 999) { if (pM.playerMatrix[x - 1, y] == 999) { truex = x - 1; } x--; } x = truex; while (x < 9 && pM.playerMatrix[x, y] == 999) { x++; lenght++; } } else //poziom { while (y > 0 && pM.playerMatrix[x, y] == 999) { if (pM.playerMatrix[x, y - 1] == 999) { truey = y - 1; } y--; } y = truey; while (y < 9 && pM.playerMatrix[x, y] == 999) { y++; lenght++; } } if (rotate == 1) { for (int i = truey - 1; i <= truey + 1; i++) { for (int j = truex - 1; j <= truex + lenght; j++) { if (i < 10 && j < 10 && i >= 0 && j >= 0) { if (pM.playerMatrix[j, i] != 999) // JA JEBIE XD { pM.playerMatrix[j, i] = 123; } } } } } else { for (int i = truex - 1; i <= truex + 1; i++) { for (int j = truey - 1; j <= truey + lenght; j++) { if (i < 10 && j < 10 && i >= 0 && j >= 0) { if (pM.playerMatrix[i, j] != 999) { pM.playerMatrix[i, j] = 123; } } } } } } else { pM.playerMatrix[x, y] = 321; //trafiony int truey = y; int truex = x; y--; if (y >= 0) //odejmujemy stałą 2 od pozostałych masztów { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { if (pM.playerMatrix[x, y] != 321) { pM.playerMatrix[x, y] -= 2; } y--; if (y < 0) { break; } } } y = truey + 1; if (y <= 9) { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { if (pM.playerMatrix[x, y] != 321) { pM.playerMatrix[x, y] -= 2; } y++; if (y > 9) { break; } } } x--; y = truey; if (x >= 0) { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { if (pM.playerMatrix[x, y] != 321) { pM.playerMatrix[x, y] -= 2; } x--; if (x < 0) { break; } } } x = truex + 1; if (x <= 9) { while (pM.playerMatrix[x, y] != 9 && pM.playerMatrix[x, y] != 18 && pM.playerMatrix[x, y] != 123) { if (pM.playerMatrix[x, y] != 321) { pM.playerMatrix[x, y] -= 2; } x++; if (x > 9) { break; } } } } } else if (pM.playerMatrix[x, y] != 321 && pM.playerMatrix[x, y] != 999) { pM.playerMatrix[x, y] = 123; } return(pM); }