private bool generateNewIsland(Board3D board, List <Island3D> islands, Vector3D direction, Vector3D origin) { Vector3D current = origin + direction; Vector3D lastPossible = null; if (!board.isInBounds(current)) { return(false); } if (!board.canBuildBridge(current)) { return(false); } while (true) { current += direction; if (!board.isInBounds(current)) { return(false); } if (board.canPlaceIsland(current)) { lastPossible = current; if (board.canBuildBridge(current)) { if (Random.Range(0, 2) == 1 ? true : false) { continue; } else { createIsland(board, origin, lastPossible, islands, direction); return(true); } } else { createIsland(board, origin, lastPossible, islands, direction); return(true); } } else if (board.get(current) is Island3D) { return(false); } else if (board.canBuildBridge(current)) { continue; } else if (lastPossible != null) { createIsland(board, origin, lastPossible, islands, direction); return(true); } else { return(false); } } }
public void reValue(Board3D board) { int sum = 0; Node3D tempNode; foreach (Vector3D direction in Vector3D.directions) { if (board.isInBounds(getPosition() + direction)) { tempNode = board.get(getPosition() + direction); if (tempNode is Bridge3D) { if (board.isInBounds(tempNode.getPosition() + ((Bridge3D)tempNode).getDirection()) && board.get(tempNode.getPosition() + ((Bridge3D)tempNode).getDirection()) == this) { sum += ((Bridge3D)board.get(getPosition() + direction)).isDoubleBridge() ? 2 : 1; } if (board.isInBounds(tempNode.getPosition() - ((Bridge3D)tempNode).getDirection()) && board.get(tempNode.getPosition() - ((Bridge3D)tempNode).getDirection()) == this) { sum += ((Bridge3D)board.get(getPosition() + direction)).isDoubleBridge() ? 2 : 1; } } } } value = sum; }