Ejemplo n.º 1
0
        public override void Update()
        {
            base.Update();

            if (transitionProgress == -1f && controllerOnScreen == null)
            {
                // no transition is ongoing.
                // if only nextController is defined, move it into controllerOnScreen.
                controllerOnScreen = nextController;
                nextController     = null;
            }
        }
        public override void Awake(Scene scene)
        {
            base.Awake(scene);

            renderer.Track(this);

            if (!SeekerBarrierColorController.HasControllerOnNextScreen() && scene.Entities.ToAdd.OfType <SeekerBarrierColorController>().Count() == 0)
            {
                // there is no seeker barrier color controller and we're not already adding one :pensive:
                // we need one, because that's the one tweaking the barriers.
                scene.Add(new SeekerBarrierColorController(new EntityData(), Vector2.Zero));
            }
        }
Ejemplo n.º 3
0
        public override void SceneEnd(Scene scene)
        {
            base.SceneEnd(scene);

            // leaving level: forget about all controllers and clean up the hooks if present.
            controllerOnScreen = null;
            nextController     = null;
            if (seekerBarrierRendererHooked)
            {
                unhookSeekerBarrierRenderer();
                seekerBarrierRendererHooked = false;
            }
            ;
        }
Ejemplo n.º 4
0
        public override void Added(Scene scene)
        {
            base.Added(scene);

            // this is the controller for the next screen.
            nextController = this;

            // enable the hooks on barrier rendering.
            if (!seekerBarrierRendererHooked)
            {
                hookSeekerBarrierRenderer();
                seekerBarrierRendererHooked = true;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a value from the active seeker barrier color controller(s), using the given getter, and the lerp function if we are transitioning
        /// between rooms. defaultValue is used when going from/to a room with no controller.
        /// </summary>
        private static T getAndLerp <T>(Func <SeekerBarrierColorController, T> valueGetter, T defaultValue, Func <T, T, float, T> lerp)
        {
            if (transitionProgress == -1f)
            {
                if (controllerOnScreen == null)
                {
                    // no transition is ongoing.
                    // if only nextController is defined, move it into controllerOnScreen.
                    controllerOnScreen = nextController;
                    nextController     = null;
                }

                if (controllerOnScreen != null)
                {
                    return(valueGetter(controllerOnScreen));
                }
                else
                {
                    return(defaultValue);
                }
            }
            else
            {
                // get the value in the room we're coming from.
                T fromRoomValue;
                if (controllerOnScreen != null)
                {
                    fromRoomValue = valueGetter(controllerOnScreen);
                }
                else
                {
                    fromRoomValue = defaultValue;
                }

                // get the value in the room we're going to.
                T toRoomValue;
                if (nextController != null)
                {
                    toRoomValue = valueGetter(nextController);
                }
                else
                {
                    toRoomValue = defaultValue;
                }

                // transition smoothly between both.
                return(lerp(fromRoomValue, toRoomValue, transitionProgress));
            }
        }
Ejemplo n.º 6
0
        public override void Removed(Scene scene)
        {
            base.Removed(scene);

            // the "current" color controller is now the one from the next screen.
            controllerOnScreen = nextController;
            nextController     = null;

            // the transition (if any) is over.
            transitionProgress = -1f;

            // if there is none, clean up the hooks.
            if (controllerOnScreen == null && seekerBarrierRendererHooked)
            {
                unhookSeekerBarrierRenderer();
                seekerBarrierRendererHooked = false;
            }
        }