public void Init(BattleMapVO vo) { _mapWidth = vo.Width; _mapLength = vo.Length; _mapGrids = new Dictionary <int, MapGrid>(); _mapRoot = new GameObject("MapRoot"); _mapRoot.transform.position = BattleConst.MAP_ORIGIN_POS; CreateMapGrids(vo); }
private void CreateMapGrids(BattleMapVO vo) { for (int i = 0; i < vo.Grids.Count; ++i) { var gridPrefab = Resources.Load(vo.Grids[i].GroundPath) as GameObject; var mapGrid = Object.Instantiate(gridPrefab); mapGrid.transform.SetParent(_mapRoot.transform); var gridScript = mapGrid.AddComponent <MapGrid>(); gridScript.InitGrid(this, vo.Grids[i]); _mapGrids.Add(vo.Grids[i].Coord.y * _mapWidth + vo.Grids[i].Coord.x, gridScript); } }