Beispiel #1
0
    private void FinishCreateAreaInspector()
    {
        if (lassoTool != null)
        {
            lassoTool.Deactivate();
            lassoTool.CanDraw = false;
            lassoTool.OnDraw -= OnDrawArea;
            //lassoTool.OnCancel -= OnLineToolCancel;

            Destroy(lassoTool.gameObject);
            lassoTool = null;
        }
    }
Beispiel #2
0
    private void FinishTurnOn(GridLayerController gridLayerController)
    {
        var mapLayers = gridLayerController.mapLayers;

        // For now, just get any grid
        var referenceGridData = mapLayers[0].Grid;

        HideMessage();

        // Create the planning grid
        var grid = new GridData
        {
            countX = referenceGridData.countX,
            countY = referenceGridData.countY
        };

        grid.ChangeBounds(referenceGridData.west, referenceGridData.east, referenceGridData.north, referenceGridData.south);
        grid.InitGridValues(false);

        // Build the planning categories list
        int index = 0;
        List <IntCategory> cats = new List <IntCategory>
        {
            new IntCategory()
            {
                color = new Color(0, 0, 0, 0.2f), name = "noData", value = index++
            },
            new IntCategory()
            {
                color = Color.black, name = "empty", value = index++
            }
        };

        for (int i = 0; i < typologies.Count; ++i)
        {
            cats.Add(new IntCategory()
            {
                color = typologies[i].color,
                name  = typologies[i].name,
                value = index++
            });
        }
        grid.categories = cats.ToArray();

        // Create planning layer
        planningLayer      = Instantiate(planningLayerPrefab);
        planningLayer.name = planningLayerPrefab.name;
        planningLayer.SetCellSize(0.25f);

        // Add planning layer to tool layers
        toolLayers.Add(planningLayer, grid, "PlanningLayer", Color.white);

        var cellGroupGrid = new GridData
        {
            countX = grid.countX,
            countY = grid.countY
        };

        cellGroupGrid.ChangeBounds(grid.west, grid.east, grid.north, grid.south);
        cellGroupGrid.InitGridValues(false);

        // Create planner
        planner      = Instantiate(plannerPrefab);
        planner.name = plannerPrefab.name;
        planner.Init(typologyLibrary, planningLayer.Grid, typologies);

        // set output after initialization
        planner.SetOutput(gameObject.activeInHierarchy);

        // Select the first typology in the list (only if none selected)
        if (!typologyGroup.AnyTogglesOn() && typologies.Count > 0)
        {
            typologyGroup.transform.GetChild(0).GetComponent <TypologyToggleWithText>().toggle.isOn = true;
        }

        // Tools
        lassoTool      = Instantiate(lassoToolPrefab);
        lassoTool.name = lassoToolPrefab.name;
        lassoTool.Deactivate();
        brushTool      = Instantiate(brushToolPrefab);
        brushTool.name = brushToolPrefab.name;
        brushTool.Deactivate();

        // Setup tool callbacks
        index = 0;
        var tools = toolsGroup.GetComponentsInChildren <Toggle>();

        foreach (var tool in tools)
        {
            int id = index++;
            tool.onValueChanged.AddListener((isOn) => OnToolChange(isOn, id));
        }

        typologyGroup.gameObject.SetActive(true);

        ToggleSiteSpecificTypologies();
    }