Esempio 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();
   }
 }
Esempio n. 2
0
 public void scheduleRecovery() {
   scheduler.schedule(
       () -> {
         try {
           doStateAction(currentState.recover(AIActor.this));
         } catch (Exception e) {
           e.printStackTrace();
         }
       },
       2000,
       TimeUnit.MILLISECONDS);
 }
Esempio n. 3
0
 public void scheduleMovement() {
   scheduler.schedule(
       () -> {
         try {
           doStateAction(currentState.move(AIActor.this));
         } catch (Exception e) {
           e.printStackTrace();
         }
       },
       500,
       TimeUnit.MILLISECONDS);
 }