void Game::HandleState(State::LevelState lState) { if(lState==State::Complete) { if(stateName==GameState::ScoreBoard)//ScoreBoard will always return completed { stateName=GameState::Menu; if(_pcurLevel!=NULL) { _pcurLevel->UnloadContent(); delete _pcurLevel; } _pcurLevel=NULL; } else if(stateName==Menu)//Menu will return completed when new game is selected { if(_pcurLevel!=NULL) { _pcurLevel->UnloadContent(); delete _pcurLevel; } _pcurLevel=NULL; score=new Score(_rWindow,_rSfmlDebugDraw,_pWorld); // Initializing new score stateName=(GameState)(stateName+1); } else { stateName=(GameState)(stateName+1); if(_currentState==(State*)_pcurLevel) _pcurLevel=NULL; _currentState->UnloadContent(); delete _currentState; } switch(stateName) { case(Menu): _currentState=_pMenu; _pMenu->SetMenuState(1); // Argument(1) For New Menu ... break; case(Level_1): LoadScreen(); _currentState=new Level1(_rWindow,_rSfmlDebugDraw,_pWorld,score); _currentState->LoadContent(); break; //case(Level_2) : // _currentState = new Level2(_rWindow, _rSfmlDebugDraw, _pWorld, score); // _currentState->LoadContent(); // break; case(ScoreBoard): _currentState=score; _currentState->LoadContent(); break; } } else if(lState==State::Paused) { if(stateName==GameState::Level_1) { LevelNo=Level_1; _pcurLevel=_currentState; stateName=GameState::Menu; _currentState=_pMenu; _pMenu->SetMenuState(0);// Paused Menu _pcurLevel->ResetLevelState(); } //if (stateName == GameState::Level_2) //{ // LevelNo = Level_2; // _pcurLevel = _currentState; // stateName = GameState::Menu; // _currentState = _pMenu; // _pMenu->SetMenuState(0);// Paused Menu // _pcurLevel->ResetLevelState(); //} } else if(lState==State::Playing) { if(stateName==Menu) { stateName=LevelNo; _currentState=_pcurLevel; } } else if(lState==State::Lost) { if(stateName==GameState::Menu)//Menu will return lost when Exit is pressed { stateName=GameState::Exit; ExitScreen(); } else { stateName=GameState::ScoreBoard; _currentState=score; _currentState->LoadContent(); } } }
void ErrorPopUpScreen::HandleInput(const DirectX::InputState& inputState) { if (inputState.IsMenuSelect(-1, nullptr)) ExitScreen(); }