Ejemplo n.º 1
0
 public void setCurrentState(AIState currentState) {
   try {
     if (currentState.getClass() == this.currentState.getClass()) return;
     if (this.currentState != null) doStateAction(this.currentState.onExit(this));
     this.currentState = currentState;
     doStateAction(currentState.onEnter(this));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
 public void scheduleRecovery() {
   scheduler.schedule(
       () -> {
         try {
           doStateAction(currentState.recover(AIActor.this));
         } catch (Exception e) {
           e.printStackTrace();
         }
       },
       2000,
       TimeUnit.MILLISECONDS);
 }
Ejemplo n.º 3
0
 public void scheduleMovement() {
   scheduler.schedule(
       () -> {
         try {
           doStateAction(currentState.move(AIActor.this));
         } catch (Exception e) {
           e.printStackTrace();
         }
       },
       500,
       TimeUnit.MILLISECONDS);
 }