private Transition LevelSelectionStateParser(LevelSelectionState state, Update update, IQuizService quizService, ILogger logger) { logger.LogInformation($"Update Type: {update.Type}"); switch (update.Type) { case UpdateType.Message: { logger.LogInformation($"Parsed message: {update.Message.Text}"); return(ParseLevel(state, update, quizService, logger)); } case UpdateType.CallbackQuery: { var callbackData = update.CallbackQuery.Data; logger.LogInformation($"Parsed callback: {callbackData}"); if (callbackData == StringCallbacks.Back) { return(new BackTransition()); } return(new InvalidTransition()); } } return(new InvalidTransition()); }
public void GetNextState_LevelSelectionState_OnBackTransition_ReturnTopicSelectionState() { var unknownUserState = new LevelSelectionState(testTopic); var backTransition = new BackTransition(); var(state, command) = stateMachine.GetNextState(unknownUserState, backTransition); state.Should().BeOfType <TopicSelectionState>(); command.Should().BeOfType <SelectTopicCommand>(); }
public void GetNextState_LevelSelectionState_OnCorrectTransition_ReturnTopicSelectionState() { var unknownUserState = new LevelSelectionState(testTopic); var backTransition = new CorrectTransition(testLevel.Id.ToString()); var(state, command) = stateMachine.GetNextState(unknownUserState, backTransition); var taskState = state.As <TaskState>(); taskState.TopicDto.Should().Be(testTopic); taskState.LevelDto.Should().Be(testLevel); command.Should().BeOfType <ShowTaskCommand>(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); _gameModel = new GameModel() { ContentManger = Content, GraphicsDeviceManager = graphics, SpriteBatch = spriteBatch, }; _state = new LevelSelectionState(_gameModel); }
void Awake() { Instance = this; mainMenuState = new MainMenuState(this); levelSelectionState = new LevelSelectionState(this); levelGameState = new LevelGameState(this); levelLoseState = new LevelLoseState(this); levelWonState = new LevelWonState(this); levelExitState = new ExitGameState(this); if (!levelManager) { levelManager = LevelsManager.Instance; } }
private Transition ParseLevel(LevelSelectionState state, Update update, IQuizService quizService, ILogger logger) { var message = update.Message.Text; if (message.Contains(UserCommands.Level)) { var levelId = message.Replace(UserCommands.Level, ""); if (int.TryParse(levelId, out var index)) { logger.LogInformation($"levelId: {index}"); var level = quizService.GetLevels(state.TopicDto.Id).ElementAt(index); logger.LogInformation($"level: {level.Id}"); return(new CorrectTransition(level.Id.ToString())); } return(new InvalidTransition()); } return(new InvalidTransition()); }
public GameLifeCycleTransitionManager(LevelState levelState, LevelSelectionState levelSelectionState, RecordApplyingState recordApplyingState, TopPlayersState topPlayersState) { AddState(levelState) .AllowTransition(levelSelectionState, context => context.IsPlayerAlive) .AllowTransition(recordApplyingState, _ => true) .Build(); AddState(levelSelectionState) .AllowTransition(levelState, context => context.NewLevelsAvailable) .AllowTransition(recordApplyingState, _ => true) .Build(); AddState(recordApplyingState) .AllowTransition(topPlayersState, _ => true) .Build(); AddState(topPlayersState) .AllowTransition(levelSelectionState, _ => true) .Build(); }
static bool Prefix(LevelSelectionState __instance) { Player player = PlayerController.Instance.inputController.player; var levelSelection = UnityEngine.Object.FindObjectOfType <LevelSelectionController>(); if (player.GetButtonDown("Y")) { UISounds.Instance?.PlayOneShotSelectionChange(); CustomLevelManager.Instance.OnNextSort <LevelSortMethod>(); return(false); } if (CustomLevelManager.Instance.CurrentFolder == null) { return(true); } if (!player.GetButtonDown("B")) { return(true); } if (!Main.Settings.DisableBToMoveUpDirectory) { UISounds.Instance?.PlayOneShotSelectMajor(); CustomLevelManager.Instance.CurrentFolder = CustomLevelManager.Instance.CurrentFolder.Parent; var currentIndexPath = Traverse.Create(levelSelection.listView).Property <IndexPath>("currentIndexPath"); currentIndexPath.Value = levelSelection.listView.currentIndexPath.Up(); levelSelection.listView.UpdateList(); levelSelection.listView.SetHighlighted(currentIndexPath.Value, true); return(false); } CustomLevelManager.Instance.CurrentFolder = null; return(true); }