Ejemplo n.º 1
0
 public static IEnumerable <IEvent> Create(QuestionState state, Guid questionId, string tagName)
 {
     if (state.Has(tagName, questionId) == false)
     {
         yield return(new TagCreated(questionId, tagName));
     }
 }
Ejemplo n.º 2
0
 void gameResume()
 {
     if (State != QuestionState.Finish)
     {
         State = previousState;
     }
 }
Ejemplo n.º 3
0
 void gameStart()
 {
     currentLevel = 1;
     cat.AwakeUpNow();
     State = QuestionState.GenerateQuestion;
     setupActivateAnswer(getTotalAnswer(currentLevel));
     StartCoroutine(generateQuestion());
 }
Ejemplo n.º 4
0
    public override void Init(Object obj = null)
    {
        instance = this;

        StressApp.instance.canvasController.SetScreen("TemplateQuestion_Screen");

        Questionaire.Get().OnEnterQuestionaire();

        //StressApp.instance.canvasController.GetScreen("TemplateQuestion_Screen").GetComponent<TemplateQuestion_Screen>().Init();
    }
Ejemplo n.º 5
0
        public void GameMain()
        {
            SendPlayer1(new GameState {
                Tag = GameTag.Started
            });
            SendPlayer2(new GameState {
                Tag = GameTag.Started
            });

            Thread.Sleep(500);
            var qns = new QuestionRepo();

            for (var i = 0; i < 5; i++)
            {
                var question = qns.GetQuestion();
                var qnState  = new QuestionState
                {
                    Answers = question.Answers,
                    Title   = question.Title
                };
                LastQuestionAskedTime = DateTime.Now;

                SendPlayer1(new GameState
                {
                    Tag        = GameTag.QuestionStart,
                    Question   = qnState,
                    LastAnswer = LastQuestionAsked?.Answers[LastQuestionAsked.AnswerIndex]
                });
                SendPlayer2(new GameState
                {
                    Tag        = GameTag.QuestionStart,
                    Question   = qnState,
                    LastAnswer = LastQuestionAsked?.Answers[LastQuestionAsked.AnswerIndex]
                });

                Thread.Sleep(QuestionDuration);

                if (Player1Answer?.ChosenIndex == question.AnswerIndex)
                {
                    Player1Score += (int)Score(Player1AnswerTime);
                }

                if (Player2Answer?.ChosenIndex == question.AnswerIndex)
                {
                    Player2Score += (int)Score(Player2AnswerTime);
                }

                Player1Answer     = null;
                Player2Answer     = null;
                Player1AnswerTime = DateTime.MinValue;
                Player2AnswerTime = DateTime.MinValue;
                LastQuestionAsked = question;
            }
            EndGame();
        }
Ejemplo n.º 6
0
        public void CheckAnswer_WrongAnswer_ReturnsFalse()
        {
            QuestionItem item = new QuestionItem {
                Question = "1", Answer = "42"
            };
            QuestionState state = BuildQuestionState(item);

            bool result = state.CheckAnswer("incorect answer");

            Assert.IsFalse(result);
        }
Ejemplo n.º 7
0
        public void CheckAnswer_CorrectAnswer_ReturnsTrue()
        {
            QuestionItem item = new QuestionItem {
                Question = "1", Answer = "42"
            };
            QuestionState state = BuildQuestionState(item);

            bool result = state.CheckAnswer("42");

            Assert.IsTrue(result);
        }
Ejemplo n.º 8
0
        public void IsQuestionAnswered_NoAnswer_ReturnsFalse()
        {
            QuestionItem item = new QuestionItem {
                Question = "1", Answer = "42"
            };
            QuestionState state = BuildQuestionState(item);


            bool result = state.HasQuestionBeenAnswered;

            Assert.IsFalse(result);
        }
Ejemplo n.º 9
0
 void gameReset()
 {
     currentLevel = 1;
     if (State == QuestionState.Init)
     {
         return;
     }
     State = QuestionState.Finish;
     StopAllCoroutines();
     cat.AwakeUpNow();
     closeAllAnswer();
     infoSign.Close();
 }
Ejemplo n.º 10
0
        public static QuestionState ToApiModel(this QuestionStateData questionStateData)
        {
            var result = new QuestionState
            {
                ProgressId               = questionStateData.ProgressId,
                CourseId                 = questionStateData.CourseId,
                LessonId                 = questionStateData.LessonId,
                StepId                   = questionStateData.StepId,
                QuestionId               = questionStateData.QuestionId,
                CurrentAttemptsCount     = questionStateData.CurrentAttemptsCount,
                Passed                   = questionStateData.Passed,
                CorrectlySelectedAnswers = new List <int>(questionStateData.CorrectlySelectedAnswers),
                SelectedAnswers          = new List <int>(questionStateData.SelectedAnswers)
            };

            return(result);
        }
Ejemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        State = QuestionState.Init;
        gController.gResetEvent    += gameReset;
        gController.gStartEvent    += gameStart;
        gController.gGameOverEvent += gameOver;
        gController.gPauseEvent    += gamePause;
        gController.gUnPauseEvent  += gameResume;
        //gController.gCountdownEvent += PreGameStart;

        gController.SetMoneyMultiplier(1);
        gController.SetEXPMultiplier(1);
        gController.SetGameID(5);
        gController.mGameReset();

        //gController.mGameCountDown();
    }
Ejemplo n.º 12
0
        private void GotoState(QuestionState questionState)
        {
            switch (questionState)
            {
                case QuestionState.PreQuestionShown:
                    SetViewModelContent("Раскрыть вопрос", string.Format("{0} - {1}", _viewModel.Model.QuestionGroup.Name, _viewModel.Model.Cost));
                    break;
                case QuestionState.QuestionShown:
                    SetViewModelContent("Раскрыть ответ", _viewModel.Model.Text, _viewModel.Model.TextImage);
                    break;
                case QuestionState.AnswerShown:
                    SetViewModelContent("Продолжить", _viewModel.Model.Answer, _viewModel.Model.AnswerImage);
                    break;
            }

            _currentState = questionState;
        }
Ejemplo n.º 13
0
    private void CheckJudge2()
    {
        if (false == m_LevelGeneratorPtr.m_QuestionTable.ContainsKey(m_QuestionString))
        {
            return;
        }

        string minAnimKey            = "";
        QuestionTableStruct question = m_LevelGeneratorPtr.m_QuestionTable[m_QuestionString];
        int detectIndex = 0;

        Debug.Log("question.m_DetectionZones" + question.m_DetectionZones.Count);
        Dictionary <string, DetectionPose> .Enumerator iQuestion = question.m_DetectionZones.GetEnumerator();
        while (iQuestion.MoveNext())
        {
            if (detectIndex == m_AnswerIndex)
            {
                minAnimKey = iQuestion.Current.Key;
                Debug.Log("m_AnswerIndex=" + m_AnswerIndex);
                break;
            }
            ++detectIndex;
        }

        // Debug.Log( "minAnimKey" + minAnimKey ) ;
        if (0 != minAnimKey.Length)
        {
            m_ResultString = minAnimKey;
            Debug.Log("m_ResultString" + m_ResultString);
            m_AnimationPlayer.Setup(m_ResultString);
            if (-1 != m_ResultString.IndexOf("_f"))
            {
                // show false alarm
                ShowGUITexture.Show(m_GUIWrong, true, true, true);
                m_GUIAgain.gameObject.SendMessage("ClearIsDown");
                m_QuestionState = QuestionState.FalseAnimation;
            }
            else
            {
                ShowGUITexture.Show(m_GUICorrect, true, true, true);
                m_QuestionState = QuestionState.CorrectAnimation;
            }
        }
    }
Ejemplo n.º 14
0
    private IEnumerator showResultCo()
    {
        cat.FinishLevel();
        activateAnswerList.ForEach((a) => { a.ShowResult(); });

        if (State != QuestionState.Finish)
        {
            State = QuestionState.Result;

            yield return(new WaitForSeconds(3f));

            while (State != QuestionState.Result)
            {
                yield return(null);
            }

            StartCoroutine(generateQuestion());
        }
    }
Ejemplo n.º 15
0
    private IEnumerator generateQuestion()
    {
        State = QuestionState.GenerateQuestion;
        currentQuestionType = (InfoSign.SignType)Random.Range(0, 5);

        setupActivateAnswer(getTotalAnswer(currentLevel));

        Shuffle(activateAnswerList);

        var correctAnswer = answerLeft = getCorrectAnswer(currentLevel);

        startTime = timeLeft = getTimeToAnswer(currentLevel);

        infoSign.SwitchSign(currentQuestionType);

        cat.ChangeLevel(currentLevel, currentQuestionType);

        foreach (var answer in activateAnswerList)
        {
            if (correctAnswer > 0)
            {
                answer.Setup(currentQuestionType);
                correctAnswer--;
            }
            else
            {
                var randomAnswerType = (InfoSign.SignType)Random.Range(0, 5);
                while (randomAnswerType == currentQuestionType)
                {
                    randomAnswerType = (InfoSign.SignType)Random.Range(0, 5);
                }
                answer.Setup(randomAnswerType);
            }
        }
        MainSoundSrc.PlaySound("Signchange2");

        while (State != QuestionState.GenerateQuestion)
        {
            yield return(null);
        }

        State = QuestionState.WaitingForAnswer;
    }
