Package gwlpr.database.entities

Examples of gwlpr.database.entities.Spawnpoint


        // pick a random spawnpoint
        Iterator<Spawnpoint> it = world.getMap().getSpawnpointCollection().iterator();
        for (int i = 0; i < ((int)Math.random() * world.getMap().getSpawnpointCollection().size() -1); i++) {
            it.next();
        }
        Spawnpoint spawn = it.next();
        int radius = spawn.getRadius();
       
        // pick a random position in a certain radius
        float t = (float)(2 * Math.PI * Math.random());
        float r = (float)(radius * -1 + (Math.random() * radius));
        WorldPosition pos = new WorldPosition(
                (float)(spawn.getX() + (r * Math.cos(t))),
                (float)(spawn.getY() + (r * Math.sin(t))),
                spawn.getPlane());
       
        return pos;
    }
View Full Code Here


        spawnpoint.getSpawnpointPK().setMapID(spawnpoint.getMap().getId());
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Spawnpoint persistentSpawnpoint = em.find(Spawnpoint.class, spawnpoint.getSpawnpointPK());
            Map mapOld = persistentSpawnpoint.getMap();
            Map mapNew = spawnpoint.getMap();
            if (mapNew != null) {
                mapNew = em.getReference(mapNew.getClass(), mapNew.getId());
                spawnpoint.setMap(mapNew);
            }
View Full Code Here

    public void destroy(SpawnpointPK id) throws NonexistentEntityException {
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            Spawnpoint spawnpoint;
            try {
                spawnpoint = em.getReference(Spawnpoint.class, id);
                spawnpoint.getSpawnpointPK();
            } catch (EntityNotFoundException enfe) {
                throw new NonexistentEntityException("The spawnpoint with id " + id + " no longer exists.", enfe);
            }
            Map map = spawnpoint.getMap();
            if (map != null) {
                map.getSpawnpointCollection().remove(spawnpoint);
                map = em.merge(map);
            }
            em.remove(spawnpoint);
View Full Code Here

TOP

Related Classes of gwlpr.database.entities.Spawnpoint

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.