예제 #1
0
    public void CheckRightChoice(int choice)
    {
        InspectorEnd inspectorEnd = GetComponent <InspectorEnd>();

        if (inspectorEnd == null && choicesName.IndexOf(currentChoices[choice]) == rightChoice || inspectorEnd != null && uiManager.vignetteIconParent.childCount >= 4)
        {
            uiManager.FadeWhite(true);
            CurrentCharacterState = CharacterState.Listening;
            if (inspectorEnd == null)
            {
                uiManager.TellMemory(GameManager.Instance.GetMemoryByName(currentChoices[choice]));
            }
            else
            {
                uiManager.TellMemory(inspectorEnd.endMemory);
            }
        }
        else
        {
            CurrentCharacterState = CharacterState.Fail;
            LetsTalk();
        }

        currentChoices.RemoveAt(choice);
    }
예제 #2
0
    public void LetsTalk()
    {
        if (CurrentCharacterState == CharacterState.Walking)
        {
            CurrentCharacterState = CharacterState.Introducing;
        }

        InspectorEnd inspectorEnd = GetComponent <InspectorEnd>();

        if (inspectorEnd != null)
        {
            choicesName.Clear();
            if (uiManager.vignetteIconParent.childCount < 4)
            {
                choicesName.Add(inspectorEnd.notEnoughMemories);
                currentChoices = new List <string>(choicesName);
            }
            else
            {
                choicesName.Add(inspectorEnd.enoughMemories);
                currentChoices = new List <string>(choicesName);
            }
        }

        if (CurrentCharacterState == CharacterState.Introducing)
        {
            if (alreadyIntroduceOnce)
            {
                if (currentSentence < otherIntroSentences.Count)
                {
                    uiManager.ChangeChatBoxText(otherIntroSentences[currentSentence]);
                    currentSentence++;
                    if (!audioSource.isPlaying && saysomething != null && saysomething.Length > 0)
                    {
                        audioSource.Stop();
                        audioSource.PlayOneShot(saysomething[Random.Range(0, saysomething.Length)]);
                    }
                }
                else
                {
                    if (choicesName.Count > 0)
                    {
                        CurrentCharacterState = CharacterState.Asking;
                        currentSentence       = 0;
                        if (asksomething != null && asksomething.Length > 0)
                        {
                            audioSource.Stop();
                            audioSource.PlayOneShot(asksomething[Random.Range(0, asksomething.Length)]);
                        }
                        uiManager.AskSomething(currentChoices);
                    }
                    else
                    {
                        currentSentence       = 0;
                        CurrentCharacterState = CharacterState.Walking;
                        GameManager.Instance.ChangeState(GameManager.GameState.Walking);
                    }
                }
            }
            else
            {
                if (currentSentence < introSentences.Count)
                {
                    uiManager.ChangeChatBoxText(introSentences[currentSentence]);
                    currentSentence++;
                    if (!audioSource.isPlaying && saysomething != null && saysomething.Length > 0)
                    {
                        audioSource.Stop();
                        audioSource.PlayOneShot(saysomething[Random.Range(0, saysomething.Length)]);
                    }
                }
                else
                {
                    if (choicesName.Count > 0)
                    {
                        CurrentCharacterState = CharacterState.Asking;
                        if (asksomething != null && asksomething.Length > 0)
                        {
                            audioSource.Stop();
                            audioSource.PlayOneShot(asksomething[Random.Range(0, asksomething.Length)]);
                        }
                        currentSentence      = 0;
                        alreadyIntroduceOnce = true;
                        uiManager.AskSomething(currentChoices);
                    }
                    else
                    {
                        currentSentence       = 0;
                        alreadyIntroduceOnce  = true;
                        CurrentCharacterState = CharacterState.Walking;
                        GameManager.Instance.ChangeState(GameManager.GameState.Walking);
                    }
                }
            }
        }
        if (CurrentCharacterState == CharacterState.Succeed)
        {
            if (currentSentence < rightChoiceSentences.Count)
            {
                uiManager.ChangeChatBoxText(rightChoiceSentences[currentSentence]);
                currentSentence++;
                if (!audioSource.isPlaying && saysomething != null && saysomething.Length > 0)
                {
                    audioSource.Stop();
                    audioSource.PlayOneShot(saysomething[Random.Range(0, saysomething.Length)]);
                }
            }
            else
            {
                CurrentCharacterState = CharacterState.Walking;
                currentSentence       = 0;
                gameObject.layer      = 0;
                for (int i = 0; i < transform.childCount; i++)
                {
                    transform.GetChild(i).gameObject.layer = 0;
                }
                GameManager.Instance.ChangeState(GameManager.GameState.Walking);

                uiManager.GiveMemory(memoryIcon);
                //alreadyGiveTheirMemory = true;
            }
        }
        if (CurrentCharacterState == CharacterState.Fail)
        {
            if (currentSentence < badChoiceSentences.Count)
            {
                uiManager.ChangeChatBoxText(badChoiceSentences[currentSentence]);
                currentSentence++;
                if (!audioSource.isPlaying && saysomething != null && saysomething.Length > 0)
                {
                    audioSource.Stop();
                    audioSource.PlayOneShot(saysomething[Random.Range(0, saysomething.Length)]);
                }
            }
            else
            {
                CurrentCharacterState = CharacterState.Walking;
                currentSentence       = 0;
                GameManager.Instance.ChangeState(GameManager.GameState.Walking);
            }
        }
    }