86 lines
2.0 KiB
C#
86 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Sirenix.OdinInspector;
|
|
|
|
/// <summary>
|
|
/// 皇帝类,控制皇帝的行为,继承自可交互物体
|
|
/// </summary>
|
|
public class HuangDi : EntryTrigger
|
|
{
|
|
[SerializeField][EnumPaging]
|
|
private KnotMediator.KnotType neededType = KnotMediator.KnotType.编成麻花的绳结;
|
|
|
|
//自身状态机
|
|
private Animator animator;
|
|
|
|
public enum HuangDiState
|
|
{
|
|
None,
|
|
Ask,
|
|
Answer,
|
|
End
|
|
}
|
|
|
|
|
|
void Start(){
|
|
animator = GetComponentInChildren<Animator>();
|
|
//如果没找到,则报错
|
|
if (animator == null)
|
|
{
|
|
Debug.LogError("没有找到Animator组件");
|
|
}
|
|
}
|
|
|
|
public HuangDiState state = HuangDiState.None;
|
|
|
|
public override void OnCall()
|
|
{
|
|
|
|
if(state == HuangDiState.Ask)
|
|
{
|
|
if(KnotMediator.Instance.CheckKnotType(neededType))
|
|
{
|
|
Debug.Log("皇帝接受了绳结");
|
|
state = HuangDiState.Answer;
|
|
//触发结束演出
|
|
FindObjectOfType<HuangdiConfused>().OnCall();
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("皇帝拒绝了绳结");
|
|
FindObjectOfType<HuangdiAsk>().OnCall();
|
|
}
|
|
}
|
|
if(state == HuangDiState.None)
|
|
{
|
|
FindObjectOfType<HuangdiAsk>().OnCall();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public void setNeededType(KnotMediator.KnotType type)
|
|
{
|
|
neededType = type;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 控制黄帝的动画
|
|
/// </summary>
|
|
/// <param name="behaviorName">触发的动画名</param>
|
|
public void Behavior(string behaviorName)
|
|
{
|
|
try{
|
|
//触发动画
|
|
animator.SetTrigger(behaviorName);
|
|
}
|
|
catch(System.Exception e)
|
|
{
|
|
e.ToString();
|
|
Debug.LogError("没有找到触发器" + behaviorName);
|
|
}
|
|
|
|
}
|
|
}
|