Ejemplo n.º 16
0
        public async void PostUserAnswerByClient()
        {
            var registrationInfo = new RegistrationInfo {
                Login = "******"
            };

            await client.RegisterAsync(registrationInfo);

            var userId = await client.GetIdByLoginAsync(ticket, registrationInfo.Login);

            var progress = await client.StartCourseAsync(ticket, firstCourse.Id, userId);

            var answer = new Answer {
                QuestionId = 0, SelectedAnswers = new List <int> {
                    0
                }
            };

            var result = await client.SendAnswerAsync(ticket, progress.Id, lessonId : 0, stepId : 0, answer : answer);

            var expectedResult = new QuestionState
            {
                CorrectlySelectedAnswers = new List <int> {
                    0
                },
                CourseId             = firstCourse.Id,
                CurrentAttemptsCount = 1,
                LessonId             = 0,
                Passed          = true,
                ProgressId      = progress.Id,
                QuestionId      = 0,
                StepId          = 0,
                SelectedAnswers = new List <int> {
                    0
                }
            };

            var compareLogic  = new CompareLogic();
            var compareResult = compareLogic.Compare(expectedResult, result);

            Assert.True(compareResult.AreEqual);
        }
Ejemplo n.º 17
0
        private void GotoState(QuestionState questionState)
        {
            switch (questionState)
            {
            case QuestionState.PreQuestionShown:
                SetViewModelContent("Раскрыть вопрос",
                                    string.Format(_viewModel.Model.Cost != 0 ? "{0} - {1}" : "{0}", _viewModel.Model.QuestionGroup.Name,
                                                  _viewModel.Model.Cost));
                break;

            case QuestionState.QuestionShown:
                SetViewModelContent("Раскрыть ответ", _viewModel.Model.Text, _viewModel.Model.TextImage);
                break;

            case QuestionState.AnswerShown:
                SetViewModelContent("Продолжить", _viewModel.Model.Answer, _viewModel.Model.AnswerImage);
                break;
            }

            _currentState = questionState;
        }
Ejemplo n.º 18
0
        private void AssertQuestionStateInProgrees_Like(Ticket userTicket, QuestionState questionState)
        {
            var progress = client.GetCourseProgressAsync(userTicket, questionState.ProgressId).Result;

            Assert.NotNull(progress.LessonProgresses);

            var firstLessonProgress = progress.LessonProgresses.FirstOrDefault(x => x.LessonId == questionState.LessonId);

            Assert.NotNull(firstLessonProgress);

            var firstStepProgress = firstLessonProgress
                                    .StepProgresses
                                    .FirstOrDefault(x => x.Id == questionState.StepId);

            Assert.NotNull(firstStepProgress);

            var firstQuestionState = firstStepProgress
                                     .QuestionStates
                                     .FirstOrDefault(x => x.QuestionId == questionState.QuestionId);

            Assert.NotNull(firstQuestionState);

            Assert.Equal(firstQuestionState, questionState, new JsonComparer <QuestionState>());
        }
Ejemplo n.º 19
0
 public Question MarkAs(QuestionState state, Question question)
 {
     question.State = state;
     return(questionRepository.Update(question));
 }
Ejemplo n.º 20
0
 public void AskForCardUsage(Prompt prompt, ICardUsageVerifier verifier, int timeOutSeconds)
 {
     CurrentQuestionState = QuestionState.AskForCardUsage;
     Gamer.ReceiveAsync();
     if (Gamer.OnlineStatus != OnlineStatus.Online) AnswerCardUsage(null, null, null);
 }
Ejemplo n.º 21
0
 public void AskForMultipleChoice(Prompt prompt, List<OptionPrompt> questions, int timeOutSeconds)
 {
     CurrentQuestionState = QuestionState.AskForMultipleChoice;
     Gamer.ReceiveAsync();
     if (Gamer.OnlineStatus != OnlineStatus.Online) AnswerMultipleChoice(0);
 }
Ejemplo n.º 22
0
 public void Freeze()
 {
     CurrentQuestionState = QuestionState.None;
 }
