// Copyright (c) Pixel Crushers. All rights reserved. using UnityEngine; namespace PixelCrushers.DialogueSystem { /// /// Abstract alert message controls. Each GUI system implementation derives its own subclass /// from this. /// [System.Serializable] public abstract class AbstractUIAlertControls : AbstractUIControls { /// /// Gets a value indicating whether an alert is visible. /// /// /// true if visible; otherwise, false. /// public abstract bool isVisible { get; } /// /// Sets the message text of an alert. /// /// /// Message. /// /// /// Duration that message will be shown. Used by subclasses to set up fade durations. /// public abstract void SetMessage(string message, float duration); protected float m_alertDoneTime = 0; /// /// Has the duration passed for the currently-showing alert? /// /// /// true if done; otherwise, false. /// public virtual bool isDone { get { return (DialogueTime.time > m_alertDoneTime); } } /// @cond FOR_V1_COMPATIBILITY public bool IsVisible { get { return isVisible; } } public bool IsDone { get { return isDone; } } /// @endcond /// /// Sets the GUI controls and shows a message. /// /// /// Message to show. /// /// /// Duration in seconds. /// public virtual void ShowMessage(string message, float duration) { if (!string.IsNullOrEmpty(message)) { m_alertDoneTime = (duration >= 0) ? DialogueTime.time + duration : Mathf.Infinity; // Negative durations show forever. SetMessage(message, duration); Show(); } else { Hide(); } } } }