
1.完成对话系统框架 (1.系统结构见图 (2.使用方法为对ConversationController单例使用OnCall(Staring 对话名) (3.需要自行编辑对话内容,填写AConversation组件的内容即可 果咩,我摸了五天,求职的压力实在是太大了😿😿
31 lines
843 B
C#
31 lines
843 B
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
public class ConversationController : UnitySingleton<ConversationController>
|
||
{
|
||
private AConversation[] conversationList;
|
||
|
||
void Start()
|
||
{
|
||
conversationList = FindObjectsOfType<AConversation>();
|
||
}
|
||
|
||
public void OnCall(string name)
|
||
{
|
||
//找到叫name的对话,并调用其OnCall()
|
||
foreach (AConversation conversation in conversationList)
|
||
{
|
||
if (conversation.conversationName == name)
|
||
{
|
||
conversation.OnCall();
|
||
//改变玩家地图至Null
|
||
FindObjectOfType<Player>().ToMap("Null");
|
||
return;
|
||
}
|
||
}
|
||
//如果没找到,则报错
|
||
Debug.LogError("没有找到名为" + name + "的对话");
|
||
}
|
||
}
|