Ejemplo n.º 23
0
 private void OnGameDataPacketReceived(GameDataPacket packet)
 {
     lock (receiveInProcess)
     {
         if (packet is GameResponse)
         {
             if (CurrentQuestionState == QuestionState.None) return;
             Game.CurrentGame.HandCardSwitcher.HandleHandCardMovements();
             var state = CurrentQuestionState;
             switch (state)
             {
                 case QuestionState.AskForCardUsage:
                     var response = packet as AskForCardUsageResponse;
                     if (response == null || response.Id != QuestionId)
                     {
                         Gamer.ReceiveAsync();
                         break;
                     }
                     ISkill skill;
                     List<Card> cards;
                     List<Player> players;
                     response.ToAnswer(out skill, out cards, out players, PlayerId);
                     CurrentQuestionState = QuestionState.None;
                     AnswerCardUsage(skill, cards, players);
                     break;
                 case QuestionState.AskForCardChoice:
                     var response2 = packet as AskForCardChoiceResponse;
                     if (response2 == null || response2.Id != QuestionId)
                     {
                         Gamer.ReceiveAsync();
                         break;
                     }
                     int opt;
                     var result = response2.ToAnswer(PlayerId, out opt);
                     if (currentChoiceOptions != null) currentChoiceOptions.OptionResult = opt;
                     CurrentQuestionState = QuestionState.None;
                     AnswerCardChoice(result);
                     break;
                 case QuestionState.AskForMultipleChoice:
                     var response3 = packet as AskForMultipleChoiceResponse;
                     if (response3 == null || response3.Id != QuestionId)
                     {
                         Gamer.ReceiveAsync();
                         break;
                     }
                     CurrentQuestionState = QuestionState.None;
                     AnswerMultipleChoice(response3.ChoiceIndex);
                     break;
             }
         }
         else if (packet is CardRearrangementNotification)
         {
             for (int i = 0; i < Game.CurrentGame.GameServer.MaxClients; i++)
             {
                 if (i != PlayerId) Game.CurrentGame.GameServer.SendPacket(i, packet);
             }
         }
         else if (packet is HandCardMovementNotification)
         {
             var notif = packet as HandCardMovementNotification;
             Game.CurrentGame.HandCardSwitcher.QueueHandCardMovement(notif);
         }
     }
 }
Ejemplo n.º 24
0
        public QuestionPopUp(string[] questionDetails)
        {
            QuestionDetails = questionDetails;
            correctAnsID = questionDetails[4];

            QuestionBox = new UiTextBox(Art.UiFont, questionDetails[0], new Vector2(250, 150), Color.White, Art.TextBoxBackGround, false);
            CorrectBox = new UiTextBox(Art.UiFont, "Correct! A soldier joins your cause!\n\nClick to continue", new Vector2(250, 150), Color.White, Art.TextBoxBackGround, false);
            WrongBox = new UiTextBox(Art.UiFont, "Wrong! Better luck next time!\n\nClick to continue", new Vector2(250, 150), Color.White, Art.TextBoxBackGround, false);
            Answers.Add(new UiButton(Art.UiFont, new Vector2(350, 400), new Vector2(300, 100), Art.TextBoxBackGround, Art.ButtonEffectTexture, "Ans1", true));
            Answers.Add(new UiButton(Art.UiFont, new Vector2(350, 520), new Vector2(300, 100), Art.TextBoxBackGround, Art.ButtonEffectTexture, "Ans2", true));
            Answers.Add(new UiButton(Art.UiFont, new Vector2(350, 640), new Vector2(300, 100), Art.TextBoxBackGround, Art.ButtonEffectTexture, "Ans3", true));

            QuestionBox.TextBoxSize = new Vector2(500, 200);
            QuestionBox.StringOffset = new Vector2(10, 0);
            QuestionBox.LineWrapper();

            CorrectBox.TextBoxSize = new Vector2(500, 200);
            CorrectBox.StringOffset = new Vector2(10, 0);
            CorrectBox.LineWrapper();

            WrongBox.TextBoxSize = new Vector2(500, 200);
            WrongBox.StringOffset = new Vector2(10, 0);
            WrongBox.LineWrapper();


            Answers[0].StringText = questionDetails[1];
            Answers[0].TextBoxInfo = "An answer box.";
            Answers[1].StringText = questionDetails[2];
            Answers[1].TextBoxInfo = "An answer box.";
            Answers[2].StringText = questionDetails[3];
            Answers[2].TextBoxInfo = "An answer box.";

            foreach (UiButton button in Answers)
            {
                UiButtonMessenger.RegisterButton(button);
                button.StringOffset = new Vector2(10, 0);
                button.TextBoxRectangleSet();
                button.LineWrapper();

                button.SetButtonState = UiButton.UiButtonStates.Button_Up;
            }

            State = QuestionState.Asking;
        }
