Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ZombieController extends Script {
- int state = 0; //0 - delay 1 - run 2 - attack
- MoveComponent move;
- SearchTargetComponent search;
- public void initialize() {
- move = gameObject.getScript(MoveComponent.class);
- search = gameObject.getScript(SearchTargetComponent.class);
- }
- public void update(float delta) {
- if(!move.inMotion())
- if(search.haveTarget()) {
- if(search.targetIsClose(0.5f)) {
- state = 2;
- } else {
- move.moveTo(search.getTarget());
- state = 1;
- }
- } else {
- state = 0;
- }
- }
- //run animation, damage on the target, etc...
- }
- public void move(int x, int y) {
- if(state == 2) return;
- move.moveTo(x, y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment