예제 #1
0
 private void Awake()
 {
     if (isSingleton)
     {
         if (instance == null)
         {
             instance = this;
         }
         else if (instance != this)
         {
             Destroy(this);
         }
     }
     isActive    = false;
     agent       = null;
     movingAgent = null;
 }
예제 #2
0
        /// <summary>
        ///     This method is called automatically once the dialogue line queue is empty, but it can be called to end the dialogue abruptly.
        ///		calls the OnDialogueEnd event, unpauses the game (if the setting is on) and disables the dialogue box.
        /// </summary>
        public void EndDialogue()
        {
            dialogueBox.gameObject.SetActive(false);

            dialogueText.text = "";
            if (titleText)
            {
                titleText.text = "";
            }

            StopAllCoroutines();

            currentLine = null;
            isActive    = false;

            if (pauseDuringDialogue)
            {
                Time.timeScale = 1f;
            }

            OnDialogueEnd?.Invoke();

            // If an agent or movable was blocked, sets them free
            if (agent)
            {
                // Input cooldown is needed because it uses the same "Interactable" button
                agent.InputCooldown();
                agent.canInteract = true;
            }
            if (movingAgent)
            {
                FinalInferno.CharacterOW.PartyCanMove = true;
                //movingAgent.CanMove = true;
            }
            agent       = null;
            movingAgent = null;

            // Triggers dialogue AfterDialogue method
            dialogue.AfterDialogue();
        }
예제 #3
0
        /// <summary>
        ///     Starts the dialogue by adding all the dialogue lines from the current dialogue object to a Queue, calls the OnDialogueStart event, pauses the game (if the setting is active) and enables the dialogue box.
        ///     This overload is supposed to be used when there is a default dialogue sequence, since it uses the last set dialogue as the current dialogue.
        ///     Otherwise, use the StartDialogue(Dialogue dialogue) overload.
        /// </summary>
        public void StartDialogue(Agent _agent = null, FinalInferno.Movable _movingAgent = null)
        {
            // If an agent or movable is passed as parameter, they must have interactions and movement blocked
            if (_agent)
            {
                agent             = _agent;
                agent.canInteract = false;
            }
            if (_movingAgent)
            {
                movingAgent = _movingAgent;
                FinalInferno.CharacterOW.PartyCanMove = false;
                //movingAgent.CanMove = false;
            }

            OnDialogueStart?.Invoke();

            if (isActive)
            {
                EndDialogue();
            }

            if (pauseDuringDialogue)
            {
                Time.timeScale = 0f;
            }

            foreach (var line in dialogue.lines)
            {
                dialogueLines.Enqueue(line);
            }

            isActive = true;
            dialogueBox.gameObject.SetActive(true);
            StartCoroutine("NextLine");
        }
예제 #4
0
 /// <summary>
 ///     Starts the dialogue by adding all the dialogue lines from the current dialogue object to a Queue, calls the OnDialogueStart event, pauses the game (if the setting is active) and enables the dialogue box.
 ///     In case of a default dialogue (that repeats), you can also set the dialogue and use the StartDialogue() overload instead.
 /// </summary>
 /// <param name="dialogue"> The current dialogue scriptable object. </param>
 public void StartDialogue(Dialogue dialogue, Agent _agent = null, FinalInferno.Movable _movingAgent = null)
 {
     this.dialogue = dialogue;
     StartDialogue(_agent, _movingAgent);
 }