public PopUpStateEngine( IConstArg arg ) { thisProcessFactory = arg.processFactory; thisImplementor = arg.implementor; thisProcessTime = arg.processTime; State.IConstArg stateArg = new State.ConstArg( this, arg.implementor ); thisHiddenState = new HiddenState(stateArg); thisHidingState = new HidingState(stateArg); thisShownState = new ShownState(stateArg); thisShowingState = new ShowingState(stateArg); thisCurState = thisHiddenState; }
public void Show(bool isImmediately, Action onCompleted) { if (!isInitialized) { Initialize(); isInitialized = true; } bool shouldUseLogic = (CurrentState == ShowingState.Showing && isImmediately) || (CurrentState == ShowingState.Hiding || CurrentState == ShowingState.Hided) || CurrentState == ShowingState.None; if (shouldUseLogic) { currentState = ShowingState.Showing; onCompleted += () => { currentState = ShowingState.Showed; }; PlayShowAnimation(isImmediately, onCompleted); } }
public void Update( GameTime gameTime ) { bool spaceState = Input.IsActionKeyDown(); switch( m_state ) { case ShowingState.Showing: m_timer += (float) gameTime.ElapsedGameTime.TotalSeconds; if( m_timer > 1 ) { m_state = ShowingState.Display; } break; case ShowingState.Display: if( !m_lastState && spaceState ) { m_state = ShowingState.Disapper; } break; case ShowingState.Disapper: m_timer -= (float)gameTime.ElapsedGameTime.TotalSeconds; if (m_timer < 0) { GameCommands.Enqueue( m_command ); } break; } m_lastState = spaceState; }