Ejemplo n.º 1
0
 public void createMonster() {
   Monster monster = new Monster();
   monster.health = 20;
   monster.attackDelay = 0;
   monster.monsterControl = new BetterCharacterControl(1f, 5f, 1f);
   monster.Model = (Node) assetManager.loadModel("Models/RealMonster/RealMonster.j3o");
   monster.Model.setLocalScale(.8f);
   monster.Model.addControl(monster.monsterControl);
   monster.monsterControl.setGravity(new Vector3f(0f, -9.81f, 0f));
   monster.anim = new AnimationManager();
   monster.anim.animationInit(monster.Model);
   physics.getPhysicsSpace().add(monster.monsterControl);
   monster.attachChild(monster.Model);
   monsterNode.attachChild(monster);
   monster.monsterSetLocation(monster);
 }
Ejemplo n.º 2
0
 public void locationChecker(Monster monster) {
   Vector3f playerLocation = player.Model.getLocalTranslation();
   Vector3f monsterLocation = monster.Model.getLocalTranslation();
   float distance = playerLocation.distance(monsterLocation);
   Vector3f playerDirection = playerLocation.subtract(monsterLocation);
   monsterRotater(monster, playerDirection);
   if (distance < 3) {
     if (monster.attackDelay == 10) {
       monster.attackDelay = 0;
       monster.attack(monster.Model, player);
     } else {
       monster.attackDelay++;
     }
   } else {
     monster.anim.animChange("UnarmedRun", "RunAction", monster.Model);
   }
 }
Ejemplo n.º 3
0
 public void monsterRotater(Monster monster, Vector3f playerDirection) {
   monster.Model.getControl(BetterCharacterControl.class).setWalkDirection(playerDirection);
   monster.Model.getControl(BetterCharacterControl.class).setViewDirection(playerDirection);
 }