public GameboardImpl() { const int X_SIZE = 7; const int Y_SIZE = 8; cells = new GameboardCell[X_SIZE, Y_SIZE]; for (int x = 0; x < X_SIZE; ++x) { for (int y = 0; y < Y_SIZE; ++y) { bool is_active = true; //ToDo make it cool if (y == 0 && (x == 0 || x == X_SIZE - 1)) { is_active = false; } if (y == Y_SIZE - 1 && (x <= 1 || x == X_SIZE / 2 || x >= X_SIZE - 2)) { is_active = false; } cells[x, y] = new GameboardCell(x, y, is_active); } } }
private void HitCell(ClickInfo hit_cell) { if (hit_cell != null && hit_cell.cell != null) { if (!IsDudeSelected()) { UnitImpl hit_dude = hit_cell.cell.cell.unit; if (hit_dude != null && !hit_dude.made_move && hit_dude.command_idx == gameboard_impl.cur_command_idx) //There is dude standing on this cell!!! { hit_cell.cell.SetStatus(CellData.Status.Selected); NewMovesAvailable(hit_dude.GetMoves(gameboard_impl)); } } else { List <Move> sel_move = GetSelectedMove(hit_cell); if (sel_move != null && sel_move.Count == 1) { sel_move[0].MakeMove(gameboard_impl); } ClearAvailableCells(); if (sel_move != null && sel_move.Count > 1) { NewMovesAvailable(sel_move); first_selected_cell = hit_cell.cell.cell; } } } }
static public bool AreCellsNeighbor(GameboardCell cell, GameboardCell next_cell) { int ymin = (cell.board_x % 2) - 1; int ymax = cell.board_x % 2; int adx = Math.Abs(next_cell.board_x - cell.board_x); int dy = next_cell.board_y - cell.board_y; //{ { 0, 1 }, { 1, ymax }, { 1, ymin }, { 0, -1 }, { -1, ymin }, { -1, ymax } }; return((adx == 0 && Math.Abs(dy) == 1) || (adx == 1 && dy >= ymin && dy <= ymax)); }
private void ClearAvailableCells() { foreach (CellData cell_obj in cells_list) { cell_obj.SetStatus(CellData.Status.Clear); } available_moves = null; first_selected_cell = null; GetComponent <RouteData>().Clear(); }
private List <GameboardCell> GetNeighborCells(CellPlace cell) { List <GameboardCell> ret = new List <GameboardCell>(6); for (int i = 0; i < 6 /*deltas.GetLength(0)*/; ++i) { GameboardCell cur_cell = GetNearCell(cell, i); if (cur_cell != null) { ret.Add(cur_cell); } } return(ret); }
public GameboardCell[] GetOccupatedCells(OrientedCell cell) { GameboardCell[] ret = null; if (cell != null) { if (cell.orientation == OrientedCell.CellOrientation.Default) { ret = new GameboardCell[1] { cell.cell }; } else { ret = new GameboardCell[4]; ret [1] = cell.cell; ret [0] = GetNearCell(cell.cell, 0); switch (cell.orientation) { case OrientedCell.CellOrientation.EastNorth: ret [2] = GetNearCell(cell.cell, 4); ret [3] = GetNearCell(cell.cell, 5); break; case OrientedCell.CellOrientation.EastSouth: ret [2] = GetNearCell(cell.cell, 1); ret [3] = GetNearCell(cell.cell, 2); break; case OrientedCell.CellOrientation.East: ret [2] = GetNearCell(cell.cell, 1); ret [3] = GetNearCell(cell.cell, 5); break; } } } return(ret); }