void Init() { //-----初始化状态机---------- MMachine = new BehaviourStateMachine(); HeroIdleState idleState = new HeroIdleState(gameObject); MMachine.AddState(idleState); HeroMoveState moveState = new HeroMoveState(gameObject); MMachine.AddState(moveState); HeroKickState kickState = new HeroKickState(gameObject); MMachine.AddState(kickState); //-----end---------------- //----初始化角色位置 MCurCoordinate = new SGridCoordinate(4, 0); Vector3 heroPosition = Definition.GridToWorld(MCurCoordinate.x, MCurCoordinate.z); //heroPosition.y += MHeroHeight / 2f; transform.position = heroPosition; //--------------------- }
public void MakeFSMMachine() { HeroAttackState attackState = new HeroAttackState(); attackState.addDictionary(Translate.Translate_Hero_Attack, StateID.Hero_Attack); HeroDieState dieState = new HeroDieState(); dieState.addDictionary(Translate.Translate_Hero_Die, StateID.Hero_Die); HeroWalkState walkState = new HeroWalkState(); walkState.addDictionary(Translate.Translate_Hero_Walk, StateID.Hero_Walk); HeroIdleState idleState = new HeroIdleState(); idleState.addDictionary(Translate.Translate_Hero_Idle, StateID.Hero_Idle); AddFSMState(idleState); AddFSMState(walkState); AddFSMState(dieState); AddFSMState(attackState); }