Ejemplo n.º 25
0
    private void DetectAmongAnswers()
    {
        // 判斷滑鼠在哪裡
        // 依照question的answer的數目
        if( false == m_LevelGeneratorPtr.m_QuestionTable.ContainsKey( m_QuestionString ) )
            return ;

        QuestionTableStruct question = m_LevelGeneratorPtr.m_QuestionTable[ m_QuestionString ] ;
        int answerNum = question.m_DetectionZones.Count ;
        float ratioOfMouse = (float) Input.mousePosition.x / (float) Camera.main.pixelWidth ;
        m_AnswerIndex = (int)( ratioOfMouse * answerNum ) ;
        // Debug.Log( "DetectAmongAnswers() answerIndex= " + answerIndex ) ;
        // 決定question要顯示的透明半身圖
        string imagePath = "" ;
        int i = 0 ;
        foreach( DetectionPose pose in question.m_DetectionZones.Values )
        {
            if( i == m_AnswerIndex )
            {
                imagePath = pose.m_AnswerImagePath ;
                // Debug.Log( "DetectAmongAnswers() imagePath= " + imagePath ) ;
                break ;
            }
            ++i ;
        }

        // 調整answersymbol的位置
        if( null != m_GUIAnswerSymbol )
        {
            m_GUIAnswerSymbol.GetComponent<GUITexture>().pixelInset =
                new Rect( m_AnswerIndex * m_AnswerSymbolWidth ,
                    m_AnswerSymbolStartY ,
                    m_AnswerSymbolWidth ,
                    m_AnswerSymbolHeight ) ;

            /*if( true == m_GUIAnswerSymbol.guiTexture.pixelInset.Contains( new Vector2( Input.mousePosition.x , Input.mousePosition.y ) ) )
            {
                // Debug.LogError( "true == m_GUIAnswerSymbol.guiTexture.pixelInset.Contains" ) ;
                m_GUIAnswerDescription.guiText.color = Color.cyan ;
            }
            else
            */
            {
                m_GUIAnswerDescription.GetComponent<GUIText>().color = Color.red ;
            }

            m_GUIAnswerDescription.GetComponent<GUIText>().pixelOffset =
                new Vector2( m_AnswerIndex * m_AnswerSymbolWidth + m_AnswerSymbolWidth / 2 ,
                    m_AnswerDescriptionStartY ) ;

            ShowGUITexture.Show( m_GUIAnswerSymbol , true , true , true ) ;
            ShowGUITexture.Show( m_GUIAnswerMouseCursor , true , true , true ) ;
        }

        // switch and show the image
        if( 0 != imagePath.Length )
        {
            m_GUIQuestionZoneAnswer.GetComponent<GUITexture>().texture =
                (Texture2D) Resources.Load( "Texture/" + imagePath ) ;
            ShowGUITexture.Show( m_GUIQuestionZoneAnswer , true , true , true ) ;
        }

        // 如果滑鼠按下,則進入判斷流程
        if( true == Input.GetMouseButtonUp( 0 ) )
        {
            ShowGUITexture.Show( m_GUIAnswerSymbol , false , true , true ) ;
            ShowGUITexture.Show( m_GUIQuestionZoneAnswer , false , true , true ) ;
            ShowGUITexture.Show( m_GUIInstruction , false , true , true ) ;
            ShowGUITexture.Show( m_GUIAnswerMouseCursor , false , true , true ) ;

            // 把返回開啟
            ShowGUITexture.Show( m_GUIBack , true , true , true ) ;

            m_QuestionState = QuestionState.Judge ;
        }
    }
