浏览代码

Townsfolk to stop talking when protagonist talks to others in conversation

/main
Amel Negra 4 年前
当前提交
3dad5079
共有 1 个文件被更改,包括 36 次插入9 次删除
  1. 45
      UOP1_Project/Assets/Scripts/Characters/Townsfolk.cs

45
UOP1_Project/Assets/Scripts/Characters/Townsfolk.cs


using UnityEngine;
public enum InitialState { Idle = 0, Walk, Talk };
public enum TownsfolkState { Idle = 0, Walk, Talk };
public InitialState InitialState; //This is checked by conditions in the StateMachine
public TownsfolkState townsfolkState; //This is checked by conditions in the StateMachine
public GameObject[] talkingTo;
private DialogueDataChannelSO _startDialogueEvent = default;
private VoidEventChannelSO _endDialogueEvent = default;
private void OnEnable()
{
if (_startDialogueEvent != null)
_startDialogueEvent.OnEventRaised += StopTalking;
if (_endDialogueEvent != null)
_endDialogueEvent.OnEventRaised += ResumeTalking;
}
void Start()
private void StopTalking(DialogueDataSO dialogue)
}
for (int i = 0; i < talkingTo.Length; ++i)
{
if (talkingTo[i].GetComponent<StepController>().IsInDialogue)
{
townsfolkState = TownsfolkState.Idle;
return;
}
}
}
void Update()
{
}
private void ResumeTalking()
{
for (int i = 0; i < talkingTo.Length; ++i)
{
if (talkingTo[i].GetComponent<StepController>().IsInDialogue)
return;
}
townsfolkState = TownsfolkState.Talk;
}
}
正在加载...
取消
保存