/**************************************************** 文件:StateMgr.cs 作者:Plane 邮箱: 1785275942@qq.com 日期:2019/03/15 9:08 功能:状态管理器 *****************************************************/ using UnityEngine; using System.Collections.Generic; public class StateMgr : MonoBehaviour { private Dictionary fsm = new Dictionary(); public void Init() { //fsm.Add(AniState.Born, new StateBorn()); } public void ChangeStatus(EntityBase entity, AniState targetState, params object[] args) { if (entity.currentAniState == targetState) { return; } if (fsm.ContainsKey(targetState)) { if (entity.currentAniState != AniState.None) { fsm[entity.currentAniState].Exit(entity, args); } fsm[targetState].Enter(entity, args); fsm[targetState].Process(entity, args); } } }