Ejemplo n.º 1
0
    void UpdateSelection()
    {
        for (int i = 0, len = conveyorButtons.Count; i < len; ++i)
        {
            conveyorButtons[i].Recycle();
        }
        conveyorButtons.Clear();
        if (selectionHighlighter)
        {
            selectionHighlighter.Recycle();
            selectionHighlighter = null;
        }

        if (selectionState.isSelected)
        {
            selectionHighlighter = ObjectPooler.instance.Get <SelectionHighlighter>();
            selectionHighlighter.Initialize(selectionState.bounds);
            if (TouchInput.inputMode == InputMode.Touch)
            {
                foreach ((Vector3Int outerTile, Vector3Int innerTile) in selectionState.bounds.EnumeratePerimeter())
                {
                    if (ConveyorSystem.instance.CanLink(innerTile, outerTile))
                    {
                        UILinkConveyorButton conveyorButton = ObjectPooler.instance.Get <UILinkConveyorButton>();
                        conveyorButton.position       = outerTile;
                        conveyorButton.sourcePosition = innerTile;
                        conveyorButton.transform.SetParent(canvas.transform, false);
                        conveyorButton.Initialize();
                        conveyorButtons.Add(conveyorButton);
                    }
                }
            }
        }
        Events.TileSelectionChanged?.Invoke(selectionState);
    }
Ejemplo n.º 2
0
    public void Visualize(MachineInfo machineInfo, Vector3 center)
    {
        if (machineInfo != this.machineInfo)
        {
            this.machineInfo = machineInfo;
            if (instance)
            {
                Destroy(instance.gameObject);
            }
            InitializeHologram();
        }

        Bounds3Int bounds = center.PositionBottomToBounds(machineInfo.size);

        this.bounds = bounds;
        instance.transform.localPosition = bounds.min;
        selectionHighlighter.Initialize(bounds);
    }