void Update() { if (Grupo1) { PerguntaCanvas.GetComponent <Text>().text = PerguntaGrupo1; Resposta1Canvas.GetComponent <Text>().text = Resposta1Grupo1; Resposta2Canvas.GetComponent <Text>().text = Resposta2Grupo1; Resposta3Canvas.GetComponent <Text>().text = Resposta3Grupo1; theAnswer = theAnswerGrupo1; } else if (Grupo2) { PerguntaCanvas.GetComponent <Text>().text = PerguntaGrupo2; Resposta1Canvas.GetComponent <Text>().text = Resposta1Grupo2; Resposta2Canvas.GetComponent <Text>().text = Resposta2Grupo2; Resposta3Canvas.GetComponent <Text>().text = Resposta3Grupo2; theAnswer = theAnswerGrupo2; } else if (Grupo3) { PerguntaCanvas.GetComponent <Text>().text = PerguntaGrupo3; Resposta1Canvas.GetComponent <Text>().text = Resposta1Grupo3; Resposta2Canvas.GetComponent <Text>().text = Resposta2Grupo3; Resposta3Canvas.GetComponent <Text>().text = Resposta3Grupo3; theAnswer = theAnswerGrupo3; } if (Interactable && myAnswer == SelectAnswer.None) { if (Input.GetKeyDown(KeyCode.Alpha1) || (Input.GetKeyDown(KeyCode.Joystick1Button0))) { myAnswer = SelectAnswer.First; } if (Input.GetKeyDown(KeyCode.Alpha2) || (Input.GetKeyDown(KeyCode.Joystick1Button1))) { myAnswer = SelectAnswer.Second; } if (Input.GetKeyDown(KeyCode.Alpha3) || (Input.GetKeyDown(KeyCode.Joystick1Button2))) { myAnswer = SelectAnswer.Third; } } if (myAnswer != SelectAnswer.None) { gameObject.GetComponent <Animator>().SetBool("Open", true); Door.GetComponent <Animator>().SetBool("Open", true); if (myAnswer == theAnswer && loop == true) { loop = false; gameObject.GetComponentInChildren <MeshRenderer>().material = Green; DoorBonus.GetComponent <Animator>().SetBool("Open", true); gameManager.CorrectCounter++; } else if (myAnswer != theAnswer && loop == true) { gameObject.GetComponentInChildren <MeshRenderer>().material = Red; } } }
void Start() { Canvas.SetActive(false); LinesGrupo1.SetActive(false); LinesGrupo2.SetActive(false); LinesGrupo3.SetActive(false); myAnswer = SelectAnswer.None; }
/// <summary> /// Обработчик нажатия на элемент списка вариантов ответов /// </summary> /// <param name="sender">Источник события</param> /// <param name="e">Параметры события</param> private void AnswerTapped(object sender, ItemTappedEventArgs e) { var selectedAnswer = (Tuple <int, string>)AnswersListView.SelectedItem; if (!_selectedAnswers.Contains(selectedAnswer)) { if (_selectionMode == SelectionMode.Single) { _selectedAnswers.Clear(); } _selectedAnswers.Add(selectedAnswer); SelectAnswer?.Invoke(); } }
public async Task ReturnFailureForInvalidRoundStatus() { var baseMock = BaseGameRequestsValidatorMock.CreateMock(); var playerAnswersRepo = PlayerAnswersRepositoryMock.Create().Object; var roundOnwerRuleMock = RoundOwnerRuleMock.Create <SelectAnswer>(); var gameRoundRepository = GameRoundsRepositoryMock.Create( status: Common.Enums.GameRoundStatusEnum.InProgress).Object; var validator = new SelectAnswerValidator(baseMock.Object, roundOnwerRuleMock.Object, playerAnswersRepo, gameRoundRepository); var request = new SelectAnswer { GameRoundId = 1, UserId = 1, GameId = 1, }; var result = await validator.Validate(request); Assert.False(result.IsSuccessful); Assert.Equal(ValidatorErrors.Games.InvalidGameRoundStatus, result.Error); }
public async Task ReturnSuccessForValidData() { var baseMock = BaseGameRequestsValidatorMock.CreateMock(); var playerAnswersRepo = PlayerAnswersRepositoryMock.Create().Object; var roundOnwerRuleMock = RoundOwnerRuleMock.Create <SelectAnswer>(); var gameRoundRepository = GameRoundsRepositoryMock.Create( status: Common.Enums.GameRoundStatusEnum.Selection).Object; var validator = new SelectAnswerValidator(baseMock.Object, roundOnwerRuleMock.Object, playerAnswersRepo, gameRoundRepository); var request = new SelectAnswer { GameRoundId = 1, UserId = 1, GameId = 1, }; var result = await validator.Validate(request); Assert.True(result.IsSuccessful); baseMock.Verify(x => x.Validate(request)); roundOnwerRuleMock.Verify(x => x.Validate(request)); }
public async Task <SelectAnswerResult> Handle(SelectAnswer request, CancellationToken cancellationToken) { using (var transaction = repositoryTransactionsFactory.CreateTransaction()) { var validationResult = await requestValidator.Validate(request); if (!validationResult.IsSuccessful) { return(new SelectAnswerResult(validationResult.Error)); } var answerSelected = await playerAnswersRepository.MarkAnswerAsSelected(request.PlayerAnswerId); if (!answerSelected) { return(new SelectAnswerResult(GameErrors.SelectAnswerFailed)); } var pointsAddedResult = await playerAnswersRepository.AddPointForAnswer(request.PlayerAnswerId, request.GameRoundId); if (!pointsAddedResult.IsSuccessful) { return(new SelectAnswerResult(GameErrors.CouldNotAddPointToPlayer)); } var updateWinnerResult = await gameRoundsRepository.SelectRoundWinner(request.GameRoundId, pointsAddedResult.PlayerPoints.PlayerId); if (!updateWinnerResult) { return(new SelectAnswerResult(GameErrors.RoundWinnerSelectionFailed)); } var game = await gamesRepository.GetGameById(request.GameId); if (pointsAddedResult.PlayerPoints.Points < game.PointsLimit) { var createNewRoundResult = await gameRoundCreator .CreateRound(request.GameId, request.GameRoundId); if (!createNewRoundResult.IsSuccessful) { return(new SelectAnswerResult(createNewRoundResult.Error)); } var createCardsResult = await playerCardsCreator.CreateCards(request.GameId); if (!createCardsResult.IsSuccessful) { return(new SelectAnswerResult(createCardsResult.Error)); } } else { var endGameResult = await gamesRepository .EndGame(request.GameId, pointsAddedResult.PlayerPoints.UserId); if (!endGameResult) { return(new SelectAnswerResult(GameErrors.GameCouldNotBeEnded)); } } var checkpoint = await gameCheckpointUpdater.Update(request.GameId, nameof(SelectAnswer)); transaction.CommitTransaction(); return(new SelectAnswerResult()); } }