Guest User

Untitled

a guest
Aug 19th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. public class ZombieController extends Script {
  2.     int state = 0; //0 - delay 1 - run 2 - attack
  3.     MoveComponent move;
  4.     SearchTargetComponent search;
  5.  
  6.     public void initialize() {
  7.         move = gameObject.getScript(MoveComponent.class);
  8.         search = gameObject.getScript(SearchTargetComponent.class);    
  9.     }
  10.  
  11.     public void update(float delta) {
  12.         if(search.haveTarget()) {
  13.             if(search.targetIsClose(0.5f)) {
  14.                 state = 2;
  15.             } else {
  16.                 move.moveTo(search.getTarget());
  17.                 state = 1;
  18.             }
  19.         } else {
  20.             state = 0;
  21.         }
  22.  
  23.         //run animation, damage on the target, etc...
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment