Exemplo n.º 1
0
        /// <summary>
        /// Execute the specified notification.
        /// </summary>
        /// <param name="notification">Notification.</param>
        public override void Execute(INotification notification)
        {
            DebugLogger.Log("CoreRequestBlackoutCommand::Execute");

            RequestBlackoutVO requestBlackoutVO = notification.Body as RequestBlackoutVO;

            // Get the data proxy to check blackoutstatus
            coreDataProxy = Facade.RetrieveProxy(CoreDataProxy.NAME) as CoreDataProxy;

            if (coreDataProxy.BlackoutStatus != BlackoutStatus.NONE)
            {
                return;
            }

            // First see if blackout canvas already exists in scene
            if (!GameObject.Find("BlackoutCanvas"))
            {
                // Create a canvas to fade to black
                GameObject fadeCanvas = new GameObject("BlackoutCanvas");
                GameObject.DontDestroyOnLoad(fadeCanvas);
                fadeCanvas.AddComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
                canvasGroup = fadeCanvas.AddComponent <CanvasGroup>();

                // Create an image component as child of fadeCanvas
                GameObject image = new GameObject("Image");
                image.transform.SetParent(fadeCanvas.transform);
                Image imageComponent = image.AddComponent <Image>();
                imageComponent.color = Color.black;
                RectTransform rectTransform = image.GetComponent <RectTransform>();
                rectTransform.anchorMin = new Vector2(0, 0);
                rectTransform.anchorMax = new Vector2(1, 1);
                rectTransform.offsetMin = new Vector2(0, 0);
                rectTransform.offsetMax = new Vector2(0, 0);
            }
            else
            {
                canvasGroup = GameObject.Find("BlackoutCanvas").GetComponent <CanvasGroup>();
            }

            // Request a coroutine to fade in blackout canvas
            RequestStartCoroutineVO requestStartCoroutineVO = new RequestStartCoroutineVO();

            // Check fade direction
            if (requestBlackoutVO.fadeDirection == FadeDirection.IN)
            {
                coreDataProxy.BlackoutStatus = BlackoutStatus.IN;

                requestStartCoroutineVO.coroutine = DoFadeIn(requestBlackoutVO.delay, requestBlackoutVO.callback, requestBlackoutVO.auto);
            }
            else
            {
                coreDataProxy.BlackoutStatus = BlackoutStatus.OUT;

                SendNotification(CoreNote.REQUEST_STOP_COROUTINE, DoFadeIn());

                requestStartCoroutineVO.coroutine = DoFadeOut(requestBlackoutVO.delay, requestBlackoutVO.callback);
            }

            SendNotification(CoreNote.REQUEST_START_COROUTINE, requestStartCoroutineVO);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prepare view command.
        /// </summary>
        public override void Execute(INotification notification)
        {
            DebugLogger.Log("CoreReadyCommand::Execute");

            // Retrieve data proxy
            CoreDataProxy coreDataProxy = (Facade.RetrieveProxy(CoreDataProxy.NAME) as CoreDataProxy);

            // Load Default environment
            SendNotification(CoreNote.REQUEST_LOAD_ENVIRONMENT, coreDataProxy.DefaultEnvironment);

            // Notify any subscribers that the application is ready
            SendNotification(CoreNote.READY);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Execute the specified notification.
        /// </summary>
        /// <param name="notification">Notification.</param>
        public override void Execute(INotification notification)
        {
            DebugLogger.Log("LoadEnvironmentCommand::Execute -> " + notification.Body.ToString());

            coreDataProxy = (Facade.RetrieveProxy(CoreDataProxy.NAME) as CoreDataProxy);

            currentScene = SceneManager.GetSceneByName(coreDataProxy.CurrentEnvironment);

            DebugLogger.Log("Current loaded Scene : " + currentScene.name);

            sceneName = notification.Body.ToString();

            if (currentScene.name != sceneName && SceneUtility.GetBuildIndexByScenePath(sceneName) >= 0)
            {
                LoadEnvironment();
            }
            else if (currentScene.name == sceneName && SceneUtility.GetBuildIndexByScenePath(sceneName) >= 0)
            {
                SendNotification(CoreNote.ENVIRONMENT_LOADED, sceneName);
            }
        }
        /// <summary>
        /// Reset the the application.
        ///
        /// Currently we just load the default environment
        /// This command will likely grow as the application does
        /// </summary>
        /// <param name="notification">Notification.</param>
        public override void Execute(INotification notification)
        {
            CoreDataProxy data = (CoreDataProxy)Facade.RetrieveProxy(CoreDataProxy.NAME);

            SendNotification(CoreNote.REQUEST_LOAD_ENVIRONMENT, data.DefaultEnvironment);
        }
 /// <summary>
 /// On register.
 /// </summary>
 public override void OnRegister()
 {
     coreDataProxy = Facade.RetrieveProxy(CoreDataProxy.NAME) as CoreDataProxy;
 }