User Contribution

Announcements, support questions, and discussion for Quest Machine.
Post Reply
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

User Contribution

Post 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);
        }
    }

}
Post Reply