//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Saturday, December 09, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class DialogueBubble : HUDBehaviour
|
{
|
[SerializeField] Text m_Content;
|
[SerializeField] protected float m_Duration = 2f;
|
public float duration {
|
get { return m_Duration; }
|
set { m_Duration = value; }
|
}
|
|
public Pattern pattern { get; set; }
|
protected bool showing = false;
|
float endTime = 0f;
|
GameObject tempTarget;
|
|
public virtual void Show(string _content, Transform _target, Camera _camera)
|
{
|
base.target = _target;
|
base.offset = Vector3.zero;
|
base.camera = _camera;
|
endTime = Time.time + m_Duration;
|
m_Content.text = _content;
|
this.SetActive(true);
|
SyncPosition(true);
|
|
showing = true;
|
}
|
|
public void Show(string _content, Vector3 _position, Camera _camera)
|
{
|
if (tempTarget == null)
|
{
|
tempTarget = new GameObject("Temp_MountPoint");
|
}
|
tempTarget.transform.position = _position;
|
|
Show(_content, tempTarget.transform, _camera);
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
if (showing && Time.time > endTime)
|
{
|
showing = false;
|
DialogueBubblePool.Recycle(this);
|
}
|
}
|
|
public enum Pattern
|
{
|
NPC,
|
Story,
|
}
|
|
}
|
|
}
|