Exemple #1
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Z) && !isInConversation)
        {
            metBefore = false;
            isAngry   = false;
        }

        if (Input.GetKeyDown(KeyCode.F) && !isInConversation)
        {
            DialogueSystem.ResetConversation();
            isInConversation = true;
            (showPlayer ? PlayerContainer : NpcContainer).SetActive(true);
        }

        if (showingSecondaryScreen)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                showingSecondaryScreen = false;
                SecondaryScreen.SetActive(false);
            }
            return;
        }

        if (!isInConversation || isPlayerChoosing)
        {
            return;
        }
        if (shouldShowText)
        {
            (showPlayer ? PlayerContainer : NpcContainer).SetActive(true);
            (showPlayer ? PlayerText : NpcText).gameObject.SetActive(true);
            (showPlayer ? PlayerText : NpcText).text = textToShow;
            showingText    = true;
            shouldShowText = false;
        }

        if (showingText)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                showingText = false;
                (showPlayer ? PlayerContainer : NpcContainer).SetActive(false);
                (showPlayer ? PlayerText : NpcText).gameObject.SetActive(false);
            }
        }
        else
        {
            if (DialogueSystem.IsConversationDone())
            {
                isInConversation = false;
                (showPlayer ? PlayerContainer : NpcContainer).SetActive(false);
                return;
            }

            var isNpc = DialogueSystem.IsCurrentNpc();
            if (isNpc)
            {
                var currentActor = DialogueSystem.GetCurrentActor();
                showPlayer     = false;
                shouldShowText = true;
                textToShow     = DialogueSystem.ProgressNpc();
                NpcName.text   = currentActor.Name;
            }
            else
            {
                var currentLines = DialogueSystem.GetCurrentLines();
                isPlayerChoosing = true;
                PlayerContainer.SetActive(true);
                LineController.gameObject.SetActive(true);
                LineController.Initialize(currentLines);
            }
        }
    }