public void UpdateFinalGrids() { this.finalGrids = grids.InitArrays(Height(), Width()); for (int i = 0; i < grids.Length; i++) { for (int j = 0; j < grids[0].Length; j++) { int gridType = grids[i][j]; int projectGridType = projectGrids[i][j]; if (projectGridType == 0) //没有project_grid_type,则用grid_type { finalGrids[i][j] = gridType; } else { int field = AStarUtil.GetField(gridType); //用grid_type的field int terrainType = AStarUtil.GetTerrainType(projectGridType) != 0 ? AStarUtil.GetTerrainType(projectGridType) : AStarUtil.GetTerrainType(gridType); //覆盖关系 int obstacleType = AStarUtil.GetObstacleType(projectGridType) != 0 ? AStarUtil.GetObstacleType(projectGridType) : AStarUtil.GetObstacleType(gridType); //覆盖关系 finalGrids[i][j] = AStarUtil.ToGridType(field, terrainType, obstacleType); } } } }
public int GetDataValue(int xWithOffset, int yWithOffset) { Vector2Int point = new Vector2Int(xWithOffset, yWithOffset); if (dataDict.ContainsKey(point)) { return(dataDict[point]); } return(AStarUtil.ToGridType(0, 0, 0)); }
void HandleEvent() { if (e.control && (e.type == EventType.MouseDown || e.type == EventType.MouseDrag) && e.button == 0) //press { if (!_target.astarConfigData.IsInRange(mouseGridX, mouseGridY) && !_target.astarConfigData.isEnableEditOutsideBounds) { return; } int orgValue = _target.astarConfigData.GetDataValue(mouseGridX, mouseGridY); int obstacleType = AStarUtil.GetObstacleType(orgValue); int terrainType = AStarUtil.GetTerrainType(orgValue); if (isSeeObstacleType) { obstacleType = this.selectedObstacleType.value; } if (isSeeTerrainType) { terrainType = this.selectedTerrainType.value; } int value = AStarUtil.ToGridType(0, terrainType, obstacleType); _brush.DoPaintPressed(mouseGridX, mouseGridY, value); } }
public static void Test_ToGridType() { LogCat.log(AStarUtil.GetObstacleType(AStarUtil.ToGridType(1, 1, 2))); }