Ejemplo n.º 26
0
    // Update is called once per frame
    void Update()
    {
        switch( m_QuestionState )
        {
        case QuestionState.UnActive :

            if( null != m_GUIAnimationTexture )
            {
                m_GUIAnimationTexture.texture = null ;
            }

            {
                ShowGUITexture.Show( m_GUIQuestionZoneAnswer , false , true , true ) ;
                ShowGUITexture.Show( m_GUIWrong , false , true , true ) ;
                ShowGUITexture.Show( m_GUICorrect , false , true , true ) ;
                ShowGUITexture.Show( m_GUIInstruction , false , true , true ) ;
                ShowGUITexture.Show( m_GUIAgain , false , true , true ) ;
                ShowGUITexture.Show( m_GUIAnswerSymbol , false , true , true ) ;
                ShowGUITexture.Show( m_GUIAnswerMouseCursor , false , true , true ) ;

            }

            // show ready mark.
            m_GUIReady.enabled = true ;
            m_GUIReady.gameObject.SendMessage( "ClearIsDown" ) ;
            m_QuestionState = QuestionState.Ready ;
            break ;
        case QuestionState.Ready :

            {

                GUI_IsDown guiIsDown = m_GUIReady.gameObject.GetComponent<GUI_IsDown>() ;
                if( true == guiIsDown.m_IsDown && 0 != m_QuestionString.Length )
                {
                    // close ready sign
                    m_GUIReady.enabled = false ;
                    // play question
                    m_AnimationPlayer.Setup( m_QuestionString ) ;
                    ShowGUITexture.Show( m_GUIInstruction , true , true , true ) ;
                    string text = StrsManager.Get( m_InstructionQuestion ) ;
                    m_GUIInstruction.GetComponent<GUIText>().text = text ;

                    // 把返回關閉
                    ShowGUITexture.Show( m_GUIBack , false , true , true ) ;

                    m_QuestionState = QuestionState.QuestionAnimation ;
                }
            }
            break ;

        case QuestionState.QuestionAnimation :
            // wait for animation complete
            if( false == m_AnimationPlayer.m_IsActive )
            {
                // show drag sword sign
                ShowGUITexture.Show( m_GUIInstruction , true , true , true ) ;
                string text = StrsManager.Get( m_InstructionMoveSword ) ;
                m_GUIInstruction.GetComponent<GUIText>().text = text ;
                m_QuestionState = QuestionState.DecideTheAnswer ;
            }
            break ;

        case QuestionState.DecideTheAnswer :
            DetectAmongAnswers() ;
            UpdateMouseCursor() ;
            break ;

        case QuestionState.Judge :
            CheckJudge2() ;

            break ;

        case QuestionState.CorrectAnimation :

            if( false == m_AnimationPlayer.m_IsActive )
            {
                // show drag sword sign
                QuestionTableStruct question = m_LevelGeneratorPtr.m_QuestionTable[ m_QuestionString ] ;
                m_AnimationPlayer.Setup( question.m_FinishAnimationString ) ;
                m_QuestionState = QuestionState.FinishAnimation ;
            }

            break ;

        case QuestionState.FalseAnimation :
            if( false == m_AnimationPlayer.m_IsActive )
            {
                // show drag sword sign
                ShowGUITexture.Show( m_GUIAgain , true , true , true ) ;
            }

            GUI_IsDown guiIsDown = m_GUIAgain.gameObject.GetComponent<GUI_IsDown>() ;
            if( true == guiIsDown.m_IsDown )
            {
                m_QuestionState = QuestionState.UnActive ;
            }
            break ;

        case QuestionState.FinishAnimation :

            break ;

        }
    }
Ejemplo n.º 27
0
        public void Update()
        {
            if (State == QuestionState.Asking)
            {
                foreach (UiButton button in Answers)
                {
                    if (button.IsButtonDown())
                    {
                        if (button.GetButtonID == correctAnsID)
                        {
                            State = QuestionState.Correct;
                            WaveManager.questionsAnsweredCorrect++;
                            TroopManager.SpawnTroop();
                            QuestionPopUpManager.QuestionsArray.Remove(QuestionDetails);
                            GameManager.ModifyResources(WaveManager.WaveComposition.Count * 20);

                        }

                        else State = QuestionState.Wrong;

                        foreach (UiButton buttons in Answers)
                        {
                            UiButtonMessenger.RemoveButton(buttons.GetButtonID);
                        }
                    }
                }
            }

            else if (State == QuestionState.Correct || State == QuestionState.Wrong)
            {

                if(Input.WasLMBClicked)
                {
                    State = QuestionState.Done;
                    Input.Update();
                }
            }
        }
