forked from wangchen/Programming-Game-AI-by-Example-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
702 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
namespace StateMachineLearn; | ||
using Location = ConstDefine.Location.LocationType; | ||
|
||
/// <summary> | ||
/// 苍蝇接口 | ||
/// </summary> | ||
public interface IFly : IBaseGameEntity | ||
{ | ||
/// <summary> | ||
/// 当前位置 | ||
/// </summary> | ||
public ConstDefine.Location.LocationType CurrentLocation { get; set; } | ||
|
||
/// <summary> | ||
/// 状态机 | ||
/// </summary> | ||
public StateMachine<Fly> FSM { get; } | ||
} | ||
|
||
/// <summary> | ||
/// 苍蝇对象 | ||
/// </summary> | ||
public class Fly : BaseGameEntity, IFly | ||
{ | ||
/// <summary> | ||
/// 防止外部绕过 Builder 创建对象 | ||
/// </summary> | ||
public Fly(EntityName name, IState<Fly> currentState, IState<Fly> preState) : base(name) | ||
{ | ||
FSM = new StateMachine<Fly>(this, currentState, preState); | ||
} | ||
|
||
#region Implementation of IFly | ||
|
||
/// <summary> | ||
/// 当前位置 | ||
/// </summary> | ||
public Location CurrentLocation { get; set; } | ||
|
||
#region Overrides of BaseGameEntity | ||
|
||
/// <summary> | ||
/// 处理信息 | ||
/// </summary> | ||
/// <param name="msg"></param> | ||
public override void HandleMessage(in Telegram msg) | ||
{ | ||
FSM.HandleMessage(msg); | ||
} | ||
|
||
#endregion | ||
|
||
#region Implementation of IBaseGameEntity | ||
|
||
public override void Update() | ||
{ | ||
FSM.Update(); | ||
} | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// 状态机 | ||
/// </summary> | ||
public StateMachine<Fly> FSM { get; } | ||
|
||
#endregion | ||
} |
Oops, something went wrong.