Ejemplo n.º 1
0
        private void OnDestroy()
        {
            MapDependencyContainer.UnregisterSingleton <IMapController>(this);

            _nodeManager.OnNodeClicked  -= OnClicked;
            _nodeManager.OnNodeSelected -= OnSelected;
        }
Ejemplo n.º 2
0
        private async void Awake()
        {
            var initTaskCompletion = new TaskCompletionSource <bool>();

            _initTask = initTaskCompletion.Task;

            if (node == null)
            {
                Debug.LogError($"{nameof(MapNodeBase)} not set in {nameof(NodeEffectsManager)} {name}!");
                initTaskCompletion.SetResult(true);
                return;
            }

            node.OnStateChanged += OnNodeStateChanged;

            // Get the WorldMap, async in case it's Awake runs after this, or it's loaded at runtime
            const float mapControllerTimeout = 0.2f; // Arbitrary short time, just to give MapController a chance to load

            _mapController = await MapDependencyContainer.ResolveAsync <IMapController>(mapControllerTimeout);

            if (_mapController == null)
            {
                initTaskCompletion.SetResult(false);
                return;
            }

            _mapController.OnZoomed      += OnZoomedIn;
            _mapController.OnNodeClicked += OnNodeClicked;
            initTaskCompletion.SetResult(true);
        }
Ejemplo n.º 3
0
        private void Awake()
        {
            MapDependencyContainer.RegisterSingleton <IMapController>(this);

            _nodeManager = GetComponentInChildren <INodeManager>();
            if (_nodeManager == null)
            {
                Debug.LogError($"NodeManager Component required for {GetType().Name}! [On GameObject {name} or it's children]");
                return;
            }
            _inputDelegate.Init(this, _nodeManager);

            _nodeManager.OnNodeClicked  += OnClicked;
            _nodeManager.OnNodeSelected += OnSelected;

            Bind();
        }