public void Grow() { switch (assigned_shape) { case Shape.NONE: // grow straight GridMarker north_neighbor = FindNeighboringGridMarker(Direction.NORTH); AdvanceGrowth(north_neighbor); break; default: break; } }
/// <summary> /// For each grid in grid_markers, give it a grid position /// so it can find it's neighbors later /// </summary> private void CreateBoard() { grid_markers = new GridMarker[GRID_WIDTH, GRID_HEIGHT]; for (int x = 0; x < GRID_WIDTH; x++) { for (int y = 0; y < GRID_HEIGHT - 1; y++) { GameObject gm = Instantiate(grid_marker_prefab, new Vector3(BOARD_START_X + (BOARD_MARKER_MARGIN * x), BOARD_START_Y - (BOARD_MARKER_MARGIN * y), 0), grid_marker_prefab.transform.rotation); GridMarker newGridMarker = gm.AddComponent <GridMarker>(); newGridMarker.xGridPosition = x; newGridMarker.yGridPosition = y; newGridMarker.obj = gm; grid_markers[x, y] = newGridMarker; } } }
private void AdvanceGrowth(GridMarker position) { growthLine.positionCount += 1; growthLine.SetPosition(growthLine.positionCount - 1, position.obj.transform.position); current_position = position; }