Package utility

Examples of utility.GamePacket


        responseCode = Constants.SMSG_UPDATE_CASH;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        packet.addInt32(amount);
        packet.addInt32(cash);
        return packet.getBytes();
    }
View Full Code Here


        responseCode = Constants.SMSG_SHOP_LIST_ANIMAL;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);

        if (allAnimalType != null) {
            packet.addShort16((short) allAnimalType.size());

            for (AnimalType at : allAnimalType) {
                packet.addShort16((short) at.getID());
                packet.addString(at.getSpeciesName());
                packet.addString(at.getDescription());
                packet.addString(at.getCategory());
                packet.addShort16((short) at.getCost());

                String predatorList = "";
                for (SpeciesType predator : at.getPredatorList(Constants.ORGANISM_TYPE_ANIMAL)) {
                    predatorList += predator.getSpeciesName() + ", ";
                }
                if (predatorList.endsWith(", ")) {
                    predatorList = predatorList.substring(0, predatorList.lastIndexOf(","));
                }

                String preyList = "";
                for (SpeciesType prey : at.getPreyList(Constants.ORGANISM_TYPE_ANIMAL)) {
                    preyList += prey.getSpeciesName() + ", ";
                }
                for (SpeciesType prey : at.getPreyList(Constants.ORGANISM_TYPE_PLANT)) {
                    preyList += prey.getSpeciesName() + ", ";
                }
                if (preyList.endsWith(", ")) {
                    preyList = preyList.substring(0, preyList.lastIndexOf(","));
                }

                packet.addString(predatorList);
                packet.addString(preyList);

                packet.addShort16((short) at.getAvgBiomass());
                packet.addShort16((short) at.getMass());
                packet.addShort16((short) at.getMovtForce());
                packet.addShort16((short) at.getMaxForce());
                packet.addInt32(at.getModelID());
                packet.addString(at.getAnimalCategory());
            }
        }

        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_STATISTICS;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        status = 0;
        if (animalStatList != null) {
            packet.addShort16(status);
            int size = animalStatList.size() + plantStatList.size();
            packet.addShort16((short)size );

            for (Stat st : animalStatList) {
                packet.addShort16((short) st.getActivityDay());
                packet.addString(st.getAnimalName());
                packet.addString(st.getActivityType());
                packet.addShort16((short) st.getCount());
                //packet.addInt32( st.getEnvironmentScore());
                //packet.addString(st.getActivityMessage());
            }
           
            for (Stat st : plantStatList) {
                packet.addShort16((short) st.getActivityDay());
                packet.addString(st.getPlantName());
                packet.addString(st.getActivityType());
                packet.addShort16((short) st.getCount());
                //packet.addInt32( st.getEnvironmentScore());
                //packet.addString(st.getActivityMessage());
            }
        }else{
          packet.addShort16((short) 1);
        }
        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_MOVE_ANIMAL;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        packet.addShort16(status);
        if (status == 0) {//0 means moving is successful.
            packet.addShort16(xTarg);
            packet.addShort16(yTarg);
        }

        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_UPDATE_LEVEL;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        packet.addShort16((short) amount);
        packet.addShort16((short) level);
        packet.addString(range);
        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_KILL_PLANT;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        packet.addInt32(plant_id);
        packet.addInt32(predator_id);
        packet.addShort16(count);
        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_GET_ENV;
    }

    @Override
    public byte[] constructResponseInBytes() {;
        GamePacket packet = new GamePacket(responseCode);
        packet.addShort16(status);

        if (status == 0) {
            packet.addShort16((short) world.getEnvironments().size());

            for (Environment env : world.getEnvironments()) {
                packet.addInt32(env.getID());
                packet.addShort16((short) env.getRow());
                packet.addShort16((short) env.getColumn());
                packet.addInt32(env.getOwnerID());
                packet.addInt32(env.getEnvironmentScore());

                for (Zone zone : env.getZones()) {
                    packet.addBoolean(zone.isEnable());
                    packet.addShort16((short) zone.getID());
                    packet.addShort16((short) zone.getType());

                    WaterSource waterSource = zone.getWaterSource();
                    packet.addBoolean(waterSource != null);

                    if (waterSource != null) {
                        packet.addInt32(waterSource.getID());
                        packet.addInt32(waterSource.getMaxWater());
                        packet.addInt32(waterSource.getWater());
                    }
                }
            }
        }

        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_PLACE_SPECIES;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        packet.addShort16(status);
        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_UPDATE_GAME_SCALE_TIME;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
        packet.addLong(time);
        return packet.getBytes();
    }
View Full Code Here

        responseCode = Constants.SMSG_CHANGE_TEAM_PVP;
    }

    @Override
    public byte[] constructResponseInBytes() {
        GamePacket packet = new GamePacket(responseCode);
//        packet.addShort16(status);

        if (this.status == 0) {
            packet.addShort16((short) world.getEnvironments().size());
            for (Environment env : world.getEnvironments()) {
//                packet.addString(env.getAvatar().getPlayer().getUsername());
//                packet.addShort16((short)env.getEnvRow());
//
//                if(env.getAvatar().getAvatarType()!=null){
//                    packet.addString(env.getClient().getAvatar().getAvatarType());
//                }else{
//                    packet.addString("none");
//                }
//
//                packet.addShort16((short)env.getAvatar().getIsReady());
            }
        }

        return packet.getBytes();

    }
View Full Code Here

TOP

Related Classes of utility.GamePacket

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.