Ejemplo n.º 1
0
 private void sendTurnMovementEvent(
     byte newTurnStatus, int movementType, Vector3f location, Quaternion rotation) {
   ClientPlayerData.getInstance().getPlayer().setTurnStatus(newTurnStatus);
   ClientNetworkController.getInstance()
       .handleOutgoingEvent(
           CharacterController.getInstance()
               .createMovementEvent(
                   movementType,
                   ClientPlayerData.getInstance().getPlayer().getMoveStatus(),
                   newTurnStatus,
                   location,
                   rotation));
 }
Ejemplo n.º 2
0
 public void update(float time) {
   // //TODO: We only take care of walking at the moment
   // 2 events ?? why ?
   super.update(time);
   // TODO: Take this out and register individual actions !
   Vector3f location = player.getLocalTranslation();
   Quaternion rotation = player.getLocalRotation();
   boolean forward = KeyBindingManager.getKeyBindingManager().isValidCommand(PROP_KEY_FORWARD);
   boolean backward = KeyBindingManager.getKeyBindingManager().isValidCommand(PROP_KEY_BACKWARD);
   int moveStatus = ClientPlayerData.getInstance().getPlayer().getMoveStatus();
   // TODO: Refactor !
   if (!(forward && backward)) {
     if (!forward && (moveStatus == Globals.WALKING || moveStatus == Globals.RUNNING)) {
       sendMovementEvent(Globals.STANDING, EventTypes.MOVEMENT_STOP_WALK, location, rotation);
     } else if (forward && moveStatus != Globals.WALKING) {
       sendMovementEvent(Globals.WALKING, EventTypes.MOVEMENT_START_WALK, location, rotation);
     } else if (!backward && moveStatus == Globals.WALKING_BACKWARD) {
       sendMovementEvent(Globals.STANDING, EventTypes.MOVEMENT_STOP_WALK, location, rotation);
     } else if (backward && moveStatus != Globals.WALKING_BACKWARD) {
       sendMovementEvent(
           Globals.WALKING_BACKWARD, EventTypes.MOVEMENT_START_WALK_BACKWARDS, location, rotation);
     }
   }
   boolean turnLeft = KeyBindingManager.getKeyBindingManager().isValidCommand(PROP_KEY_LEFT);
   boolean turnRight = KeyBindingManager.getKeyBindingManager().isValidCommand(PROP_KEY_RIGHT);
   if (!(turnRight && turnLeft)) {
     int turnStatus = ClientPlayerData.getInstance().getPlayer().getTurnStatus();
     if (turnLeft && turnStatus != Globals.TURN_LEFT) {
       sendTurnMovementEvent(
           Globals.TURN_LEFT, EventTypes.MOVEMENT_START_TURN_LEFT, location, rotation);
     } else if (!turnLeft && turnStatus == Globals.TURN_LEFT) {
       sendTurnMovementEvent(Globals.NO_TURN, EventTypes.MOVEMENT_STOP_TURN, location, rotation);
     } else if (turnRight && turnStatus != Globals.TURN_RIGHT) {
       sendTurnMovementEvent(
           Globals.TURN_RIGHT, EventTypes.MOVEMENT_START_TURN_RIGHT, location, rotation);
     } else if (!turnRight && turnStatus == Globals.TURN_RIGHT) {
       sendTurnMovementEvent(Globals.NO_TURN, EventTypes.MOVEMENT_STOP_TURN, location, rotation);
     }
   }
 }