//配置状态机 private void ConfigFSM() { states = new List <FSMState>(); IdleState idle = new IdleState(); idle.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); idle.AddMap(FSMTriggerID.SawTarget, FSMStateID.Pursuit); states.Add(idle); DeadState dead = new DeadState(); states.Add(dead); PursuitState pursuit = new PursuitState(); pursuit.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); pursuit.AddMap(FSMTriggerID.ReachTarget, FSMStateID.Attacking); pursuit.AddMap(FSMTriggerID.LoseTarget, FSMStateID.Default); states.Add(pursuit); AttackingState attacking = new AttackingState(); attacking.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); attacking.AddMap(FSMTriggerID.WithoutAttackRange, FSMStateID.Pursuit); attacking.AddMap(FSMTriggerID.KilledTarget, FSMStateID.Default); states.Add(attacking); PatrollingState patrolling = new PatrollingState(); patrolling.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); patrolling.AddMap(FSMTriggerID.SawTarget, FSMStateID.Pursuit); patrolling.AddMap(FSMTriggerID.CompletePatrol, FSMStateID.Idle); states.Add(patrolling); }
public override void ConfigFSM() { base.ConfigFSM(); states = new List <FSMState>(); //创建状态对象 //添加映射(AddMap)* //加入状态机 //-------------------- //随机移动 RandomMoveState randomMove = new RandomMoveState(); randomMove.AddMap(FSMTriggerID.ScoutedTargetIn, FSMStateID.Follow); randomMove.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); states.Add(randomMove); //跟随 FollowState follow = new FollowState(); follow.AddMap(FSMTriggerID.ScoutedTargetOut, FSMStateID.RandomMove); follow.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); follow.AddMap(FSMTriggerID.AttackTargetIn, FSMStateID.Attacking); states.Add(follow); //攻击 AttackingState attacking = new AttackingState(); attacking.AddMap(FSMTriggerID.AttackTargetOut, FSMStateID.Follow); attacking.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); states.Add(attacking); //站立 IdleState idle = new IdleState(); //idle.AddMap(FSMTriggerID.) idle.AddMap(FSMTriggerID.NoHealth, FSMStateID.Dead); states.Add(idle); //死亡 DeadState dead = new DeadState(); states.Add(dead); }