Browse Source

DialogInput uses IDialogInput interface

master
Christopher 8 years ago
parent
commit
06ed94cda7
  1. 82
      Assets/Fungus/Narrative/Scripts/DialogInput.cs
  2. 31
      Assets/Fungus/Narrative/Scripts/IDialogInput.cs
  3. 12
      Assets/Fungus/Narrative/Scripts/IDialogInput.cs.meta

82
Assets/Fungus/Narrative/Scripts/DialogInput.cs

@ -7,17 +7,9 @@ using UnityEngine.EventSystems;
namespace Fungus namespace Fungus
{ {
/// <summary> /// <summary>
/// Interface for listening for dialogue input events. /// Input handler for say dialogs.
/// </summary> /// </summary>
public interface IDialogInputListener public class DialogInput : MonoBehaviour, IDialogInput
{
void OnNextLineEvent();
}
/// <summary>
/// Input handler for say dialogues.
/// </summary>
public class DialogInput : MonoBehaviour
{ {
public enum ClickMode public enum ClickMode
{ {
@ -47,42 +39,6 @@ namespace Fungus
protected StandaloneInputModule currentStandaloneInputModule; protected StandaloneInputModule currentStandaloneInputModule;
/// <summary>
/// Trigger next line input event from script.
/// </summary>
public void SetNextLineFlag()
{
nextLineInputFlag = true;
}
/// <summary>
/// Set the dialog clicked flag (usually from an Event Trigger component in the dialog UI).
/// </summary>
public void SetDialogClickedFlag()
{
// Ignore repeat clicks for a short time to prevent accidentally clicking through the character dialogue
if (ignoreClickTimer > 0f)
{
return;
}
ignoreClickTimer = nextClickDelay;
// Only applies in Click On Dialog mode
if (clickMode == ClickMode.ClickOnDialog)
{
dialogClickedFlag = true;
}
}
public void SetButtonClickedFlag()
{
// Only applies if clicking is not disabled
if (clickMode != ClickMode.Disabled)
{
SetNextLineFlag();
}
}
protected virtual void Update() protected virtual void Update()
{ {
if (EventSystem.current == null) if (EventSystem.current == null)
@ -159,5 +115,39 @@ namespace Fungus
nextLineInputFlag = false; nextLineInputFlag = false;
} }
} }
#region IDialogInput
public void SetNextLineFlag()
{
nextLineInputFlag = true;
}
public void SetDialogClickedFlag()
{
// Ignore repeat clicks for a short time to prevent accidentally clicking through the character dialogue
if (ignoreClickTimer > 0f)
{
return;
}
ignoreClickTimer = nextClickDelay;
// Only applies in Click On Dialog mode
if (clickMode == ClickMode.ClickOnDialog)
{
dialogClickedFlag = true;
}
}
public void SetButtonClickedFlag()
{
// Only applies if clicking is not disabled
if (clickMode != ClickMode.Disabled)
{
SetNextLineFlag();
}
}
#endregion
} }
} }

31
Assets/Fungus/Narrative/Scripts/IDialogInput.cs

@ -0,0 +1,31 @@
namespace Fungus
{
/// <summary>
/// Input handler for say dialogues.
/// </summary>
public interface IDialogInput
{
/// <summary>
/// Trigger next line input event from script.
/// </summary>
void SetNextLineFlag();
/// <summary>
/// Set the dialog clicked flag (usually from an Event Trigger component in the dialog UI).
/// </summary>
void SetDialogClickedFlag();
/// <summary>
/// Sets the button clicked flag.
/// </summary>
void SetButtonClickedFlag();
}
/// <summary>
/// Interface for listening for dialogue input events.
/// </summary>
public interface IDialogInputListener
{
void OnNextLineEvent();
}
}

12
Assets/Fungus/Narrative/Scripts/IDialogInput.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: daaafdda848514f7caee7d3a2b70a30c
timeCreated: 1473680781
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save