Exemple #1
0
    //
    // Public Methods
    //

    public void Init(GridData grid, PlanningOutput planningOutput)
    {
        this.grid           = grid;
        this.planningOutput = planningOutput;

        // Find Components
        map = ComponentManager.Instance.Get <MapController>();
        var canvas = GameObject.FindWithTag("Canvas").GetComponent <Canvas>();

        // Create pin container (inside map)
        pinContainer = new GameObject("PinContainer").transform;
        pinContainer.SetParent(map.transform, false);

        // Create flag container (inside UI canvas)
        flagContainer      = Instantiate(flagContainerPrefab, canvas.transform, false);
        flagContainer.name = flagContainerPrefab.name;
        flagContainer.transform.SetSiblingIndex(0);

        // Create summary flag container (inside UI canvas)
        summaryflagContainer      = Instantiate(flagContainerPrefab, canvas.transform, false);
        summaryflagContainer.name = "Summary" + flagContainerPrefab.name;
        summaryflagContainer.transform.SetSiblingIndex(0);

        // Create summary pin/flag
        summaryPanelFlag = Instantiate(summaryPanelPrefab, summaryflagContainer, false);
        summaryPanelFlag.Init("SummaryPanelFlag", grid, 3);
        summaryPanelFlag.SetPlanningOutput(planningOutput);
        summaryPanelFlag.gameObject.SetActive(showFlags);
        summaryPin = Instantiate(summaryPinPrefab, pinContainer, true);
        summaryPin.Init(Coordinate.Zero, groupPins, summaryPanelFlag);

        // Attach to events
        map.OnMapUpdate += OnMapUpdate;
    }
Exemple #2
0
    private GroupPin AddGroupPin(PlanningGroup group)
    {
        // Create summary panel
        SummaryPanel groupSummary = Instantiate(summaryPanelPrefab, flagContainer, false);

        groupSummary.SetPlanningOutput(planningOutput);
        groupSummaries.Add(groupSummary);
        groupSummary.Init(summaryPanelPrefab.name, grid, 2);
        groupSummary.gameObject.SetActive(showFlags);

        // Create pin
        var groupPin = Instantiate(groupPinPrefab, pinContainer, true);

        groupPin.name = "Group_" + group.id;
        groupPin.Init(group, groupSummary);
        groupPin.globalCount = planningGroups.Count;
        groupPin.UpdatePosition(map);
        groupPins.Add(groupPin);

        return(groupPin);
    }