Page 1 of 1

User Contribution

Posted: Thu Oct 29, 2020 10:00 am
by Tony Li
User @ollymuk shared this ScenePortal subclass that checks if a quest node is in a specified state. If so, it uses the portal. If not, it plays a Dialogue System conversation.

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers;
using PixelCrushers.QuestMachine;
using PixelCrushers.DialogueSystem;

public class QuestScenePortal : ScenePortal
{
    [Header("Quest Items")]
    [Tooltip("The Quest ID as STRING.")]
    public string QuestID;
    [Tooltip("The Quest Node ID as STRING.")]
    public string NodeID;
	[Tooltip("The Quest Node must be in this state.")]
	public QuestNodeState RequiredState = QuestNodeState.Active;

    [Header("Conversation Items")]
    [Tooltip("The conversation to show if Quest not Active as STRING")]
    [ConversationPopup]
    public string ConversationTitle;
    [Tooltip("The conversation entry point as INT")]
    public int ConversationEntryID=0;

    public override void UsePortal()
    {
        
        if (QuestMachine.GetQuestNodeState(QuestID, NodeID) == RequiredState)
        {

            base.UsePortal();
        }
        else
        {

            PixelCrushers.DialogueSystem.DialogueManager.StartConversation(ConversationTitle,null,null,ConversationEntryID);
        }
    }

}