Package org.pokenet.server.backend.map

Examples of org.pokenet.server.backend.map.ServerMap


  public void run() {
    System.out.println("INFO: Npc sleep timer started");
    Random r = new Random();
    NonPlayerChar n = null;
    ServerMap m = null;
    while(m_running) {
      /*
       * Loop through every map
       */
      for(int x = 0; x < 100; x++) {
        for(int y = 0; y < 100; y++) {
          m = GameServer.getServiceManager().
            getMovementService().getMapMatrix().getMapByRealPosition(x, y);
          if(m != null) {
            /*
             * Loop through every npc on the map
             * If they're sleeping, check if its time to wake them
             */
            for(int i = 0; i < m.getNpcs().size(); i++) {
              n = m.getNpcs().get(i);
              if(n != null && !n.canBattle() &&
                  System.currentTimeMillis() - n.getLastBattleTime()
                  >= 300000 + r.nextInt(300000)) {
                n.setLastBattleTime(0);
              }
View Full Code Here


    /*
     * Reload all the maps
     */
    XMLMapTransformer loader = new XMLMapTransformer();
    File nextMap;
    ServerMap s;
    for(int x = -50; x < 50; x++) {
      for(int y = -50; y < 50; y++) {
        nextMap = new File("res/maps/" + String.valueOf(x) + "." + String.valueOf(y) + ".tmx");
        if(nextMap.exists()) {
          try {
            s = new ServerMap(loader.readMap(nextMap.getCanonicalPath()), x, y);
            s.setMapMatrix(m_mapMatrix);
            s.loadData();
            m_mapMatrix.setMap(s , x + 50, y + 50);
            Thread.sleep(100);
          } catch (Exception e) {
            System.err.println("Error loading " + x + "." + y + ".tmx - Bad map file");
            m_mapMatrix.setMap(null, x + 50, y + 50);
View Full Code Here

        /**
         * Called by m_thread.start()
         */
        public void run() {
                Object [] o;
                ServerMap m;
                IoSession s;
                while(true) {
                        //Send next local chat message
                        if(m_localQueue.peek() != null) {
                                o = m_localQueue.poll();
                                m = GameServer.getServiceManager().getMovementService().
                                        getMapMatrix().getMapByGamePosition(Integer.parseInt((String) o[1]), Integer.parseInt((String) o[2]));
                                if(m != null)
                                        m.sendChatMessage((String) o[0], Language.valueOf(((String)o[3])));
                        }
                        //Send next private chat message
                        if(m_privateQueue.peek() != null) {
                                o = m_privateQueue.poll();
                                s = (IoSession) o[0];
View Full Code Here

TOP

Related Classes of org.pokenet.server.backend.map.ServerMap

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.