// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Backspace)) { FinalizeController(); } // TODO Should be somewhere else ? Also useless? if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } //If the controller was not initialized we wont do any of what follows if (!_initialized) { return; } _readyToCycle = (_currentDisplayManager.timeDriven && Time.time - _lastCycleTime > _currentDisplayManager.cycleTime) || (!_currentDisplayManager.timeDriven && _currentDisplayManager.readyToCycle) || _currentDisplayManager.forceCycle; if (_readyToCycle) { //if we are on video Display and the next one is a video display too if (_currentDisplayManager is VideoDisplayManager && Preloader.instance.GetNextDisplayType() == DisplayType.VIDEO) { // Add 1 to the current index and initialize the next display Preloader.instance.SetNextDisplayIndex(); (_currentDisplayManager as VideoDisplayManager).AddNextVideo(Preloader.instance.GetRunningDisplayId()); _cyclingDisplay = false; _lastCycleTime = Time.time; } else { if (!_cyclingDisplay && !_currentDisplayManager.forceCycle) { if (_currentDisplayManager is PhotographyDisplayManager && Preloader.instance.GetNextDisplayType() == DisplayType.VIDEO) { (_currentDisplayManager as PhotographyDisplayManager).SetAuxPhoto(); } else if (_currentDisplayManager is VideoDisplayManager && Preloader.instance.GetNextDisplayType() == DisplayType.PHOTOGRAPHY) { (_currentDisplayManager as VideoDisplayManager).SetAuxPhoto(Preloader.instance.GetNextDisplayFirstPhoto()); } //Start the out animation for every avaialable display animator foreach (Animator displayAnimator in _currentDisplayManager.animators) { if (displayAnimator.gameObject.activeSelf) { displayAnimator.SetTrigger("DisplayOut"); } } _currentDisplayManager.DisplayOut(); _cyclingDisplay = true; } else { bool stillCycling = false; stillCycling = !_currentDisplayManager.DisplayOutFinished; if (!stillCycling && !_currentDisplayManager.forceCycle) { //We check in every display animator if the out animation finished foreach (Animator displayAnimator in _currentDisplayManager.animators) { if (displayAnimator.gameObject.activeSelf) { if (!displayAnimator.GetCurrentAnimatorStateInfo(0).IsName("DisplayOut")) { stillCycling = true; } else if (displayAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1f) { stillCycling = true; } } } } //For now we just call the same display in animation if (!stillCycling) { // Finalize and de activate the current display _currentDisplayManager.FinalizeDisplay(); _currentDisplayManager.gameObject.SetActive(false); // Add 1 to the current index and initialize the next display Preloader.instance.SetNextDisplayIndex(); _currentDisplayManager = GetCurrentDisplayManager(); if (_currentDisplayManager == null) { _initialized = false; return; } _currentDisplayManager.gameObject.SetActive(true); //Here we should send the right display id to retreive the right data _currentDisplayManager.InitializeDisplay(Preloader.instance.GetRunningDisplayId()); _cyclingDisplay = false; _lastCycleTime = Time.time; } } } } }