//before all next public void DeserializeCells() { //cells List <SerializedCell> serializedCells = serializedGraph.serializedCells; foreach (var c in serializedCells) { Cell newC = new Cell(deserializer.GetArea(c.area), (Passability)c.passability, c.layer, targetGraph, c.originalEdges); newC.SetCenter(c.center); foreach (var data in c.data) { newC.TryAddData(data); } cellPool[c.id] = newC; cells.Add(newC); //Vector3 CC = c.center; //foreach (var data in c.data) { // Vector3 DC = data.centerV3; // PFDebuger.Debuger_K.AddLine(CC, DC, Color.red); // Vector3 CCDC = SomeMath.MidPoint(CC, DC); // PFDebuger.Debuger_K.AddLine(CCDC, data.rightV3, Color.blue); // PFDebuger.Debuger_K.AddLine(CCDC, data.leftV3, Color.cyan); //} } //map var serializedCellMap = serializedGraph.cellMapData; List <Cell>[][] cellMap = new List <Cell> [PathFinder.CELL_GRID_SIZE][]; for (int x = 0; x < PathFinder.CELL_GRID_SIZE; x++) { cellMap[x] = new List <Cell> [PathFinder.CELL_GRID_SIZE]; for (int z = 0; z < PathFinder.CELL_GRID_SIZE; z++) { cellMap[x][z] = new List <Cell>(); } } foreach (var data in serializedCellMap) { cellMap[data.x][data.y].Add(cellPool[data.z]); } //contour var serializedContour = serializedGraph.contour; Dictionary <CellContentData, Cell> contour = new Dictionary <CellContentData, Cell>(); foreach (var c in serializedContour) { contour.Add(new CellContentData(c.a, c.b), cellPool[c.cell]); } targetGraph.SetBunchOfData(cells, cellMap, contour); //borders var serializedBorderData = serializedGraph.borderData; if (serializedBorderData != null) { foreach (var bd in serializedBorderData) { targetGraph.SetEdgeSide(new CellContentData(bd.a, bd.b), (Directions)bd.direction, cellPool[bd.cell]); } } //debug //Debug.Log(cells.Count); //string s = ""; //for (int x = 0; x < cellMap.Length; x++) { // for (int z = 0; z < cellMap[x].Length; z++) { // s += cellMap[x][z].Count; // } // s += "\n"; //} //Debug.Log(s); //Debug.Log(contour.Count); }
//before all next public void DeserializeCells() { //cells List <SerializedCell> serializedCells = serializedGraph.serializedCells; foreach (var curSerializedCell in serializedCells) { Area cellArea; if (curSerializedCell.isAdvancedAreaCell) { GameObject targetGO = deserializer.GetGameObject(curSerializedCell.area); if (targetGO == null) { Debug.LogWarning("Deserializer cant find GameObject so Cell area became default area"); cellArea = PathFinder.settings.getDefaultArea; } else { AreaWorldMod areaWorldMod = targetGO.GetComponent <AreaWorldMod>(); if (areaWorldMod == null) { Debug.LogWarning("Deserializer cant find AreaModifyer on gameObject so Cell area became default area"); cellArea = PathFinder.settings.getDefaultArea; } else { if (areaWorldMod.useAdvancedArea == false) { Debug.LogWarning("Area Modifyer don't use advanced area so Cell area became default area"); cellArea = PathFinder.settings.getDefaultArea; } else { cellArea = areaWorldMod.advancedArea; } } } } else { cellArea = deserializer.GetArea(curSerializedCell.area); } Cell newC = new Cell(cellArea, (Passability)curSerializedCell.passability, curSerializedCell.layer, targetGraph, curSerializedCell.originalEdges); newC.SetCenter(curSerializedCell.center); foreach (var data in curSerializedCell.data) { newC.TryAddData(data); } cellPool[curSerializedCell.id] = newC; cells.Add(newC); //Vector3 CC = c.center; //foreach (var data in c.data) { // Vector3 DC = data.centerV3; // PFDebuger.Debuger_K.AddLine(CC, DC, Color.red); // Vector3 CCDC = SomeMath.MidPoint(CC, DC); // PFDebuger.Debuger_K.AddLine(CCDC, data.rightV3, Color.blue); // PFDebuger.Debuger_K.AddLine(CCDC, data.leftV3, Color.cyan); //} } //map var serializedCellMap = serializedGraph.cellMapData; List <Cell>[][] cellMap = new List <Cell> [PathFinder.CELL_GRID_SIZE][]; for (int x = 0; x < PathFinder.CELL_GRID_SIZE; x++) { cellMap[x] = new List <Cell> [PathFinder.CELL_GRID_SIZE]; for (int z = 0; z < PathFinder.CELL_GRID_SIZE; z++) { cellMap[x][z] = new List <Cell>(); } } foreach (var data in serializedCellMap) { cellMap[data.x][data.y].Add(cellPool[data.z]); } //contour var serializedContour = serializedGraph.contour; Dictionary <CellContentData, Cell> contour = new Dictionary <CellContentData, Cell>(); foreach (var c in serializedContour) { contour.Add(new CellContentData(c.a, c.b), cellPool[c.cell]); } targetGraph.SetBunchOfData(cells, cellMap, contour); //borders var serializedBorderData = serializedGraph.borderData; if (serializedBorderData != null) { foreach (var bd in serializedBorderData) { targetGraph.SetEdgeSide(new CellContentData(bd.a, bd.b), (Directions)bd.direction, cellPool[bd.cell]); } } //debug //Debug.Log(cells.Count); //string s = ""; //for (int x = 0; x < cellMap.Length; x++) { // for (int z = 0; z < cellMap[x].Length; z++) { // s += cellMap[x][z].Count; // } // s += "\n"; //} //Debug.Log(s); //Debug.Log(contour.Count); }