新增测试模式;增加选择项接入
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -11,6 +12,8 @@ namespace AibisDream
|
||||
{
|
||||
private DialogueRunner dialogueRunner;
|
||||
|
||||
private Dictionary<string, Action<YarnOption[]>> commandMap = new Dictionary<string, Action<YarnOption[]>>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
dialogueRunner = GetComponentInChildren<DialogueRunner>();
|
||||
@@ -26,6 +29,55 @@ namespace AibisDream
|
||||
dialogueRunner.StartDialogue("Start");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行指令
|
||||
/// </summary>
|
||||
/// <param name="commandName">指令名称</param>
|
||||
public void InvokeOptionCommand(string commandName, YarnOption[] options)
|
||||
{
|
||||
if (commandName == null) { }
|
||||
|
||||
if (commandMap.TryGetValue(commandName, out var action))
|
||||
{
|
||||
action(options);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"没有找到 {commandName} 命令");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册带选项指令
|
||||
/// </summary>
|
||||
/// <param name="commandName">指令名称</param>
|
||||
/// <param name="commandAction">指令函数</param>
|
||||
public void RegisterOptionCommand(string commandName, Action<YarnOption[]> commandAction)
|
||||
{
|
||||
if (commandMap.ContainsKey(commandName))
|
||||
{
|
||||
Debug.Log($"命令 {commandName} 并未注册,重新注册会替换旧指令");
|
||||
}
|
||||
|
||||
commandMap[commandName] = commandAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卸载指令
|
||||
/// </summary>
|
||||
/// <param name="commandName">指令名称</param>
|
||||
public void RemoveOptionCommand(string commandName)
|
||||
{
|
||||
if (commandMap.ContainsKey(commandName))
|
||||
{
|
||||
commandMap.Remove(commandName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"命令 {commandName} 并未注册,重新注册会替换旧指令");
|
||||
}
|
||||
}
|
||||
|
||||
#region 各种命令
|
||||
[YarnCommand("switch_tv")]
|
||||
public static void SwitchTV(string picName)
|
||||
|
||||
Reference in New Issue
Block a user