public string GetCoordinat(string attach) { string answer = ""; int x = 0, y = 0; if (attach == "+++" || attach == "***") { Point tmp = AutoAction.AutoAttack(ref Matrix_Com_Enemy); answer = answer + tmp.X.ToString(); answer = answer + tmp.Y.ToString(); answer = answer + "-"; } else { x = Int32.Parse(attach[0].ToString()); y = Int32.Parse(attach[1].ToString()); if (Matrix_Com_My[x, y].Get_Unit_Type() == unit_type.sea) { Point tmp = AutoAction.AutoAttack(ref Matrix_Com_Enemy); answer = answer + tmp.X.ToString(); answer = answer + tmp.Y.ToString(); answer = answer + "-"; } if (Matrix_Com_My[x, y].Get_Unit_Type() == unit_type.ship) { Matrix_Com_My[x, y].Set_Unit_Type(unit_type.hit_ship); answer = "+++"; } if (Utilits.IsEndGame(Matrix_Com_My)) { answer = "end"; } } return(answer); }
public Computer() { for (int i = 0; i < Matrix_Com_Enemy.GetLength(0); i++) { for (int j = 0; j < Matrix_Com_Enemy.GetLength(1); j++) { Matrix_Com_Enemy[i, j] = new Unit(unit_type.sea, i, j); Matrix_Com_My[i, j] = new Unit(unit_type.sea, i, j); } } AutoAction.AutoSetShips(ref Matrix_Com_My); }
// Авто-заполнение поля public void AutoSetShips() { Initinitialization_Field(Unit.Get_Size_Unit(), MyCanvas_MouseLeftButtonUp); // Инициализируем матрицу по новой, чтобы она была "чистой" AutoAction.AutoSetShips(ref matrix_state); SetFieldType(type_field.user_field); Initinitialization_Field(Unit.Get_Size_Unit(), MyCanvas_MouseLeftButtonUp, matrix_state); // Отрисовка новой, заполненной матрицы grid.IsEnabled = false; // Блокируем поле, т.к. все уже выставлено и оно больше не будет изменяться игроком StartFieldEvent(); if (this.mode_game == game_mode.online_game) { online_client = new ConnectManager(Utilits.ParseMatric(matrix_state)); // Создаем подключение } }