// Copyright (c) Pixel Crushers. All rights reserved.
using UnityEngine;
using System;
namespace PixelCrushers.DialogueSystem
{
///
/// Standard UI implementation of IBarkUI.
///
[AddComponentMenu("")] // Use wrapper.
public class StandardBarkUI : AbstractBarkUI
{
///
/// The (optional) UI canvas group. If assigned, the fade will occur on this
/// control. The other controls should be children of this canvas group.
///
[Tooltip("Optional canvas group, for example to play fade animations.")]
public CanvasGroup canvasGroup = null;
///
/// The UI text control for the bark text.
///
[Tooltip("UI text control for bark text.")]
public UITextField barkText = null;
///
/// The (optional) UI text control for the actor's name, if includeName is true.
/// If null, the name is added to the front of the subtitle text instead.
///
[Tooltip("Optional UI text control for barker's name if Include Name is ticked. If unassigned and Include Name is ticked, name is prepended to Bark Text.")]
public UITextField nameText = null;
///
/// Set true to include the barker's name in the text.
///
[Tooltip("If Name Text is unassigned, prepend barker's name to Bark Text.")]
public bool includeName = false;
[Tooltip("Optional to show barker's portrait image.")]
public UnityEngine.UI.Image portraitImage = null;
[Tooltip("Show barker's portrait image.")]
public bool showPortraitImage = false;
[HideInInspector]
public float doneTime = 0;
[Serializable]
public class AnimationTransitions
{
public string showTrigger = "Show";
public string hideTrigger = "Hide";
}
public AnimationTransitions animationTransitions = new AnimationTransitions();
///
/// The duration in seconds to show the bark text before fading it out.
///
[Tooltip("The duration in seconds to show the bark text before fading it out. If zero, use the Dialogue Manager's Bark Settings.")]
public float duration = 4f;
[Tooltip("Keep bark canvas anchor point always in camera view.")]
public bool keepInView = false;
///
/// Set true to keep the bark text onscreen until the sequence ends.
///
[Tooltip("Keep the bark text onscreen until the sequence ends.")]
public bool waitUntilSequenceEnds = false;
[Tooltip("If bark is visible and waiting for sequence to end, but new bark wants to show, cancel wait for previous sequence.")]
public bool cancelWaitUntilSequenceEndsIfReplacingBark = false;
///
/// Wait for an "OnContinue" message.
///
[Tooltip("Wait for an OnContinue message.")]
public bool waitForContinueButton = false;
///
/// If visible, hide this bark UI when any conversation starts.
///
[Tooltip("If visible, hide this bark UI when any conversation starts.")]
public bool hideOnConversationStart = false;
///
/// The text display setting. Defaults to use the same subtitle setting as the Dialogue
/// Manager, but you can also set it to always show or always hide the text.
///
public BarkSubtitleSetting textDisplaySetting = BarkSubtitleSetting.SameAsDialogueManager;
protected Canvas canvas { get; set; }
protected Animator animator { get; set; }
protected AbstractTypewriterEffect typewriter { get; set; }
protected Vector3 originalCanvasLocalPosition { get; set; }
protected int numSequencesActive = 0;
protected bool hasEverBarked = false;
///
/// Indicates whether a bark is currently playing.
///
///
/// true if playing; otherwise, false.
///
public override bool isPlaying
{
get
{
return (canvas != null) && canvas.enabled && (DialogueTime.time < doneTime);
}
}
protected virtual void Awake()
{
canvas = GetComponentInChildren