public void Update(bool pressedState, ILedFunction overrideLedFunction = null) { if (pressedState != _currentKeyState) { _currentKeyState = pressedState; onKeyStateChanged?.Invoke(_currentKeyState); } UpdateLedFunction(overrideLedFunction != null ? overrideLedFunction : ledFunction); }
private void UpdateLedFunction(ILedFunction ledFunc = null) { bool targetLedState = false; if (ledFunc != null) { targetLedState = ledFunc.GetLedState(this); } if (targetLedState != _currentLedState) { _currentLedState = targetLedState; onLedStateChanged?.Invoke(_currentLedState); } }
public void Initialize(GlowingButton button) { Teardown(); int totalButtons = GridController.grid.width * GridController.grid.height; _cellWeights = new List <int>(GridController.grid.width * GridController.grid.height); for (int i = 0; i < totalButtons; i++) { _cellWeights.Add(1); } _ledFunction = new ScreenSaverLedFunction(this); _button = button; _button.onKeyStateChanged += OnButtonStateChanged; _button.ledFunction = LedOn.instance; _overrideButton = new GlowingButton(0, 0); _overrideButton.onKeyStateChanged += OnOverrideButtonStateChanged; }