Ejemplo n.º 1
0
 private IEnumerator HandleQuestionButtonClick(int index)
 {
     leftPlayButton.GetComponent<Animator>().SetTrigger("disappear");
     rightPlayButton.GetComponent<Animator>().SetTrigger("disappear");
     bool correct = SessionLogic.HandleSelection(index);
     if (correct)
     {
         if (index == 0)
         {
             leftCharacter.EmitLove();
         }
         else
         {
             rightCharacter.EmitLove();
         }
     }
     if (index == 0) leftCharacter.Talk = true;
     else if (index == 1) rightCharacter.Talk = true;
     SessionLogic.PersonType type = SessionLogic.GetPersonType(index);
     if (type == SessionLogic.PersonType.Male)
         yield return new WaitForSeconds(MaleClientSpeechWaitTime);
     else
         yield return new WaitForSeconds(FemaleClientSpeechWaitTime);
     if (index == 0) leftCharacter.Talk = false;
     else if (index == 1) rightCharacter.Talk = false;
     if (SessionLogic.HasSessionEnded())
     {
         StartCoroutine(ChangeState(GameState.PlaySessionEnded));
     }
     else
     {
         yield return new WaitForSeconds(1);
         WindowsVoice.getInstance().speak("You", SessionLogic.GetDoctorPrefix(), PhraseGenerator.getDoctorPhrase());
         yield return new WaitForSeconds(DoctorSpeechWaitTime);
         leftPlayButton.GetComponent<Animator>().SetTrigger("appear");
         rightPlayButton.GetComponent<Animator>().SetTrigger("appear");
         yield return new WaitForSeconds(0.5f);
     }
 }
Ejemplo n.º 2
0
        private IEnumerator ChangeState(GameState targetState)
        {
            switch (targetState)
            {
                case GameState.Started:
                    {
                        SessionLogic.InitSession();
                        PhraseGenerator.generatePhrases();
                        var parent = leftCharacter.transform.parent;


                        GameObject tempLeft;
                        GameObject tempRight;
                        var leftTrans = leftCharacter.transform;
                        var rightTrans = rightCharacter.transform;
                        if (SessionLogic.GetPersonType(0) == SessionLogic.PersonType.Male)
                        {
                            tempLeft = GameObject.Instantiate(malePrefab, leftTrans.position, leftTrans.rotation, parent);
                            tempLeft.transform.localScale = new Vector3(tempLeft.transform.localScale.x * -1, tempLeft.transform.localScale.y, tempLeft.transform.localScale.z);
                        }
                        else
                            tempLeft = GameObject.Instantiate(femalePrefab, leftTrans.position, leftTrans.rotation, parent);
                        if (SessionLogic.GetPersonType(1) == SessionLogic.PersonType.Male)
                            tempRight = GameObject.Instantiate(malePrefab, rightTrans.position, rightTrans.rotation, parent);
                        else
                        {
                            tempRight = GameObject.Instantiate(femalePrefab, rightTrans.position, rightTrans.rotation, parent);
                            tempRight.transform.localScale = new Vector3(tempRight.transform.localScale.x * -1, tempRight.transform.localScale.y, tempRight.transform.localScale.z);
                        }
                        Destroy(leftCharacter.gameObject);
                        Destroy(rightCharacter.gameObject);
                        yield return null;
                        leftCharacter = tempLeft.GetComponent<CharacterControllerGGJ>();
                        rightCharacter = tempRight.GetComponent<CharacterControllerGGJ>();
                        leftPlayButton = leftCharacter.playButton;
                        rightPlayButton = rightCharacter.playButton;
                        leftCharacter.index = 0;
                        rightCharacter.index = 1;
                        if (leftCharacter == null || rightCharacter == null)
                            Debug.Log("no component");

                        cameraController.FadeInCamera();
                        yield return new WaitForSeconds(1);
                        gameState = targetState;
                        break;
                    }
                case GameState.StartPlaySession:
                    {
                        gameState = GameState.PlaySessionStarted;
                        WindowsVoice.getInstance().speak("You", SessionLogic.GetDoctorPrefix(), PhraseGenerator.getPhrase("DoctorStart"));
                        yield return new WaitForSeconds(DoctorSpeechWaitTime);
                        leftPlayButton.GetComponent<Animator>().SetTrigger("appear");
                        rightPlayButton.GetComponent<Animator>().SetTrigger("appear");
                        gameState = GameState.PlaySessionRunning;
                        break;
                    }
                case GameState.PlaySessionEnded:
                    {
                        WindowsVoice.getInstance().speak("You", SessionLogic.GetDoctorPrefix(), PhraseGenerator.getPhrase("DoctorEnd"));
                        yield return new WaitForSeconds(DoctorSpeechWaitTime);
                        cameraController.FadeOutCamera();
                        yield return new WaitForSeconds(1);
                        playButton.SetActive(true);
                        subtitle.text = "";
                        gameState = targetState;
                        break;
                    }
                default:
                    break;
            }
        }