private void CopyWalkableData(int range, CStarGrid grid, Vector2Int center) { int startCol = center.x - range; int startRow = center.y - range; for (int c = 0; c < m_grid.NumCols; c++) { for (int r = 0; r < m_grid.NumRows; r++) { bool w = grid.IsWalkable(startCol + c, startRow + r); m_grid.SetWalkable(c, r, w); } } }
public static void PrintGird(CStarGrid gird) { string str = ""; for (int row = gird.NumRows - 1; row >= 0; row--) { for (int col = 0; col < gird.NumCols; col++) { bool node = gird.IsWalkable(col, row); int v = node ? 1 : 0; str = string.Format("{0},{1}", str, v); } str += "\n"; } Debug.Log(str); }
private void CoroutineBuild() { for (int row = 0; row < m_grid.NumRows; row++) { for (int col = 0; col < m_grid.NumCols; col++) { bool walkable = m_grid.IsWalkable(col, row); if (!walkable) { continue; } var pos = CMapUtil.GetTileCenterPosByColRow(col, row); pos.y = GameConst.DEFAULT_TERRAIN_HEIGHT + 0.05f; LoadAndCreateTile(pos); } } }
public ActorGeneraterPlaceholder(CStarGrid walkGrid) { m_numRows = walkGrid.NumRows; m_numCols = walkGrid.NumCols; for (int row = 0; row < m_numRows; ++row) { for (int col = 0; col < m_numCols; ++col) { //这里存储不可通行的位置 bool w = walkGrid.IsWalkable(col, row); if (w) { continue; } int key = GetKey(col, row); m_unitRangeDict[key] = true; m_unitPosDict[key] = true; } } }
public static void DrawGrid(CStarGrid gird) { var parent = new GameObject("map cube"); var t = parent.transform; t.localPosition = Vector3.zero; for (int row = gird.NumRows - 1; row >= 0; row--) { for (int col = 0; col < gird.NumCols; col++) { bool node = gird.IsWalkable(col, row); if (!node) { continue; } var go = GameObject.CreatePrimitive(PrimitiveType.Cube); go.transform.localPosition = new Vector3(col, 0, row); go.transform.SetParent(t, true); } } }