53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
|
|
|||
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace Ether
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 状态类型
|
|||
|
/// </summary>
|
|||
|
public enum StateType
|
|||
|
{
|
|||
|
Loop = 0, //循环:如idle,walk,run等
|
|||
|
Once = 1, //一次:如技能播放等,结束后自动切换会默认状态
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 状态所处阶段
|
|||
|
/// </summary>
|
|||
|
public enum StateStage
|
|||
|
{
|
|||
|
Playing = 0, //播放中
|
|||
|
Over = 1, //结束
|
|||
|
}
|
|||
|
|
|||
|
public abstract class StateBase : IDisposable
|
|||
|
{
|
|||
|
protected StateMachine machine;
|
|||
|
|
|||
|
private StateType stateType = StateType.Loop;
|
|||
|
public virtual StateType StateType { get { return stateType; } set { stateType = value; } }
|
|||
|
|
|||
|
public void Init(StateMachine stateMachine)
|
|||
|
{
|
|||
|
this.machine = stateMachine;
|
|||
|
OnInit();
|
|||
|
}
|
|||
|
public virtual void OnInit() { }
|
|||
|
public abstract void EnterState();
|
|||
|
public abstract void ExitState();
|
|||
|
public virtual bool CheckStateIsCanSwitch()
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public virtual void Dispose()
|
|||
|
{
|
|||
|
PoolManager.Inst.Push(this);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|