Exemplo n.º 1
0
        public void Initialize(ILiftManager manager)
        {
            foreach (var floor in manager.Floors)
            {
                var controller = Instantiate(floorPrefab, root);
                controller.Floor = floor;

                var selection = controller.GetComponent <FloorSelection>();
                if (selection == null)
                {
                    continue;
                }

                selection.OnFloorFocusStateChanged += FloorFocusStateChanged;
                if (selection.Floor != manager.CurrentFloor)
                {
                    continue;
                }

                _selected          = selection;
                _selected.Selected = true;
            }

            OnFloorSelected?.Invoke(_selected != null ? _selected.Floor : manager.CurrentFloor);
        }
Exemplo n.º 2
0
        private void FloorFocusStateChanged(FloorSelection selection)
        {
            if (selection.Selected && _selected != selection)
            {
                _selected.Selected = false;
                _selected          = selection;
            }

            if (selection.Focused)
            {
                _focused = selection;
            }
            else if (_focused == selection)
            {
                _focused = null;
            }

            OnFloorSelected?.Invoke(_focused != null ? _focused.Floor : _selected.Floor);
        }