Ejemplo n.º 1
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 void DrawDataDict()
 {
     for (int gridY = _target.astarConfigData.minGridY; gridY <= _target.astarConfigData.maxGridY; gridY++)
     {
         for (int gridX = _target.astarConfigData.minGridX;
              gridX <= _target.astarConfigData.maxGridX;
              gridX++)
         {
             int value        = _target.astarConfigData.GetDataValue(gridX, gridY);
             int obstacleType = AStarUtil.GetObstacleType(value);
             int terrainType  = AStarUtil.GetTerrainType(value);
             //draw obstacleType
             if (this.isSeeObstacleType && obstacleType == AStarConst.Default_Obstacle_Type_Value)
             {
                 AStarEditorUtil.DrawObstacleTypeRect(_target, gridX, gridY, obstacleType);
             }
             // draw terrainType
             if (this.isSeeTerrainType && obstacleType == AStarConst.Default_Terrain_Type_Value)
             {
                 AStarEditorUtil.DrawdTerrainTypeRect(_target, gridX, gridY, terrainType);
             }
         }
     }
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
 public static void Test_GetObstacleType()
 {
     LogCat.log(AStarUtil.GetObstacleType(2));
 }
Ejemplo n.º 5
0
 public static void Test_ToGridType()
 {
     LogCat.log(AStarUtil.GetObstacleType(AStarUtil.ToGridType(1, 1, 2)));
 }