Exemplo n.º 1
0
        // Event handlers.

        private void UpdateNode(UnitPresentation unit)
        {
            if (unitSystemPresentation.Contains(unit))
            {
                var position = unitSystemPresentation[unit];
                if (unitsToNodes.TryGetValue(unit, out var node))
                {
                    node.Position = position;
                }
                else
                {
                    node = NodeController.BuildNode(map, position);
                    node.transform.parent = transform;
                    unitsToNodes[unit]    = node;
                }
            }
            else
            {
                if (unitsToNodes.TryGetValue(unit, out var node))
                {
                    Destroy(node.gameObject);
                    unitsToNodes.Remove(unit);
                }
            }
        }
Exemplo n.º 2
0
        public static NodeController BuildNode(MapController map, Vector2Int position)
        {
            GameObject     node       = Instantiate(Prefab);
            NodeController controller = node.GetComponent <NodeController>();

            controller.Map      = map;
            controller.Position = position;
            return(controller);
        }