Exemple #1
0
 public void Release()
 {
     if (this.mCheckGrids != null)
     {
         for (int index = 0; index < this.mCheckGrids.Length; ++index)
         {
             this.mCheckGrids[index] = (Grid)null;
         }
         this.mCheckGrids = (Grid[])null;
     }
     if (this.mMoveRoutes != null)
     {
         this.mMoveRoutes.Clear();
         this.mMoveRoutes = (List <Grid>)null;
     }
     this.mMoveStep = 0;
     if (this.mRoot != null)
     {
         this.mRoot.Release();
         this.mRoot = (BattleMapRoot)null;
     }
     if (this.mGrid == null)
     {
         return;
     }
     for (int index1 = 0; index1 < this.mHeight; ++index1)
     {
         for (int index2 = 0; index2 < this.mWidth; ++index2)
         {
             this.mGrid[index2, index1] = (Grid)null;
         }
     }
     this.mGrid = (Grid[, ])null;
 }
Exemple #2
0
        public bool Deserialize(JSON_Map src)
        {
            this.mWidth  = src.w;
            this.mHeight = src.h;
            if (src.grid.Length != this.mWidth * this.mHeight)
            {
                throw new Exception("Grid size does not match width x height");
            }
            this.mGrid = new Grid[this.mWidth, this.mHeight];
            for (int index1 = 0; index1 < this.mHeight; ++index1)
            {
                for (int index2 = 0; index2 < this.mWidth; ++index2)
                {
                    Grid         grid        = new Grid();
                    JSON_MapGrid jsonMapGrid = src.grid[index2 + index1 * this.mWidth];
                    grid.x      = index2;
                    grid.y      = index1;
                    grid.height = jsonMapGrid.h;
                    grid.tile   = jsonMapGrid.tile;
                    grid.geo    = MonoSingleton <GameManager> .Instance.GetGeoParam(jsonMapGrid.tile);

                    grid.cost = grid.geo == null ? 1 : (int)grid.geo.cost;
                    this.mGrid[index2, index1] = grid;
                }
            }
            this.mRoot = new BattleMapRoot();
            this.mRoot.Initialize(this.mWidth, this.mHeight, this.mGrid);
            this.ResetMoveRoutes();
            return(true);
        }