CangJie/Assets/Scripts//对话框架/ConversationController.cs
Roman 32e1fd2d93 任务:编写场景1逻辑
1.完成对话系统框架
(1.系统结构见图
(2.使用方法为对ConversationController单例使用OnCall(Staring 对话名)
(3.需要自行编辑对话内容,填写AConversation组件的内容即可

果咩,我摸了五天,求职的压力实在是太大了😿😿
2022-03-19 22:52:00 +08:00

31 lines
843 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 + "的对话");
}
}