예제 #1
0
        private void MakeFSM()
        {
            mFSMSystem = new SoldierFSMSystem();

            //参数1:角色的有限状态机
            //参数2:控制的对象(为当前角色的对象)
            SoldierIdleState idleState = new SoldierIdleState(mFSMSystem, this);

            idleState.AddTransition(SoldierTransition.SeeEnemy, SoldierStateID.Chase);

            SoldierChaseState chaseState = new SoldierChaseState(mFSMSystem, this);

            chaseState.AddTransition(SoldierTransition.NoEnemy, SoldierStateID.Idle);
            chaseState.AddTransition(SoldierTransition.CanAttack, SoldierStateID.Attack);


            SoldierAttackState attackState = new SoldierAttackState(mFSMSystem, this);

            attackState.AddTransition(SoldierTransition.NoEnemy, SoldierStateID.Idle);
            attackState.AddTransition(SoldierTransition.SeeEnemy, SoldierStateID.Chase);

            mFSMSystem.AddState(idleState, chaseState, attackState);
        }
예제 #2
0
 public SoldierChaseState(SoldierFSMSystem fsm, ICharacter character) : base(fsm, character)
 {
     mStateID = SoldierStateID.Chase;
 }
예제 #3
0
 public SoldierAttackState(SoldierFSMSystem fsm, ICharacter character) : base(fsm, character)
 {
     mStateID     = SoldierStateID.Attack;
     mAttackTimer = mAttackTime;
 }
예제 #4
0
 public ISoldierState(SoldierFSMSystem fsm, ICharacter character)
 {
     mFSM       = fsm;
     mCharacter = character;
 }