public IntegrationField CreateIntegrationField(List <Tile> tiles, List <int> sectors, WorldArea area) { IntegrationField integrationField = new IntegrationField(); integrationField.AddFields(sectors, WorldData.MultiLevelSectorManager.GetSectorWidthAtLevel(area, 0) * WorldData.MultiLevelSectorManager.GetSectorHeightAtLevel(area, 0), tiles, area); return(integrationField); }
private void DrawIntegrationField(IntegrationField integrationField) { if (_integrationFieldHolder != null) { Destroy(_integrationFieldHolder); } GameObject integrationTile = Resources.Load("Prefab/IntegrationTile") as GameObject; if (worldData.Pathfinder.showIntegrationField) { _integrationFieldHolder = new GameObject(); for (int x = 0; x < worldData.WorldAreas.Count; x++) { for (int i = 0; i < worldData.WorldAreas[x].SectorGrid[0].Length; i++) { if (integrationField.Field.ContainsKey(new IntVector2(x, i))) { MultiLevelSector sector = worldData.WorldAreas[x].SectorGrid[0][i]; Vector2 sectorPos = new Vector2(sector.Left, sector.Top); for (int j = 0; j < sector.TilesInWidth * sector.TilesInHeight; j++) { int y = Mathf.FloorToInt((float)j / sector.TilesInWidth); Vector2 node = sectorPos + new Vector2(j - (sector.TilesInWidth * y), y); if (worldData.WorldAreas[x].TileGrid[(int)node.x][(int)node.y] != null) { GameObject b = Instantiate(integrationTile, worldData.TileManager.GetTileWorldPosition( worldData.WorldAreas[x].TileGrid[(int)node.x][(int)node.y], worldData.WorldAreas[x]), Quaternion.identity); int value = integrationField.Field[new IntVector2(x, i)][j]; if (value * 3 >= worldData.ColorLists.PathCostColors.Length - 2) { b.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material.color = worldData.ColorLists.PathCostColors[ worldData.ColorLists.PathCostColors.Length - 2]; } else { if (value < worldData.ColorLists.PathCostColors.Length - 2) { b.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material .color = worldData.ColorLists.PathCostColors[value * 3]; } } b.transform.position += Vector3.up * 0.15f; b.transform.parent = _integrationFieldHolder.transform; b.transform.localScale = new Vector3(worldData.Pathfinder.tileSize, worldData.Pathfinder.tileSize, worldData.Pathfinder.tileSize); } } } } } } }