public void SetGridCellContent() { IGridConfiguration conf = CreateTestConfig(); IGrid grid = new SquareGrid(conf); ICellContent content = Substitute.For <ICellContent>(); Cell.Cell cell = grid.GetCell(0, 0); cell.Content = content; Assert.AreEqual(content, grid.GetCell(0, 0).Content); }
void AdjustVerticleHeight() { if (mainCamera.orthographic) { transform.position = new Vector3(transform.position.x, 0, transform.position.z); } else { SquareCell cell = grid.GetCell(transform.position); Vector3 target = new Vector3(transform.position.x, 0, transform.position.z) + Vector3.up * cell.GetMaxElevation() * GridMetrics.elevationStep; transform.position = Vector3.SmoothDamp(transform.position, target, ref velocity, smoothTime); } }
public IGrid Create() { SquareGrid grid = new SquareGrid(gridConfig); int cellCount = gridConfig.RowCount * gridConfig.ColumnCount; for (int i = 0; i < cellCount; i++) { int row, column; GridMath.CalculateColumnRow(i, gridConfig.ColumnCount, out column, out row); grid.GetCell(column, row).Content = randomContentProvider.Get(); } return(grid); }
void HandleInput() { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { currentCell = squareGrid.GetCell(hit.point); if (previousCell && previousCell != currentCell) { ValidateDrag(currentCell); } else { isDrag = false; } EditCells(currentCell, hit.point); previousCell = currentCell; } else { previousCell = null; } }
void OnFire(object sender, object e) { SquareCell cell = null; if ((int)e == 0 && !EventSystem.current.IsPointerOverGameObject()) { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { cell = grid.GetCell(hit.point); } } if (cell != null) { ActOnCell(cell); } }