Package be.demmel.jgws

Examples of be.demmel.jgws.MovementType


        }
    }

    private void movePlayer(Channel movingPlayer, Channel recipient) throws Exception {
        CharacterData character = movingPlayer.attr(SessionKey.SESSION_KEY).get().getCurrentCharacter();
        MovementType moveType = character.getMoveType();

        if (moveType == MovementType.FORWARD || moveType == MovementType.DIAG_FW_LEFT || moveType == MovementType.DIAG_FW_RIGHT || moveType == MovementType.STOP) {
            character.setSpeedModifier(1f);
        } else if (moveType == MovementType.BACKWARD || moveType == MovementType.DIAG_BW_LEFT || moveType == MovementType.DIAG_BW_RIGHT) {
            character.setSpeedModifier(.066f);
        } else if (moveType == MovementType.SIDE_LEFT || moveType == MovementType.SIDE_RIGHT) {
            character.setSpeedModifier(0.75f);
        } else if (moveType == MovementType.COLLISION) {
            // dont change speed modifier, as it is dynamically set.
            // reset movetype, cause 10 is non existant for the client
            moveType = MovementType.FORWARD;
        }

        if (moveType != MovementType.STOP && character.getMoveState() == MovementState.MOVE_CHANGE_DIR) {
            P026_MovementDirection movementDirection = new P026_MovementDirection();
            movementDirection.setAgentId(character.getAgentID());
            Vector2 direction = new Vector2(character.getDirection().getX(), character.getDirection().getY());
            movementDirection.setDirection(direction);
            movementDirection.setMoveType((short) moveType.getValue());
            recipient.write(movementDirection);
           
            // reset the moving state here
            character.setMoveState(MovementState.MOVE_KEEP_DIR);
        }

        P032_MovementSpeedModifier movementSpeedModifier = new P032_MovementSpeedModifier();
        movementSpeedModifier.setAgentId(character.getAgentID());
        movementSpeedModifier.setSpeed(character.getSpeedModifier());
        movementSpeedModifier.setMoveType((short) moveType.getValue());
        recipient.write(movementSpeedModifier);

        P030_MovementAim movementAim = new P030_MovementAim();
        movementAim.setAgentId(character.getAgentID());
        Vector2 position = new Vector2(character.getPosition().getX(), character.getPosition().getY());
View Full Code Here

TOP

Related Classes of be.demmel.jgws.MovementType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.