public override void init() { //TODO moveState = ActorMoveState.IDLE; movingDirection = TSVector.zero; facingDirection = TSVector.forward; health = MAX_HEALTH; }
private void MakeFSM() { ActorAttackState attackState = new ActorAttackState(2.0f); ActorMoveState moveState = new ActorMoveState(1.0f); ActorSkillState skillState = new ActorSkillState(0.1f); attackState.AddTransition(Transition.TS_FIND_TARGET, StateID.STS_MOVE); attackState.AddTransition(Transition.TS_SKILL, StateID.STS_SKILL); moveState.AddTransition(Transition.TS_ATTACK, StateID.STS_ATTACK); moveState.AddTransition(Transition.TS_SKILL, StateID.STS_SKILL); fsm = new FSMMgr(); fsm.AddState(moveState); fsm.AddState(attackState); fsm.AddState(skillState); }
public void StepRunning(/* object inputParam = null TODO 后面要改成具体的结构体 */) { // 移动 switch (_movingState) { case ActorMoveState.IDLE: if (isWASD(_keyPressed)) { _movingState = ActorMoveState.RUN; if (_keyPressed.Equals("w")) { _actor.run(TSVector.forward); } else if (_keyPressed.Equals("s")) { _actor.run(TSVector.back); } else if (_keyPressed.Equals("a")) { _actor.run(TSVector.left); } else if (_keyPressed.Equals("d")) { _actor.run(TSVector.right); } } else { _actor.idle(); } break; case ActorMoveState.JUMP: break; case ActorMoveState.WALK: break; case ActorMoveState.RUN: if (_keyPressed.Equals("w")) { _actor.run(TSVector.forward); } else if (_keyPressed.Equals("s")) { _actor.run(TSVector.back); } else if (_keyPressed.Equals("a")) { _actor.run(TSVector.left); } else if (_keyPressed.Equals("d")) { _actor.run(TSVector.right); } else if (string.IsNullOrEmpty(_keyPressed)) { _movingState = ActorMoveState.IDLE; } break; } //转向 _actor.lookAt(_mousePosition); //开火 if (_mouseClicked) { _mouseClicked = false; _actor.attack(); } }
public void startRunning() { BaseActorData actorData = _actor.getData() as BaseActorData; _movingState = actorData.moveState; }