Exemplo n.º 1
0
    /// <summary>
    /// Sets the transition to the specified state, using ScreenShaderTransition.TransitionState.VALUE
    /// </summary>
    /// <param name="newState">New state.</param>
    public void SetTransitionState(TransitionState newState)
    {
        transitionState = newState;

        switch (newState)
        {
        case TransitionState.FADE_IN:
            curFade = 1;
            m_transitionInProgress = true;
            break;

        case TransitionState.ON:
            curFade = 1;
            m_transitionInProgress = false;
            break;

        case TransitionState.FADE_OUT:
            curFade = 0;
            m_transitionInProgress = true;
            break;

        case TransitionState.OFF:
            curFade = 0;
            m_transitionInProgress = false;
            break;
        }
    }
Exemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            switch (State)
            {
            case TransitionState.Out:
                _currentSeconds += elapsedSeconds;

                if (_currentSeconds >= _halfDuration)
                {
                    State = TransitionState.In;
                    StateChanged?.Invoke(this, EventArgs.Empty);
                }
                break;

            case TransitionState.In:
                _currentSeconds -= elapsedSeconds;

                if (_currentSeconds <= 0.0f)
                {
                    Completed?.Invoke(this, EventArgs.Empty);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 3
0
    private void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
        MovementSM = new StateMachine();

        Standing   = new StandingState(this, MovementSM);
        Fly        = new FlyState(this, MovementSM);
        Swing      = new SwingState(this, MovementSM);
        Create     = new CreateState(this, MovementSM);
        Transition = new TransitionState(this, MovementSM);

        ActivCube = CubePrefabs[0];
        MovementSM.Initialize(Create);


        Platform  = GameObject.FindGameObjectWithTag("Platform");
        LastBlock = Platform;
    }
        public void ShouldExitTimeout()
        {
            var cut = RenderComponent <Component.Transition>(parameters =>
                                                             parameters
                                                             .Add(c => c.In, true)
                                                             .Add(c => c.Timeout, 100)
                                                             .Add(c => c.ChildContent, (RenderFragment <ITransitionContext>)((context) => (__builder) =>
            {
                __builder.OpenElement(1, "div");
                __builder.CloseElement();
            }))
                                                             );

            IElement div = cut.Find("div");

            TransitionState state = cut.Instance.Current;

            Assert.Equal(TransitionState.Entered, state);

            Assert.NotNull(div);

            bool onExitCalled = false;

            bool onExitingCalled = false;

            bool onExitedCalled = false;

            List <string> ordereds = new List <string>();

            cut.SetParametersAndRender(parameters => parameters
                                       .Add(c => c.In, false)
                                       .Add(c => c.OnExit, (f) => {
                onExitCalled = true;
                ordereds.Add("OnExit");
            })
                                       .Add(c => c.OnExiting, (f) => {
                onExitingCalled = true;
                ordereds.Add("OnExiting");
            })
                                       .Add(c => c.OnExited, (f) => {
                onExitedCalled = true;
                ordereds.Add("OnExited");
            })
                                       );

            cut.WaitForState(() => onExitedCalled, TimeSpan.FromMilliseconds(311));

            Assert.True(onExitCalled);
            Assert.True(onExitingCalled);
            Assert.True(onExitedCalled);

            Assert.Equal(3, ordereds.Count);
            Assert.Equal("OnExit", ordereds[0]);
            Assert.Equal("OnExiting", ordereds[1]);
            Assert.Equal("OnExited", ordereds[2]);

            TransitionState newstate = cut.Instance.Current;

            Assert.Equal(TransitionState.Exited, newstate);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates any transition logic of the current transition.
        /// </summary>
        /// <param name="state">The current transition state.</param>
        public void updateTransitions(TransitionState state)
        {
            switch (state)
            {
            case TransitionState.intro:
                if (intro != null)
                {
                    intro.update(this as IMenuComponent);
                }
                break;

            case TransitionState.revert:
                if (revert != null)
                {
                    revert.update(this as IMenuComponent);
                }
                break;

            case TransitionState.select:
                if (select != null)
                {
                    select.update(this as IMenuComponent);
                }
                break;

            case TransitionState.exit:
                if (exit != null)
                {
                    exit.update(this as IMenuComponent);
                }
                break;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialize the transition, setting any initial values that it needs to have to run.
        /// </summary>
        /// <param name="transition">The transition that needs to be run</param>
        public void setTransition(TransitionState transition)
        {
            switch (transition)
            {
            case TransitionState.intro:
                if (intro != null)
                {
                    intro.setTransition(this as IMenuComponent);
                }
                break;

            case TransitionState.revert:
                if (revert != null)
                {
                    revert.setTransition(this as IMenuComponent);
                }
                break;

            case TransitionState.select:
                if (select != null)
                {
                    select.setTransition(this as IMenuComponent);
                }
                break;

            case TransitionState.exit:
                if (exit != null)
                {
                    exit.setTransition(this as IMenuComponent);
                }
                break;
            }
        }
Exemplo n.º 7
0
        public TransitionState ValidatePlacementTransition(TransitionState transitionState, ref int redo)
        {
            redo = 0;

            if (SpherePath.CheckCell == null)
            {
                return(TransitionState.Collided);
            }

            switch (transitionState)
            {
            case TransitionState.OK:
                SpherePath.CurPos  = SpherePath.CheckPos;
                SpherePath.CurCell = SpherePath.CheckCell;
                SpherePath.CacheGlobalCurrCenter();
                break;

            case TransitionState.Collided:
            case TransitionState.Adjusted:
            case TransitionState.Slid:

                // added target id
                if (SpherePath.PlacementAllowsSliding && ObjectInfo.TargetID == 0)
                {
                    CollisionInfo.Init();
                }

                break;
            }
            return(transitionState);
        }
Exemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        //Updating based on our state
        switch (this.currentState)
        {
        //If we're staying hidden, nothing happens
        case TransitionState.Hide:
            return;

        //Moving into position
        case TransitionState.TransitionIn:
            //Increasing the current time
            this.currentTime += Time.deltaTime;
            //If the current time has reached the total transition time, we need to switch states to "Show"
            if (this.currentTime >= this.transitionTime)
            {
                this.currentState            = TransitionState.Show;
                this.currentTime             = 0;
                this.transform.localPosition = this.transitionStayPos;
            }
            //Otherwise, we're still transitioning
            else
            {
                //Setting our position between the start pos and the stay pos based on the percent of time passed
                float transInPercent = this.currentTime / this.transitionTime;
                this.transform.localPosition = ((this.transitionStayPos - this.transitionStartPos) * transInPercent) + this.transitionStartPos;
            }
            break;

        case TransitionState.Show:
            //Increasing the current time
            this.currentTime += Time.deltaTime;
            //If the current time has reached the total time to display, we need to switch states to "Transition Out"
            if (this.currentTime >= this.timeToDisplay)
            {
                this.currentState = TransitionState.TransitionOut;
                this.currentTime  = 0;
            }
            break;

        case TransitionState.TransitionOut:
            //Increasing the current time
            this.currentTime += Time.deltaTime;
            //If the current time has reached the total transition time, we need to switch states to "Hide"
            if (this.currentTime >= this.transitionTime)
            {
                this.currentState            = TransitionState.Hide;
                this.currentTime             = 0;
                this.transform.localPosition = this.transitionOutPos;
            }
            //Otherwise, we're still transitioning
            else
            {
                //Setting our position between the stay pos and the out pos based on the percent of time passed
                float transInPercent = this.currentTime / this.transitionTime;
                this.transform.localPosition = ((this.transitionOutPos - this.transitionStayPos) * transInPercent) + this.transitionStayPos;
            }
            break;
        }
    }
Exemplo n.º 9
0
 public MenuType(string current)
 {
     components      = new Dictionary <string, IComponent>();
     state           = current;
     transitionState = TransitionState.menu;
     queue           = true;
 }
Exemplo n.º 10
0
        protected virtual void InitEnding()
        {
            if (string.IsNullOrEmpty(this.nextImageId) == false)
            {
                if (this.parentLayer.TryGetTarget(out ALayer2D parentLayer))
                {
                    Texture nextTexture = parentLayer.GetLayerTextureFromId(this.nextImageId);
                    this.ObjectSprite.Texture = nextTexture;

                    this.ObjectSprite.Origin = new Vector2f(this.Canevas.Width / 2, this.Canevas.Height / 2);

                    if (this.ObjectSprite.Texture != null)
                    {
                        this.SpriteColor = new Color(255, 255, 255, 0);

                        IAnimation endingAnimation = new ColorAnimation(this.SpriteColor, new Color(255, 255, 255), Time.FromSeconds(0.5f), AnimationType.ONETIME, InterpolationMethod.LINEAR);

                        this.PlayAnimation(endingAnimation);
                    }
                }

                this.nextImageId = null;

                this.ImageTransitionState = TransitionState.ENDING;
            }
            else
            {
                this.InitFinished();
            }
        }
 protected override void OnQuestUpdate()
 {
     base.OnQuestUpdate();
     switch (_questState)
     {
         case TransitionState.Started:
             if (_activationTimer.CanTick)
             {
                 foreach (Transform t in gameObject.transform)
                 {
                     t.gameObject.SetActive(true);
                 }
                 _questState = TransitionState.Waiting;
             }
             break;
         case TransitionState.Completed:
             if (_deactivationTimer.CanTick)
             {
                 foreach (Transform t in gameObject.transform)
                 {
                     t.gameObject.SetActive(false);
                 }
                 _questState = TransitionState.Waiting;
             }
             break;
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Updates the duration position based upon the game time.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <returns>The state of the transition.</returns>
        public TransitionState Update(GameTime gameTime)
        {
            // How much should we move by?
            float transitionDelta;

            if (this.Time == TimeSpan.Zero)
            {
                transitionDelta = 1.0f;
            }
            else
            {
                transitionDelta = (float)(gameTime.ElapsedGameTime.TotalMilliseconds / this.Time.TotalMilliseconds);
            }

            // Update the transition position.
            this.Position += transitionDelta * this._numericDirection;

            // Did we reach the end of the transition?
            if (((this._numericDirection < 0) && (this.Position <= 0)) ||
                ((this._numericDirection > 0) && (this.Position >= 1)))
            {
                this.Position = MathHelper.Clamp(this.Position, 0, 1);
                this.State    = TransitionState.Complete;
            }
            else
            {
                this.State = TransitionState.InProgress;
            }

            // Return the state
            return(this.State);
        }
Exemplo n.º 13
0
 private void onOffPosition()
 {
     //Debug.Log("onOffPosition");
     m_currentTransitionState = TransitionState.OFF;
     m_lastLockedState        = TransitionState.OFF;
     m_from = m_wipeOutPosition;
     m_to   = m_startPosition;
     if (m_imageRetriever != null)
     {
         foreach (LeapImageRetriever image in m_imageRetriever)
         {
             image.enabled = false;
         }
     }
     else
     {
         //Debug.LogError("No image retreiver on: " + gameObject.name);
     }
     if (m_handController != null)
     {
         m_handController.gameObject.SetActive(true);
     }
     if (m_cameraAlignment != null)
     {
         m_cameraAlignment.enabled = false;
     }
 }
Exemplo n.º 14
0
    void Update()
    {
        if (state == TransitionState.Flight || state == TransitionState.Platformer || state == TransitionState.Menu)
        {
            return;
        }

        if (state == TransitionState.ToMenu)
        {
            t += Time.deltaTime;
            camera.transform.position = Vector3.Lerp(FlightPosition, MenuPosition,
                                                     curve.Evaluate(Mathf.Min(1, t / TransitionTime)));
            if (t > TransitionTime)
            {
                state = TransitionState.Platformer;
                callback?.Invoke();
                callback = null;
                t        = 0;
            }
        }
        if (state == TransitionState.FromMenu)
        {
            t += Time.deltaTime;
            camera.transform.position = Vector3.Lerp(MenuPosition, PlatformerPosition,
                                                     curve.Evaluate(Mathf.Min(1, t / TransitionTime)));
            if (t > TransitionTime)
            {
                state = TransitionState.Platformer;
                callback?.Invoke();
                callback = null;
                t        = 0;
            }
        }
        if (state == TransitionState.FromPlatformer)
        {
            t += Time.deltaTime;
            camera.transform.position = Vector3.Lerp(PlatformerPosition, FlightPosition,
                                                     curve.Evaluate(Mathf.Min(1, t / TransitionTime)));
            if (t > TransitionTime)
            {
                state = TransitionState.Flight;
                callback?.Invoke();
                callback = null;
                t        = 0;
            }
        }
        if (state == TransitionState.FromFlight)
        {
            t += Time.deltaTime;
            camera.transform.position = Vector3.Lerp(FlightPosition, MenuPosition,
                                                     curve.Evaluate(Mathf.Min(1, t / TransitionTime)));
            if (t > TransitionTime)
            {
                state = TransitionState.Menu;
                callback?.Invoke();
                callback = null;
                t        = 0;
            }
        }
    }
Exemplo n.º 15
0
        public void updateTransitions(TransitionState state)
        {
            switch (state)
            {
            case TransitionState.intro:
                if (intro != null)
                {
                    intro.update(this);
                }
                break;

            case TransitionState.selected:
                if (select != null)
                {
                    select.update(this);
                }
                break;

            case TransitionState.exit:
                if (exit != null)
                {
                    exit.update(this);
                }
                break;
            }
        }
Exemplo n.º 16
0
        public TransitionState ValidatePlacement(TransitionState transitionState, bool adjust)
        {
            if (SpherePath.CheckCell == null)
            {
                return(TransitionState.Collided);
            }

            switch (transitionState)
            {
            case TransitionState.OK:
                SpherePath.CurPos  = SpherePath.CheckPos;
                SpherePath.CurCell = SpherePath.CheckCell;
                SpherePath.CacheGlobalCurrCenter();
                break;

            case TransitionState.Adjusted:
            case TransitionState.Slid:
                if (adjust)
                {
                    return(ValidatePlacement(PlacementInsert(), false));
                }
                break;
            }
            return(transitionState);
        }
Exemplo n.º 17
0
        void Footer_OnSpeedChanged(object sender, EventArgs e)
        {
            try
            {
                if (tran != null)
                {
                    TransitionState oldState = tran.State;
                    tran.pause();

                    Point originalLabelPos = label.Location;

                    int time = (MAX_SLIDER_VALUE - speed + (MIN_SLIDER_VALUE == 0 ? 1 : 0)) * CalculateTransitionTime(BASE_TIME_TRANSITION, label.Width + originalLabelPos.X);

                    tran = new Transition(new TransitionType_Linear(time));

                    tran.add(label, "Left", -label.Size.Width);

                    tran.TransitionCompletedEvent += tran_TransitionCompletedEvent;

                    if (oldState == TransitionState.Running)
                    {
                        tran.run();
                    }

                    CurrentTextIndex++;
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show("Footer_OnSpeedChanged" + Environment.NewLine + ex.Message);
#endif
            }
        }
        protected async Task UpdateState(bool mounting, TransitionState next)
        {
            // var next = Next;
            if (next != TransitionState.None)
            {
                DisposeCallback();

                // Next will always be ENTERING or EXITING.

                if (next == TransitionState.Entering)
                {
                    await PerformEnter(mounting);
                }
                else
                {
                    await PerformExit();
                }
            }
            else if (UnmountOnExit && Current == TransitionState.Exited)
            {
                Current = TransitionState.Unmounted;

                await InvokeAsync(StateHasChanged);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Essentially triggers the animation to play again in reverse
        /// </summary>
        public virtual void TriggerFadeOut()
        {
            if (state == TransitionState.AnyState)     //this is for brand new items, it show we don't know what state it is in. However since we are calling fade out first...
            {
                state       = TransitionState.Waiting; //then it must be displaying and waiting to fade out
                currentTime = fadeOutTime;
            }

            if (fadeOutDelay != 0)
            {
                if (state == TransitionState.Waiting)//if finished, then restart
                {
                    currentTime = 0;
                    state       = TransitionState.FadeOutDelay;
                }
                else//Otherwise continue the animation where this left off
                {
                    state = TransitionState.FadingOut;
                }
            }
            else
            {
                if (state == TransitionState.Waiting)//if finished, then restart. Otherwise continue the animation were this left off
                {
                    currentTime = fadeOutTime;
                }

                state = TransitionState.FadingOut;
            }

            CheckMessage();
        }
Exemplo n.º 20
0
        public static TransitionState DoTransition([NotNull] StateContext nextState, [CanBeNull] StateContext previousState, [CanBeNull] StateContext parentState = null)
        {
            TransitionState transitionState = new TransitionState(nextState, previousState);

            (parentState ?? ((object)((previousState != null) ? previousState.get_parent() : null)) ?? ((object)StateManager.GetDefaultLayer())).SetChildState(transitionState, 0);
            return(transitionState);
        }
Exemplo n.º 21
0
 public void JumpToEnd()
 {
     currentTime = transitionInTime;
     Transition();
     state = BaseTransition.TransitionState.Waiting;
     CheckMessage();
 }
Exemplo n.º 22
0
        public virtual void Initialise()
        {
            #region Send Instantly
            TransitionState temp = state;

            state = TransitionState.Delay;
            CheckMessage();//check to see if a message needs sent instantly

            state = temp;
            #endregion

#if (UNITY_EDITOR)
            //if(transitionInTime <= 0 || fadeOutTime <= 0)
            //    Debug.LogError("Transition and Fade time has to be greater than 0!!");

            if (transitionInCurve.length == 0 || fadeOutCurve.length == 0)
            {
                Debug.LogError("No animation curve set for: " + parent.gameObject +
                               ".\nIf you have upgraded this framework then selecting the straight diagonal line will reproduce the exact result from previous versions. However you can now get nicer results using more natural curves intstead of lines" +
                               "\nTo set these click the empty box labelled 'Animation Curve'");
            }
#endif

            state = BaseTransition.TransitionState.AnyState;//used to show this is the first run

            if (triggerInstantly)
            {
                TriggerTransition(false);
            }
        }
Exemplo n.º 23
0
 internal void TransitionStateChanged(TransitionState state)
 {
     if (state == TransitionState.Left)
     {
         Closed?.Invoke(this);
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Update transitions
        /// </summary>
        /// <param name="gameTime">GameTime</param>
        public override void Update(GameTime gameTime)
        {
            if (_transitionState == TransitionState.FadeIn)
            {
                if (UpdateTransition(gameTime, _timeTransitionOn, -1))
                {
                    _transitionState = TransitionState.On;
                    OnTransitionFinished(EventArgs.Empty, true);
                }
                else
                {
                    OnTransitionActive(EventArgs.Empty, true);
                }
            }

            else if (_transitionState == TransitionState.FadeOut)
            {
                if (UpdateTransition(gameTime, _timeTransitionOff, 1))
                {
                    _transitionState = TransitionState.Off;
                    OnTransitionFinished(EventArgs.Empty, false);
                }
                else
                {
                    OnTransitionActive(EventArgs.Empty, true);
                }
            }
        }
    private IEnumerator collapse(Vector2 pTargetSize, float pTransitionDuration)
    {
        if (_subElements.Length > 0)
        {
            for (int i = _subElements.Length - 1; i >= 0; i--)
            {
                //This can be graetly improved, perhaps implement an interface to support different types of collapsing
                IEnumerator foldin = _subElements[i].GetComponent <ARHintFoldout>().Foldin();
                yield return(foldin);
            }
        }

        _dummyRect.gameObject.SetActive(true);
        gameObject.SetActive(false);

        _state = TransitionState.Collapsing;
        Vector2 startSize   = _dummyRect.sizeDelta;
        float   timeElapsed = 0;
        float   closeTime   = pTransitionDuration * (Vector2.Distance(pTargetSize, startSize) / Vector2.Distance(pTargetSize, _rect.sizeDelta));

        while (Vector2.Distance(pTargetSize, _dummyRect.sizeDelta) > 0.01f)
        {
            _dummyRect.sizeDelta = Vector2.Lerp(startSize, pTargetSize, timeElapsed / closeTime);
            timeElapsed         += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }

        _dummyRect.sizeDelta = pTargetSize;
        _transforming        = null;
        _state = TransitionState.Collapsed;
    }
Exemplo n.º 26
0
        void SetTutorial(TutorialType type)
        {
            // Clean up old tutorial.
            Destroy(m_TutorialObject);
            m_TutorialObject = null;

            // Find the appropriate prefab.
            GameObject prefab = TutorialManager.m_Instance.GetTutorialPrefab(type);

            if (prefab)
            {
                m_TutorialObject = (GameObject)Instantiate(prefab, transform.position, transform.rotation);
                m_TutorialObject.transform.parent     = transform;
                m_TutorialObject.transform.localScale = Vector3.zero;
            }
            else
            {
                // Nothing mapped.  Jump straight to standard.
                m_TipTransitionState = TransitionState.None;
            }

            m_CurrentTutorialType = m_DesiredTutorialType;

            int iNumTypes    = (int)TutorialType.Num;
            int iCurrentType = (int)m_CurrentTutorialType + 1;

            m_TipNumber.text = iCurrentType.ToString() + "  of  " + iNumTypes.ToString();
        }
Exemplo n.º 27
0
    private void Transition()
    {
        if (Vector3.Distance(LevelDestination[0].transform.position, transform.position) <= 0.1f)
        {
            transform.position = LevelDestination[0].transform.position;
            transitionPosOk    = true;
        }
        else
        {
            offset             = Vector3.Lerp(offset, offsetLevel2, Time.deltaTime * transitionSpeed);
            transform.position = transform.position + dirNormalized * transitionSpeed * Time.deltaTime;
        }
        if (Quaternion.Angle(transform.rotation, LevelDestination[0].transform.rotation) <= 0)
        {
            transform.rotation = LevelDestination[0].transform.rotation;
            transitionRotOk    = true;
        }
        if (transitionPosOk && transitionRotOk)
        {
            transitionState = TransitionState.TRANSITION_OFF;
            target.GetComponent <PlayerBehavior>().SetLevel((int)levelState);
        }

        else
        {
            Vector3 angleTarget = new Vector3(
                Mathf.LerpAngle(transform.rotation.eulerAngles.x, LevelDestination[(int)levelState - 1].transform.rotation.eulerAngles.x, Time.deltaTime * rotationSpeed),
                Mathf.LerpAngle(transform.rotation.eulerAngles.y, LevelDestination[(int)levelState - 1].transform.rotation.eulerAngles.y, Time.deltaTime * rotationSpeed),
                Mathf.LerpAngle(transform.rotation.eulerAngles.z, LevelDestination[(int)levelState - 1].transform.rotation.eulerAngles.z, Time.deltaTime * rotationSpeed));
            transform.eulerAngles = angleTarget;
        }
    }
Exemplo n.º 28
0
    private void ProcessTransition()
    {
        float deltaTime = Time.unscaledDeltaTime;

        switch (_currentTransitionState)
        {
        case TransitionState.TS_NONE:
            if (_fader.gameObject.activeSelf)
            {
                _fader.gameObject.SetActive(false);
            }
            break;

        case TransitionState.TS_OUT:
            _transitionTimer += deltaTime;
            if (_transitionTimer > _transitionLength)
            {
                _transitionTimer = _transitionLength;

                SetPanelActive(_currentGameState, false);
                SetPanelActive(_targetGameState, true);
                _currentGameState = _targetGameState;
                _targetGameState  = AppState.AS_NONE;

                _currentTransitionState = TransitionState.TS_IN;
            }
            else
            {
                if (!_fader.gameObject.activeSelf)
                {
                    _fader.gameObject.SetActive(true);
                }
                Color faderColor = _fader.color;
                faderColor.a = Mathf.Clamp01(_transitionTimer / _transitionLength);
                _fader.color = faderColor;
            }
            break;

        case TransitionState.TS_IN:
            _transitionTimer -= deltaTime;
            if (_transitionTimer < 0.0f)
            {
                _transitionTimer        = 0.0f;
                _currentTransitionState = TransitionState.TS_NONE;

                NotifyOnGameStateChanged();
            }
            else
            {
                if (!_fader.gameObject.activeSelf)
                {
                    _fader.gameObject.SetActive(true);
                }
                Color faderColor = _fader.color;
                faderColor.a = Mathf.Clamp01(_transitionTimer / _transitionLength);
                _fader.color = faderColor;
            }
            break;
        }
    }
Exemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        if (update)
        {
            if (tsState == TransitionState.Evap)
            {
                transitionTimer += Time.deltaTime / transitionTime;
                float magnitude = Mathf.Lerp(minMagnitude, maxMagnitude, transitionTimer);
                evaporateMat.SetFloat("_Magnitude", magnitude);

                if (transitionTimer >= 1)
                {
                    //De-evaporate
                    evaporateMat.SetFloat("_Magnitude", minMagnitude);
                    halluMat.SetFloat("_yPercentage", 1f);
                    tsState = TransitionState.Invert;
                }
            }

            else if (tsState == TransitionState.Invert)
            {
                inversionTimer += Time.deltaTime;
                if (inversionTimer > inversionTime)
                {
                    halluMat.SetFloat("_yPercentage", 0f);
                    SoundEffector.Instance.Stop();
                    tsState = TransitionState.Done;
                }
            }
        }
    }
Exemplo n.º 30
0
  void Update() {
    BaseUpdate();

    switch (m_TipTransitionState) {
    case TransitionState.Out:
      // Shrink our current tutorial until 0, then spawn the desired next.
      m_TipTransitionValue -= Time.deltaTime * m_TipTransitionSpeed;
      if (m_TipTransitionValue <= 0.0f) {
        SetTutorial(m_DesiredTutorialType);
        m_TipTransitionValue = 0.0f;
        m_TipTransitionState = TransitionState.In;
      } else {
        m_TutorialObject.transform.localScale = Vector3.one * m_TipTransitionValue;
      }
      break;
    case TransitionState.In:
      // Grow our current tutorial until 1.
      m_TipTransitionValue += Time.deltaTime * m_TipTransitionSpeed;
      if (m_TipTransitionValue >= 1.0f) {
        m_TipTransitionValue = 1.0f;
        m_TipTransitionState = TransitionState.None;
      }

      if (m_TutorialObject) {
        m_TutorialObject.transform.localScale = Vector3.one * m_TipTransitionValue;
      }
      break;
    }
  }
Exemplo n.º 31
0
        public void drawTransitions(SpriteBatch spriteBatch, TransitionState state)
        {
            switch (state)
            {
            case TransitionState.intro:
                if (intro != null)
                {
                    intro.draw(spriteBatch, this);
                }
                break;

            case TransitionState.selected:
                if (select != null)
                {
                    select.draw(spriteBatch, this);
                }
                break;

            case TransitionState.exit:
                if (exit != null)
                {
                    exit.draw(spriteBatch, this);
                }
                break;
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// Constructs a Transitionable with the given transition times and screen directions.
        /// </summary>
        /// <param name="transitionOnTime"></param>
        /// <param name="transitionOffTime"></param>
        public Transition(double transitionOnTime, double transitionOffTime)
        {
            elapsedTransition = TimeSpan.Zero;
            state = TransitionState.Off;

            transitionOn = TimeSpan.FromSeconds(transitionOnTime);
            transitionOff = TimeSpan.FromSeconds(transitionOffTime);
        }
Exemplo n.º 33
0
	// Use this for initialization
	void Start () {
		m_startPosition = transform.localPosition;
		m_from = m_startPosition;
		m_to = m_wipeOutPosition;
		m_lastLockedState = TransitionState.ON;
		SystemWipeRecognizerListener.Instance.SystemWipeUpdate += onWipeUpdate;
    TweenToOffPosition();
	}
Exemplo n.º 34
0
 public TransitionState Transitioning( TransitionState currentState, Node scene, GameTime gameTime )
 {
     if ( currentState == TransitionState.Begin )
         return TransitionState.PretransitionEnd;
     else if ( currentState == TransitionState.PretransitionEnd )
         return TransitionState.End;
     else throw new ArgumentException ();
 }
Exemplo n.º 35
0
    private IEnumerator FadeIn()
    {
        _fadeStartTime = Time.time;
        _transitionState = TransitionState.Showing;

        yield return new WaitForSeconds( FADE_DURATION );

        _transitionState = TransitionState.Idle;
    }
Exemplo n.º 36
0
            public override void OnDeactivate()
            {
                if(State == TransitionState.InTransitForward || State == TransitionState.InTransitReverse)
                    StartTime = Time.time - (TransitionTime * CurrentProgress);
                else
                    StartTime = Time.time;

                State = TransitionState.InTransitReverse;
            }
Exemplo n.º 37
0
    private IEnumerator FadeOut()
    {
        _fadeStartTime = Time.time;
        _transitionState = TransitionState.Hiding;

        yield return new WaitForSeconds( FADE_DURATION );

        SaveManager.ChangeLevel( nextLevelName );
    }
Exemplo n.º 38
0
        public override void Draw( GameTime gameTime )
        {
            if ( currentNode != null )
                currentNode.Draw ( gameTime );

            if ( TransitionState != TransitionState.None )
            {
                TransitionState = SceneTransitor.Transitioning ( TransitionState, sceneList.Peek (), gameTime );
                if ( TransitionState == Scenes.TransitionState.PretransitionEnd )
                {
                    switch ( ContainMethod )
                    {
                        case SceneContainMethod.Flat:
                            spinlock.Enter ();
                            sceneList.Pop ().Outro ();
                            nextNode.Intro ( nextNodeArgs );
                            nextNode.Parent = this;
                            sceneList.Push ( currentNode = nextNode );
                            nextNode = null;
                            nextNodeArgs = null;
                            spinlock.Exit ();
                            break;
                        case SceneContainMethod.Stack:
                            if ( nextNode == null )
                            {
                                spinlock.Enter ();
                                Node nn = sceneList.Pop ();
                                nn.Parent = null;
                                nn.Outro ();
                                currentNode = null;
                                nextNode = null;
                                nextNodeArgs = null;
                                spinlock.Exit ();
                            }
                            else
                            {
                                spinlock.Enter ();
                                nextNode.Intro ( nextNodeArgs );
                                sceneList.Push ( currentNode = nextNode );
                                nextNode = null;
                                nextNodeArgs = null;
                                spinlock.Exit ();
                            }
                            break;
                    }
                    gameTime.Reset ();
                }
                else if ( TransitionState == Scenes.TransitionState.End )
                {
                    TransitionState = TransitionState.None;
                    nextNode = null;
                }
            }
            base.Draw ( gameTime );
        }
 protected override void OnQuestAdded()
 {
     base.OnQuestAdded();
     _activationTimer = new Timer(_activationTime);
     _questState = TransitionState.Started;
     // Ensure all the transforms start off disabled
     foreach(Transform t in gameObject.transform)
     {
         t.gameObject.SetActive(false);
     }
 }
    public void ChangeRoom(int id)
    {
        if(dia)
            dia.Hide(); // hides dialogue box messages

        im.SetMode(InteractMode.gMode.GM_NONE);

        NextRoom = id;
        Transitioning = true;
        TransitionTimeRemaining = 1.0f;
        TransitionStateCurrent = TransitionState.TO_BLACK;
    }
	public void StartTransition (Color fromColor, Color toColor, float duration, TransitionType type) {
		if (transitState == TransitionState.TransitedIn || transitState == TransitionState.TransitedOut) {
			// Change the state to transiting in/out (according to the previous state)
			transitState = transitState == TransitionState.TransitedIn ? TransitionState.TransitingOut : TransitionState.TransitingIn;

			// Enable the transiter's Image
			transiters[type].EnableImage ();

			// Call the transition animation according to the given TransitionType
			transiters[type].StartTransition (fromColor, toColor, duration);
		}
	}
    void Awake()
    {
		// Access button component
		button = GetComponent<Button>();

        // Starting state
        transitionState = TransitionState.Down;

        // Get colour
        baseColor = button.colors.normalColor;
        highlightedColor =  button.colors.highlightedColor;
    }
Exemplo n.º 43
0
 public Screen(Game game)
     : base(game)
 {
     game.Components.Add(this);
     this.Enabled = false;
     this.Visible = false;
     killFlag = false;
     transState = TransitionState.None;
     spriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));
     spriteFont = (SpriteFont)game.Services.GetService(typeof(SpriteFont));
     inputHelper = (InputHelper)game.Services.GetService(typeof(InputHelper));
     shadeTexture = Game.Content.Load<Texture2D>("Media\\GUI\\Shade");
     fadeLevel = 0;
 }
	void Awake () {
		transitState = TransitionState.TransitedIn;

		UITransiterFadeInOut fadeInOut = GetComponentInChildren<UITransiterFadeInOut> ();
		transiters.Add (TransitionType.FadeInOut, fadeInOut);

		try {
			transiters[TransitionType.FadeInOut].TransiterActionCompleted += this.OnTransiterActionCompleted;
		} catch {
			Debug.LogError ("No UIFadeInOut was found in the children of the object " + gameObject.name);
			Debug.Break ();
		}

		transiters.Add (TransitionType.None, null);
	}
Exemplo n.º 45
0
	private void onWipeUpdate(object sender, SystemWipeArgs eventArgs) {
		if ( !m_enabled ) { return; }

		string debugLine = "Debug";
		if ( eventArgs.WipeInfo.Status == Leap.Util.Status.SwipeAbort ) {
			debugLine += " | Abort";
			// If the user aborts, tween back to original location
			if ( m_lastLockedState == TransitionState.ON ) {
				TweenToOnPosition();
			}
			else {
				TweenToOffPosition();
			}
		}

		if ( m_currentTransitionState == TransitionState.MANUAL ) {
			debugLine += " | Manual Control";
			float fraction = Mathf.Clamp01(eventArgs.WipeInfo.Progress);

			debugLine += ": " + fraction;
			transform.localPosition = Vector3.Lerp(m_from, m_to, fraction);

			// If we're sure of the gesture, just go make the transition
			if ( fraction >= m_fractionToLockTransition ) {
				debugLine += " | Transition Cofirmed";
				if ( m_lastLockedState == TransitionState.OFF ) {
					TweenToOnPosition();
				}
				else {
					TweenToOffPosition();
				}
			}
		}
		else if ( m_currentTransitionState == TransitionState.TWEENING ) {
			debugLine += " | Currently Tweening";
			//Debug.Log(debugLine);
			return;
		}
		else { // We're either on or off
			debugLine += " | Locked";
			if ( eventArgs.WipeInfo.Progress >= m_minProgressToStartTransition ) {
				debugLine += " | Go To Manual";
				m_currentTransitionState = TransitionState.MANUAL; 
			}
		}

		//Debug.Log(debugLine);
	}
Exemplo n.º 46
0
 public StateHandler()
 {
     _score = 0;
     _gamestate = GameState.Menu;
     _menustate = MenuState.MainMenu;
     _levelstate = LevelState.Level1;
     _transitionstate = TransitionState.LevelStart;
     _characterstate = CharacterState.Standing;
     _characterskin = Skins.Mario;
     _nextgamestate = GameState.Menu;
     _nextmenustate = MenuState.MainMenu;
     _nextlevelstate = LevelState.Level1;
     _nexttransitionstate = TransitionState.LevelStart;
     _nextcharacterstate = CharacterState.Standing;
     _nextcharacterskin = Skins.Mario;
     _cursor = MenuCursor.PlayGame;
     _keyscursor = 1;
     _skinscursor = 1;
 }
Exemplo n.º 47
0
 public TransitionState Transitioning( TransitionState currentState, Node scene, GameTime gameTime )
 {
     switch ( currentState )
     {
         case TransitionState.Begin:
             fadeAlpha += ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f * FadeUnit;
             if ( fadeAlpha >= 255 ) fadeAlpha = 255;
             DrawFade ();
             if ( fadeAlpha >= 255 ) return TransitionState.PretransitionEnd;
             return TransitionState.Begin;
         case TransitionState.Posttransition:
         case TransitionState.PretransitionEnd:
             fadeAlpha -= ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f * FadeUnit;
             DrawFade ();
             if ( fadeAlpha <= 0 ) { fadeAlpha = 0; return TransitionState.End; }
             return TransitionState.Posttransition;
         default:
             throw new ArgumentException ();
     }
 }
Exemplo n.º 48
0
            void Update()
            {
                if(State == TransitionState.InTransitForward || State == TransitionState.InTransitReverse)
                {
                    CurrentProgress = (Time.time - StartTime) / TransitionTime;
                    CurrentProgress = Mathf.Clamp(CurrentProgress, 0.0f, 1.0f);

                    if(State == TransitionState.InTransitForward)
                    {
                        TargetObject.transform.position = Vector3.Lerp(OriginalLocation, ActualEndLocation, CurrentProgress);
                        TargetObject.transform.rotation = Quaternion.Lerp(OriginalOrientation, ActualEndRotation, CurrentProgress);
                    }
                    else if(State == TransitionState.InTransitReverse)
                    {
                        TargetObject.transform.position = Vector3.Lerp(ActualEndLocation, OriginalLocation, CurrentProgress);
                        TargetObject.transform.rotation = Quaternion.Lerp(ActualEndRotation, OriginalOrientation, CurrentProgress);
                    }

                    if(Time.time - StartTime > TransitionTime)
                        State = TransitionState.Waiting;
                }
            }
    private IEnumerator Flash()
    {
		while(isSelected)
        {
            // Increase alpha
            animationFrame += Time.deltaTime;

            // Get colour
            ColorBlock block = button.colors;

            // Update structs
            if(transitionState.Equals(TransitionState.Down))
            {
                // Lerp towards base
                block.highlightedColor = Color.Lerp(highlightedColor, baseColor, animationFrame / flashSpeed);
                if(block.highlightedColor.Equals(baseColor))
                {
                    transitionState = TransitionState.Up;
                    animationFrame = 0;
                }
            }
            else
            {
                // Lerp towards highlighted
                block.highlightedColor = Color.Lerp(baseColor, highlightedColor, animationFrame / flashSpeed);
                if(block.highlightedColor.Equals(highlightedColor))
                {
                    transitionState = TransitionState.Down;
                    animationFrame = 0;
                }
            }

            // Apply to button
            button.colors = block;

            yield return null;
        }
    }
        public override void LoadContent(ContentManager content)
        {
            Engine.ClearColor = Color.Black;
            _state = TransitionState.Beginning;

            _transitionTween = new Tween(0, 100, 2000)
            {
                OnComplete = t =>
                {
                    if (_state == TransitionState.Beginning)
                    {
                        _state = TransitionState.Running;
                    }
                    else if (_state == TransitionState.Running)
                    {
                        _state = TransitionState.End;
                    }
                    else if (_state == TransitionState.End)
                    {
                        _state = TransitionState.Stopped;
                    }

                    if (_state != TransitionState.Stopped)
                    {
                        t.Reset();
                        t.Start();
                    }
                    else
                    {
                        Engine.Scenes.ChangeScene(SceneNames.Title);
                    }
                }
            };

            _logoTexture = Textures.Load(TextureNames.CarpMuffinLogo);
            _whitePixel = Engine.CreateWhitePixel();
        }
Exemplo n.º 51
0
 private void onOffPosition()
 {
     //Debug.Log("onOffPosition");
     m_currentTransitionState = TransitionState.OFF;
     m_lastLockedState = TransitionState.OFF;
     m_from = m_wipeOutPosition;
     m_to = m_startPosition;
 }
Exemplo n.º 52
0
    protected new void FixedUpdate()
    {
        base.FixedUpdate();

        if (throwDelayCountdown > 0.0f && throwDelayCountdown - Time.deltaTime < 0)
        {
            Throw(delayedDirection, delayedCamera, delayedOtherCamera, 0);
        }
        throwDelayCountdown -= Time.deltaTime;

        if (floatDirection != null)
        {
            Vector3 moveDelta = new Vector3(floatDirection.Value.x * Time.deltaTime, floatDirection.Value.y * Time.deltaTime, floatDirection.Value.z * Time.deltaTime);

            transform.Translate(moveDelta.x, moveDelta.y, moveDelta.z);

            if(GameManager.isSingleScreen()) return;

            if (originCamera != null && destinationCamera != null)
            {
                // move up or down until we're not longer in view of the origin camera
                Plane[] plane = GeometryUtility.CalculateFrustumPlanes(destinationCamera);
                Vector3 cameraSpacePosition = originCamera.WorldToScreenPoint(transform.position);
                bool goingUp = (floatDirection.Value.y > 0);
                float pixelHeight = originCamera.pixelHeight * 0.5f;
                //Debug.Log("cameraSpacePosition " + cameraSpacePosition + ": " + originCamera.pixelWidth);
                //Debug.Log("pixelHeight " + pixelHeight + " " + originCamera.pixelWidth);
                if ((goingUp && cameraSpacePosition.y > pixelHeight) || (!goingUp && cameraSpacePosition.y < pixelHeight))
                {
                    //Debug.Log("cameraSpacePosition.x " + cameraSpacePosition.x);
                    Vector3 position = destinationCamera.ScreenToWorldPoint(new Vector3(cameraSpacePosition.x, goingUp ? pixelHeight : pixelHeight, 0.0f));
                    position.x = Mathf.Round(position.x);
                    position.z = 0.0f;

                    if (shouldStopInFirstEmptySpace)
                    {
                        if (goingUp) transitionState = TransitionState.TRANSITIONING_FROM_BOTTOM;
                        else transitionState = TransitionState.TRANSITIONING_FROM_TOP;
                    }
                    else
                    {
                        transitionState = TransitionState.FLOATING_AWAY;
                    }

                    transform.position = position;

                    originCamera = null;
                    return;
                }
            }
            else
            {
                switch(transitionState)
                {
                    case TransitionState.TRANSITIONING_FROM_BOTTOM:
                        {
                            Vector3 bottom = transform.position;
                            bottom.y -= collider.bounds.size.y * 0.5f;
                            if (pointIsInCamera(bottom, destinationCamera))
                                transitionState = TransitionState.LOOKING_FOR_FREE_SPACE_GOING_UP;
                        }
                        break;

                    case TransitionState.TRANSITIONING_FROM_TOP:
                        {
                            Vector3 top = transform.position;
                            top.y += collider.bounds.size.y * 1.0f;
                            if (pointIsInCamera(top, destinationCamera))
                                transitionState = TransitionState.LOOKING_FOR_FREE_SPACE_GOING_DOWN;
                        }
                        break;

                    case TransitionState.LOOKING_FOR_FREE_SPACE_GOING_UP:
                        {
                            Collider collidedWith = collidedWithSomething();
                            if (collidedWith == null || collidedWith.GetComponent<PlayerControls2>())
                            {
                                if (collidedWith != null)
                                {
                                    PlayerControls2 hitPlayer = collidedWith.GetComponent<PlayerControls2>();
                                    if (hitPlayer != null)
                                        hitPlayer.knockBackByBlock(true, damageMultiplier);
                                }

                                floatDirection = null;
                                collider.isTrigger = false;

                                //if(passedThroughSomething) // keep it suspected in air if it didn't pass through a floor
                                    jumpState = JUMP_STATE.ON_GROUND;

                                onHitGround();
                            }
                            else
                                passedThroughSomething = true;
                        }
                        break;

                    case TransitionState.LOOKING_FOR_FREE_SPACE_GOING_DOWN:
                        {
                            //transform.Translate(moveDelta.x, moveDelta.y, moveDelta.z);

                            /*int count = 0;
                            Ray ray = new Ray(new Vector3(transform.position.x, 0.0f, 0.0f), new Vector3(0.0f, -1.0f, 0.0f));
                            RaycastHit lastHit = new RaycastHit();
                            while(count++ < 50)
                            {
                                RaycastHit hit;
                                bool didHit = collider.Raycast(ray, out hit, Mathf.Infinity);
                                Debug.DrawLine(ray.origin, ray.origin + ray.direction, Color.blue, 10);
                                if (didHit && lastHit.collider != null && hit.collider == lastHit.collider)
                                {
                                    break;
                                }

                                lastHit = hit;

                                ray.origin = new Vector3(ray.origin.x, ray.origin.y + 1.0f);
                            }

                            if (count >= 50.0f)
                                Debug.Log("failed " + count);

                            Collider collidedWith = collidedWithSomething();

                            if(collider.gameObject != null)
                                Debug.Log("collidedWith", collider.gameObject);

                            if(lastHit.collider.gameObject != null)
                                Debug.Log("lastHit ", lastHit.collider.gameObject);

                            if (collidedWith == lastHit.collider)*/

                            Collider collidedWith = collidedWithSomething();
                            if(collidedWith != null)
                            {
                                if (collidedWith != null)
                                {
                                    PlayerControls2 hitPlayer = collidedWith.GetComponent<PlayerControls2>();
                                    if (hitPlayer != null)
                                        hitPlayer.knockBackByBlock(true, damageMultiplier);
                                }

                                transform.Translate(-moveDelta.x, -moveDelta.y, -moveDelta.z);

                                floatDirection = null;
                                collider.isTrigger = false;
                                passedThroughSomething = true;
                                jumpState = JUMP_STATE.ON_GROUND;
                                onHitGround();
                            }
                        }
                        break;

                    case TransitionState.FLOATING_AWAY:
                        if (!renderer.isVisible)
                        {
                            Destroy(this);
                        }
                        break;
                }
            }
        }
    }
Exemplo n.º 53
0
 public void StartClose()
 {
     tState = TransitionState.TransitionOff;
 }
Exemplo n.º 54
0
	public void TweenToPosition(float percentage, float time = 0.4f) {
		m_currentTransitionState = TransitionState.TWEENING;
		StopAllCoroutines();
		StartCoroutine(doPositionTween(percentage, time));
	}
Exemplo n.º 55
0
	private void onOnPosition() {
		//Debug.Log("onOnPosition");
		m_currentTransitionState = TransitionState.ON;
		m_lastLockedState = TransitionState.ON;
		m_from = m_startPosition;
		m_to = m_wipeOutPosition;
    m_handController.gameObject.SetActive(false);
	}
Exemplo n.º 56
0
	private void onOffPosition() {
		//Debug.Log("onOffPosition");
		m_currentTransitionState = TransitionState.OFF;
		m_lastLockedState = TransitionState.OFF;
		m_from = m_wipeOutPosition;
		m_to = m_startPosition;
    if ( m_imageRetriever != null ) {
      m_imageRetriever.doUpdate = false;
    }
    else {
      Debug.LogError("No image retreiver on: " + gameObject.name);
    }
    m_handController.gameObject.SetActive(true);
	}
Exemplo n.º 57
0
        public void UpdateTransition(GameTime gameTime)
        {
            float transitionDelta = 0;
            if (tState == TransitionState.TransitionOn)
            {
                transitionDelta = (float)(gameTime.ElapsedGameTime.TotalMilliseconds /
                                         transitionOn.TotalMilliseconds);
            }
            else if (tState == TransitionState.TransitionOff)
            {
                transitionDelta = (float)(gameTime.ElapsedGameTime.TotalMilliseconds /
                         transitionOff.TotalMilliseconds);
            }

            if (tState != TransitionState.NoTransition)
            {
                transitionProgress += transitionDelta;
                if (transitionProgress >= 1)
                {
                    transitionProgress = 1;
                    if (tState == TransitionState.TransitionOff)
                    {
                        canClose = true;
                    }
                    tState = TransitionState.NoTransition;
                }
            }
            else
            {
                transitionProgress = 0;
            }
        }
Exemplo n.º 58
0
 public override void LoadContent()
 {
     State = TransitionState.Intro;
 }
Exemplo n.º 59
0
 public void SetDone()
 {
     State = TransitionState.Done;
 }
Exemplo n.º 60
0
		private void				ImportState(Interface.Struct.TechniteState state)
		{

			taskParameter = 0;
			lastResources = resources;
			resources = state.resources;
			taskResult = (TaskResult)state.taskResult;
			this.state = new CompressedState(state.state).Decoded;
			transitionState = TransitionState.Preserved;

			if (taskResult == Technite.TaskResult.OperationWindowMissed)
			{
				if (++windowMissedThisRound < MaxLogPerRound)
					Out.Log(Significance.Unusual, "Operation Window Missed on " + nextTask + " of " + this);
			}


			if (taskResult != TaskResult.MoreWorkNeeded)
				nextTask = Task.None;

		}