An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
public class EventHandlerInfoAttribute : Attribute
{
public EventHandlerInfoAttribute(string category, string eventHandlerName, string helpText)
{
this.Category = category;
this.EventHandlerName = eventHandlerName;
this.HelpText = helpText;
}
public string Category { get; set; }
public string EventHandlerName { get; set; }
public string HelpText { get; set; }
}
/**
* A Sequence may have an associated Event Handler which starts executing the sequence when
* a specific event occurs.
* To create a custom Event Handler, simply subclass EventHandler and call the ExecuteSequence() method
* when the event occurs.
* Add an EventHandlerInfo attibute and your new EventHandler class will automatically appear in the
* 'Start Event' dropdown menu when a sequence is selected.
*/
public class EventHandler : MonoBehaviour
{
[HideInInspector]
public Sequence parentSequence;
/**
* The Event Handler should call this method when the event is detected.
*/
public virtual bool ExecuteSequence()
{
if (parentSequence == null)
{
return false;
}
FungusScript fungusScript = parentSequence.GetFungusScript();
return fungusScript.ExecuteSequence(parentSequence);
}
}
}