Package model

Examples of model.Environment


     * @param  worldType            GameMode: pvp/pve
     * @param  row                  The row of the environment
     * @param  col                  The col of the environment
     */
    public Environment removeAnEnvFromWorld(int worldID, int worldType, int row, int col) {
        Environment env = null;
        if (worldType == Constants.GAME_TYPE_PVP) {
            World pvpWorld = activePvPWorld.get(worldID);
            if (pvpWorld != null) {
                env = pvpWorld.getEnvByRowAndCol(row, col);
                if (env != null) {
View Full Code Here


                        int col = map.getCol(position);

                        WorldMapDAO.updatePvEWorldMap(map);

                        //Create a new environment for this user.
                        Environment env = new Environment(-1);
                        env.setOwnerID(client.getPlayer().getID());
                        env.setPos(row, col);
                        env.setWorldID(world.getID());

                        int env_id = EnvironmentDAO.createEnvironment(env);
                        env.setID(env_id);

                        Random random = new Random();

                        //Handle the zones in this environment.
                        for (int i = 0; i < 3; i++) {
                            for (int j = 0; j < 3; j++) {
                                Zone zone = new Zone(-1);
                                zone.setOrder(i * 3 + j);
                                zone.setEnvID(env.getID());
                                zone.setEnvironment(env);
                                zone.setRow(i);
                                zone.setColumn(j);
                                zone.setCurrentTimeStep(1);

                                zone.setType(random.nextInt(3) + 1);

                                int zone_id = ZoneDAO.createZone(zone);
                                zone.setID(zone_id);

                                ParamTableDAO.createParameters(zone_id);
                                PreyPredatorRatioDAO.createParameters(world.getCreatorID(),zone_id);
                                zone.setParameters(ParamTableDAO.getByZoneID(zone_id));

                                ZoneType zoneType = ZoneTypeDAO.getZoneType(zone.getType());

                                if (zoneType.containsWater()) {
                                    WaterSource waterSource = new WaterSource(-1);
                                    waterSource.setMaxWater(100);
                                    waterSource.setWater(100);
                                    waterSource.setZoneID(zone_id);

                                    int water_source_id = WaterSourceDAO.createWaterSource(waterSource);
                                    waterSource.setID(water_source_id);

                                    zone.setWaterSource(waterSource);
                                }

                                env.setZone(zone);
                            }
                        }

                        for (Environment e : world.getEnvironments()) {
                            for (Zone zone : e.getZones()) {
                                if (zone.isEnable()) {
                                    for (Organism organism : zone.getOrganisms()) {
                                        if (organism.getOrganismType() == Constants.ORGANISM_TYPE_PLANT) {
                                            ResponseBirthPlant responseBirthPlant = new ResponseBirthPlant();
                                            responseBirthPlant.setPlant((Plant) organism);
                                            responses.add(responseBirthPlant);
                                        } else if (organism.getOrganismType() == Constants.ORGANISM_TYPE_ANIMAL) {
                                            ResponseBirthAnimal responseBirthAnimal = new ResponseBirthAnimal();
                                            responseBirthAnimal.setAnimal((Animal) organism);
                                            responses.add(responseBirthAnimal);
                                        }
                                    }
                                }
                            }
                        }

                        ResponseCreateEnv responseCreateEnv = new ResponseCreateEnv();
                        responseCreateEnv.setEnvironment(env);
                        client.getServer().addResponseToOtherPeopleInTheSameWorld(client.getId(), world.getID(), responseCreateEnv);

                        Zone startZone = env.getZones().get(0);

                        SimulationEngine se = startZone.getSimulationEngine();
                        String networkName = "WoB-" + env.getID() + "." + startZone.getOrder() + "-" + System.currentTimeMillis() % 100000;

                        int nodeList[] = {13, 20, 31};
                        startZone.setManipulationID(se.createAndRunSeregenttiSubFoodweb(nodeList, networkName, 0, 0, false));

                        ZoneDAO.updateManipulationID(startZone.getID(), startZone.getManipulationID());
View Full Code Here

TOP

Related Classes of model.Environment

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.