Ejemplo n.º 28
0
    private void CheckJudge2()
    {
        if( false == m_LevelGeneratorPtr.m_QuestionTable.ContainsKey( m_QuestionString ) )
            return ;

        string minAnimKey = "" ;
        QuestionTableStruct question = m_LevelGeneratorPtr.m_QuestionTable[ m_QuestionString ] ;
        int detectIndex = 0 ;
        Debug.Log( "question.m_DetectionZones" + question.m_DetectionZones.Count ) ;
        Dictionary< string , DetectionPose >.Enumerator iQuestion = question.m_DetectionZones.GetEnumerator() ;
        while( iQuestion.MoveNext() )
        {
            if( detectIndex == m_AnswerIndex )
            {
                minAnimKey = iQuestion.Current.Key ;
                Debug.Log( "m_AnswerIndex=" + m_AnswerIndex ) ;
                break ;
            }
            ++detectIndex ;
        }

        // Debug.Log( "minAnimKey" + minAnimKey ) ;
        if( 0 != minAnimKey.Length )
        {
            m_ResultString = minAnimKey ;
            Debug.Log( "m_ResultString" + m_ResultString ) ;
            m_AnimationPlayer.Setup( m_ResultString ) ;
            if( -1 != m_ResultString.IndexOf( "_f" ) )
            {
                // show false alarm
                ShowGUITexture.Show( m_GUIWrong , true , true , true ) ;
                m_GUIAgain.gameObject.SendMessage( "ClearIsDown" ) ;
                m_QuestionState = QuestionState.FalseAnimation ;
            }
            else
            {
                ShowGUITexture.Show( m_GUICorrect , true , true , true ) ;
                m_QuestionState = QuestionState.CorrectAnimation ;

            }

        }
    }
Ejemplo n.º 29
0
 public void AskForCardChoice(Prompt prompt, List<Cards.DeckPlace> sourceDecks, List<string> resultDeckNames, List<int> resultDeckMaximums, ICardChoiceVerifier verifier, int timeOutSeconds, AdditionalCardChoiceOptions options, CardChoiceRearrangeCallback callback)
 {
     currentChoiceOptions = options;
     CurrentQuestionState = QuestionState.AskForCardChoice;
     Gamer.ReceiveAsync();
     if (Gamer.OnlineStatus != OnlineStatus.Online) AnswerCardChoice(null);
 }
Ejemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        switch (m_QuestionState)
        {
        case QuestionState.UnActive:

            if (null != m_GUIAnimationTexture)
            {
                m_GUIAnimationTexture.texture = null;
            }

            {
                ShowGUITexture.Show(m_GUIQuestionZoneAnswer, false, true, true);
                ShowGUITexture.Show(m_GUIWrong, false, true, true);
                ShowGUITexture.Show(m_GUICorrect, false, true, true);
                ShowGUITexture.Show(m_GUIInstruction, false, true, true);
                ShowGUITexture.Show(m_GUIAgain, false, true, true);
                ShowGUITexture.Show(m_GUIAnswerSymbol, false, true, true);
                ShowGUITexture.Show(m_GUIAnswerMouseCursor, false, true, true);
            }

            // show ready mark.
            m_GUIReady.enabled = true;
            m_GUIReady.gameObject.SendMessage("ClearIsDown");
            m_QuestionState = QuestionState.Ready;
            break;

        case QuestionState.Ready:

        {
            GUI_IsDown guiIsDown = m_GUIReady.gameObject.GetComponent <GUI_IsDown>();
            if (true == guiIsDown.m_IsDown && 0 != m_QuestionString.Length)
            {
                // close ready sign
                m_GUIReady.enabled = false;
                // play question
                m_AnimationPlayer.Setup(m_QuestionString);
                ShowGUITexture.Show(m_GUIInstruction, true, true, true);
                string text = StrsManager.Get(m_InstructionQuestion);
                m_GUIInstruction.GetComponent <GUIText>().text = text;

                // 把返回關閉
                ShowGUITexture.Show(m_GUIBack, false, true, true);

                m_QuestionState = QuestionState.QuestionAnimation;
            }
        }
        break;

        case QuestionState.QuestionAnimation:
            // wait for animation complete
            if (false == m_AnimationPlayer.m_IsActive)
            {
                // show drag sword sign
                ShowGUITexture.Show(m_GUIInstruction, true, true, true);
                string text = StrsManager.Get(m_InstructionMoveSword);
                m_GUIInstruction.GetComponent <GUIText>().text = text;
                m_QuestionState = QuestionState.DecideTheAnswer;
            }
            break;

        case QuestionState.DecideTheAnswer:
            DetectAmongAnswers();
            UpdateMouseCursor();
            break;


        case QuestionState.Judge:
            CheckJudge2();


            break;

        case QuestionState.CorrectAnimation:

            if (false == m_AnimationPlayer.m_IsActive)
            {
                // show drag sword sign
                QuestionTableStruct question = m_LevelGeneratorPtr.m_QuestionTable[m_QuestionString];
                m_AnimationPlayer.Setup(question.m_FinishAnimationString);
                m_QuestionState = QuestionState.FinishAnimation;
            }

            break;

        case QuestionState.FalseAnimation:
            if (false == m_AnimationPlayer.m_IsActive)
            {
                // show drag sword sign
                ShowGUITexture.Show(m_GUIAgain, true, true, true);
            }

            GUI_IsDown guiIsDown = m_GUIAgain.gameObject.GetComponent <GUI_IsDown>();
            if (true == guiIsDown.m_IsDown)
            {
                m_QuestionState = QuestionState.UnActive;
            }
            break;

        case QuestionState.FinishAnimation:

            break;
        }
    }
