You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
3.5 KiB
C#
134 lines
3.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Articy.Unity;
|
|
using Articy.Touhou;
|
|
|
|
namespace Game
|
|
{
|
|
/// <summary>
|
|
/// 剧情管理
|
|
/// </summary>
|
|
public class DramaManager : ManagerBase<DramaManager>
|
|
{
|
|
private GameObject _dramaRoot;
|
|
private ArticyFlowPlayer _articyFlowPlayer;
|
|
private DramaFlowPlayer _flowPlayer;
|
|
|
|
public DramaManager()
|
|
{
|
|
}
|
|
|
|
public override void OnCreate()
|
|
{
|
|
Object.DontDestroyOnLoad(GameObject.Find("FlowRoot"));
|
|
_dramaRoot = GameObject.Find("FlowRoot/DramaRoot");
|
|
|
|
_articyFlowPlayer = _dramaRoot.GetComponent<ArticyFlowPlayer>();
|
|
_flowPlayer = _dramaRoot.GetComponent<DramaFlowPlayer>();
|
|
_dramaRoot.SetActive(false);
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
}
|
|
|
|
public override void OnDestroy()
|
|
{
|
|
Object.DestroyImmediate(_dramaRoot);
|
|
}
|
|
|
|
public void StartDrama(string dramaId)
|
|
{
|
|
if (_dramaRoot.activeSelf)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var dialog = ArticyDatabase.GetObject<Dialogue>(dramaId);
|
|
if (dialog == null)
|
|
{
|
|
Util.Print("剧情不存在:", dramaId);
|
|
return;
|
|
}
|
|
|
|
Util.EntityStopMove(Util.GetMasterID());
|
|
UIManager.Instance.Open(EuiPage.Drama);
|
|
_articyFlowPlayer.StartOn = dialog;
|
|
_dramaRoot.SetActive(true);
|
|
}
|
|
|
|
public void EndDrama()
|
|
{
|
|
_dramaRoot.SetActive(false);
|
|
SendDialogEnd();
|
|
}
|
|
|
|
public void NextDrama()
|
|
{
|
|
_flowPlayer.NextDrama();
|
|
}
|
|
|
|
public void NextDramaChoice(int index)
|
|
{
|
|
_flowPlayer.NextDramaChoice(index);
|
|
}
|
|
|
|
public void SendDialog(string name, string content, ArticyObject icon)
|
|
{
|
|
var param = new PDialog()
|
|
{
|
|
Name = name,
|
|
Content = content,
|
|
Pic = icon,
|
|
};
|
|
EventManager.Instance.SendEvent<PDialog>(EEvent.Dialog, param);
|
|
}
|
|
|
|
public void SendDialogChoice(List<string> choices)
|
|
{
|
|
var param = new PDialogChoice()
|
|
{
|
|
Choices = choices,
|
|
};
|
|
EventManager.Instance.SendEvent<PDialogChoice>(EEvent.DialogChoice, param);
|
|
}
|
|
|
|
private void SendDialogEnd()
|
|
{
|
|
EventManager.Instance.SendEvent(EEvent.DialogEnd);
|
|
}
|
|
}
|
|
|
|
public abstract partial class Util
|
|
{
|
|
public static void StartDrama(string dramaId)
|
|
{
|
|
DramaManager.Instance.StartDrama(dramaId);
|
|
}
|
|
|
|
public static void EndDrama()
|
|
{
|
|
DramaManager.Instance.EndDrama();
|
|
}
|
|
|
|
public static void NextDrama()
|
|
{
|
|
DramaManager.Instance.NextDrama();
|
|
}
|
|
|
|
public static void NextDramaChoice(int index)
|
|
{
|
|
DramaManager.Instance.NextDramaChoice(index);
|
|
}
|
|
|
|
public static void SendDialog(string name, string content, ArticyObject icon)
|
|
{
|
|
DramaManager.Instance.SendDialog(name, content, icon);
|
|
}
|
|
|
|
public static void SendDialogChoice(List<string> choices)
|
|
{
|
|
DramaManager.Instance.SendDialogChoice(choices);
|
|
}
|
|
}
|
|
} |