public UIBridge(AllExecutableObjects listExecutableObjects) { _displayHealth = Object.FindObjectOfType <DisplayHealth>(); _displayKey = Object.FindObjectOfType <DisplayKey>(); _displayWin = Object.FindObjectOfType <DisplayWin>(); _executableObjects = listExecutableObjects; for (int i = 0; i < _executableObjects.Count; i++) { var interactiveObject = _executableObjects[i]; switch (interactiveObject) { case HealthBonus healthBonus: healthBonus.OnInteraction += _displayHealth.HealOrDamage; break; case KeyBonus keyBonus: keyBonus.OnInteraction += _displayKey.ShowKey; break; } } _exitDoor = Object.FindObjectOfType <ExitDoor>(); _exitDoor.OnEnter += _displayWin.ShowWin; }
public DataBridge(AllExecutableObjects executableObjects, DisplayHealth healthBar) { _savedData = Object.FindObjectOfType <SaveDataButton>(); _loadedData = Object.FindObjectOfType <LoadDataButton>(); _dataRepository = new DataRepository(); _allInteractableObjects = new AllInteractableObjects(executableObjects); _listInteractableObjects = _allInteractableObjects.InteractableObjects; _savedData.ButtonAction += SaveBonusesData; _savedData.ButtonAction += healthBar.RememberHealth; _savedData.ButtonAction += _loadedData.SetButtonActive; _loadedData.ButtonAction += LoadBonusesData; }