Ejemplo n.º 31
0
 void gameOver()
 {
     State = QuestionState.Finish;
     closeAllAnswer();
     infoSign.Close();
 }
Ejemplo n.º 32
0
    private void DetectAmongAnswers()
    {
        // 判斷滑鼠在哪裡
        // 依照question的answer的數目
        if (false == m_LevelGeneratorPtr.m_QuestionTable.ContainsKey(m_QuestionString))
        {
            return;
        }

        QuestionTableStruct question = m_LevelGeneratorPtr.m_QuestionTable[m_QuestionString];
        int   answerNum    = question.m_DetectionZones.Count;
        float ratioOfMouse = (float)Input.mousePosition.x / (float)Camera.main.pixelWidth;

        m_AnswerIndex = (int)(ratioOfMouse * answerNum);
        // Debug.Log( "DetectAmongAnswers() answerIndex= " + answerIndex ) ;
        // 決定question要顯示的透明半身圖
        string imagePath = "";
        int    i         = 0;

        foreach (DetectionPose pose in question.m_DetectionZones.Values)
        {
            if (i == m_AnswerIndex)
            {
                imagePath = pose.m_AnswerImagePath;
                // Debug.Log( "DetectAmongAnswers() imagePath= " + imagePath ) ;
                break;
            }
            ++i;
        }


        // 調整answersymbol的位置
        if (null != m_GUIAnswerSymbol)
        {
            m_GUIAnswerSymbol.GetComponent <GUITexture>().pixelInset =
                new Rect(m_AnswerIndex * m_AnswerSymbolWidth,
                         m_AnswerSymbolStartY,
                         m_AnswerSymbolWidth,
                         m_AnswerSymbolHeight);

            /*if( true == m_GUIAnswerSymbol.guiTexture.pixelInset.Contains( new Vector2( Input.mousePosition.x , Input.mousePosition.y ) ) )
             * {
             *      // Debug.LogError( "true == m_GUIAnswerSymbol.guiTexture.pixelInset.Contains" ) ;
             *      m_GUIAnswerDescription.guiText.color = Color.cyan ;
             * }
             * else
             */
            {
                m_GUIAnswerDescription.GetComponent <GUIText>().color = Color.red;
            }


            m_GUIAnswerDescription.GetComponent <GUIText>().pixelOffset =
                new Vector2(m_AnswerIndex * m_AnswerSymbolWidth + m_AnswerSymbolWidth / 2,
                            m_AnswerDescriptionStartY);

            ShowGUITexture.Show(m_GUIAnswerSymbol, true, true, true);
            ShowGUITexture.Show(m_GUIAnswerMouseCursor, true, true, true);
        }

        // switch and show the image
        if (0 != imagePath.Length)
        {
            m_GUIQuestionZoneAnswer.GetComponent <GUITexture>().texture =
                (Texture2D)Resources.Load("Texture/" + imagePath);
            ShowGUITexture.Show(m_GUIQuestionZoneAnswer, true, true, true);
        }

        // 如果滑鼠按下,則進入判斷流程
        if (true == Input.GetMouseButtonUp(0))
        {
            ShowGUITexture.Show(m_GUIAnswerSymbol, false, true, true);
            ShowGUITexture.Show(m_GUIQuestionZoneAnswer, false, true, true);
            ShowGUITexture.Show(m_GUIInstruction, false, true, true);
            ShowGUITexture.Show(m_GUIAnswerMouseCursor, false, true, true);

            // 把返回開啟
            ShowGUITexture.Show(m_GUIBack, true, true, true);

            m_QuestionState = QuestionState.Judge;
        }
    }
Ejemplo n.º 33
0
 void gamePause()
 {
     previousState = State;
     State         = QuestionState.Pause;
 }