Exemple #1
0
        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;
        }
Exemple #2
0
        public AllInteractableObjects(AllExecutableObjects executableObjects)
        {
            _interactableObjects = new List <IInteractable>();

            for (int i = 0; i < executableObjects.Count; i++)
            {
                if (executableObjects[i] is IInteractable interactable)
                {
                    _interactableObjects.Add(interactable);
                }
            }
        }
Exemple #3
0
        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;
        }
Exemple #4
0
        public EventsBridge(AllExecutableObjects listExecutableObjects)
        {
            _executableObjects = listExecutableObjects;

            for (int i = 0; i < _executableObjects.Count; i++)
            {
                var interactiveObject = _executableObjects[i];

                if (interactiveObject is BadBonus || interactiveObject is SpeedBonus)
                {
                    (interactiveObject as Bonus).OnInteraction +=
                        _executableObjects.CameraController.OnInteraction;
                }

                if (interactiveObject is KeyBonus keyBonus)
                {
                    var door = Object.FindObjectOfType <ExitDoor>();
                    keyBonus.OnInteraction += door.OpenTheDoor;
                }
            }
        }
Exemple #5
0
        public BonusCreator(AllExecutableObjects listExecutableObjects, BonusesContainer container)
        {
            IExecute bonus = null;

            for (int i = 0; i < container.BonusCount; i++)
            {
                switch (container[i].BonusType)
                {
                case BonusType.BadBonus:
                    bonus = new BadBonus(Object.Instantiate(Reference.Bonus, container[i].SpawnPoint,
                                                            Quaternion.identity));
                    ((Bonus)bonus).SetBonusType(BonusType.BadBonus);
                    break;

                case BonusType.GoodBonus:
                    bonus = new GoodBonus(Object.Instantiate(Reference.Bonus, container[i].SpawnPoint,
                                                             Quaternion.identity));
                    ((Bonus)bonus).SetBonusType(BonusType.GoodBonus);
                    break;

                case BonusType.KeyBonus:
                    bonus = new KeyBonus(Object.Instantiate(Reference.Bonus, container[i].SpawnPoint,
                                                            Quaternion.identity));
                    ((Bonus)bonus).SetBonusType(BonusType.KeyBonus);
                    break;

                case BonusType.SpeedBonus:
                    bonus = new SpeedBonus(Object.Instantiate(Reference.Bonus, container[i].SpawnPoint,
                                                              Quaternion.identity));
                    ((Bonus)bonus).SetBonusType(BonusType.SpeedBonus);
                    break;

                case BonusType.None:
                    throw new Exception("Missing Bonus Type");
                }

                listExecutableObjects.AddExecutableObject(bonus);
            }
        }
Exemple #6
0
        private void Awake()
        {
            _executableObjects = new AllExecutableObjects(_bonusesContainer);

            var bridges = new AllBridges(_executableObjects);
        }