You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
981 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/****************************************************
文件StateMgr.cs
作者Plane
邮箱: 1785275942@qq.com
日期2019/03/15 9:08
功能:状态管理器
*****************************************************/
using UnityEngine;
using System.Collections.Generic;
public class StateMgr : MonoBehaviour {
private Dictionary<AniState, IState> fsm = new Dictionary<AniState, IState>();
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);
}
}
}