Package com.benkyou.common

Examples of com.benkyou.common.Player


    @Override
    public void simpleUpdate(float tpf) {
        if (newPlayer) {
            Iterator playerIterator = getPlayerList().iterator();
            while (playerIterator.hasNext()) {
                Player p = (Player) playerIterator.next();
                System.out.println(p + " newPlayer? " + newPlayer + " updateNeeded? " + p.isAtachementUpdate());
                if (p.isAtachementUpdate()) {
                    if (!p.isAttached()) {
                        p.setChatter(new Chatter(p.getName(), p.getUUID()));
                        this.formHandler.addNewUser(p.getChatter());
                        //p.getAvatar().setLocalTranslation(Player.spawnLocation);
                        worldPhysics.setupAllPlayers();
                        p.setAttached(true);
                        //rootNode.attachChild(p.getAvatar());
                    }
                    p.setAtachementUpdate(false);
                }

                if (p.isMarkedForDeletion()) {
                    System.out.println("Deleting player " + p);
                    rootNode.detachChild(p.getAvatar());
                    rootNode.detachChild(p);
                    p.detachAllChildren();
                    //getPlayerList().remove(p);
                    p.setMarkedForDeletion(false);
                    this.formHandler.removeUser(p.getChatter());
                }
                newPlayer = false;
            }
                if(needsToBeDeleted.size() > 0){
            for(String uuid : needsToBeDeleted){
                Player deletePlayer;
                deletePlayer = this.getPlayerByUUID(uuid);
                deletePlayer.setMarkedForDeletion(true);
            }
            newPlayer = true;
            needsToBeDeleted.clear();
        }
           
View Full Code Here


    /**
     *
     */
    public void addMainPlayer() {
        Player p = addPlayer(getPlayerName(), getPlayerID(), getMainPlayerUUID()).setAsMainPlayer();
        getCamSys().setupChaseCam(p.getAvatar(), inputManager);
    }
View Full Code Here

     * @param name
     * @param id
     * @return
     */
    public Player addPlayer(String name, int id, String uuid) {
        Player p = new Player(this, id, name, uuid);
        getPlayerList().add(p);
        //rootNode.attachChild(playerList.get(playerList.size() - 1));
        return p;
    }
View Full Code Here

    public void setNewPlayer(Boolean newPlayer) {
        this.newPlayer = newPlayer;
    }

    public Player getPlayerByName(String name) {
        Player p = null;
        for (Player search : getPlayerList()) {
            if (search.getName().equalsIgnoreCase(name)) {
                p = search;
            }
        }
View Full Code Here

    public String getMainPlayerUUID() {
        return playerUUID;
    }

    public Player getPlayerByUUID(String uuid) {
        Player returner = null;
        System.out.println("Searching for player with uuid " + uuid);
        ArrayList<Player> players = (ArrayList<Player>) getPlayerList().clone();
        Iterator playerIterator = getPlayerList().iterator();
        while (playerIterator.hasNext()) {
        Player p = (Player) playerIterator.next();
            System.out.println("traversing through player list " + p + " for uuid " + uuid);
            if (p.getUUID().equals(uuid)) {
                returner = p;
            }
        }
        return returner;
    }
View Full Code Here

        }
    }

    private void syncPlayer(Player syncMessagePlayer) {

        Player syncedPlayer = new Player(this, syncMessagePlayer.getID(), syncMessagePlayer.getName(), syncMessagePlayer.getUUID());
        newPlayer = true;
        getPlayerList().add(syncedPlayer);
    }
View Full Code Here

    public void messageReceived(HostedConnection source, Message m) {
        if (m instanceof LoginMessage) {
            LoginMessage loginMessage = (LoginMessage) m;
            if (gameServer.login(loginMessage.getLoginName(), loginMessage.getPassword())) {
                Player p =new Player(loginMessage.getLoginName(), loginMessage.getID(), (String) source.getAttribute("UUID"));
                System.out.println("Client connected! username: " + loginMessage.getLoginName() + " ip: " + source.getAddress() );
                gameServer.getPlayerList().add(p);
                source.getServer().getConnection(source.getId()).send(new PlayerMessage(loginMessage.getLoginName(),loginMessage.getID(),p.getUUID()));
                //gameServer.getMyServer().broadcast(Filters.notEqualTo(source), new LoginMessage(loginMessage.getLoginName(), null, loginMessage.getID(), p.getUUID()));
                  gameServer.getMyServer().broadcast(new ChatClientMessage("BenkyouServer", p.getName() + " Has joined the server!"));
                gameServer.syncPlayers();
           
           
            }
        }
View Full Code Here

       
        if(m instanceof PlayerMessage){
            PlayerMessage playerMessage = (PlayerMessage) m;
            if(gameClient.isUp() && playerMessage.isMove()){

                Player player;
                player = gameClient.getPlayerByName(playerMessage.getName());
                if(player != null){
                player.setWalkDirection(playerMessage.getX(), playerMessage.getY(), playerMessage.getZ());
                player.setCurrentPosition(playerMessage.getPosX(), playerMessage.getPosY(), playerMessage.getPosZ());
                player.getAvatarControlSystem().setUpdateNeeded(true);
                }
            }else if(!playerMessage.isMove()){
            gameClient.setMainPlayer(playerMessage.getName(), playerMessage.getId(), playerMessage.getUUID());
            gameClient.getFormHandler().startGame();
       
            }
        }
        if(m instanceof PlayerSyncMessage){
            PlayerSyncMessage sync = (PlayerSyncMessage) m;
            for(PlayerMessage play: sync.getLoggedInPlayers()){
              players.add(new Player(play.getName(), play.getId(), play.getUUID()));
            }
            gameClient.processSyncMessage(players);
            players.clear();
          
        }
View Full Code Here

TOP

Related Classes of com.benkyou.common.Player

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.