Examples of HMObject


Examples of org.pokenet.client.backend.entity.HMObject

         * Parse all the information. This packet contains details for all players on this map
         */
        for(int i = 0; i < details.length - 1; i++) {
          p = new Player();
          try {
            HMObject hm = new HMObject(HMObject.parseHMObject(details[i]));
            i++;
            hm.setId(Integer.parseInt(details[i]));
            i ++;
            hm.setSprite(Integer.parseInt(details[i]));
            i ++;
            hm.setX(Integer.parseInt(details[i]));
            hm.setServerX(Integer.parseInt(details[i]));
            i++;
            hm.setY(Integer.parseInt(details[i]));
            hm.setServerY(Integer.parseInt(details[i]));
            i++;
            hm.setDirection(Direction.Down);
            hm.loadSpriteImage();
            p = hm;
          } catch (Exception e) {
            p.setUsername(details[i]);
            i++;
            p.setId(Integer.parseInt(details[i]));
            i++;
            p.setSprite(Integer.parseInt(details[i]));
            i++;
            p.setX(Integer.parseInt(details[i]));
            p.setServerX(Integer.parseInt(details[i]));
            i++;
            p.setY(Integer.parseInt(details[i]));
            p.setServerY(Integer.parseInt(details[i]));
            i++;
            switch(details[i].charAt(0)) {
            case 'D':
              p.setDirection(Direction.Down);
              break;
            case 'L':
              p.setDirection(Direction.Left);
              break;
            case 'R':
              p.setDirection(Direction.Right);
              break;
            case 'U':
              p.setDirection(Direction.Up);
              break;
            default:
              p.setDirection(Direction.Down);
              break;
            }
            p.loadSpriteImage();
          }
          if(p.getId() == m_game.getPlayerId()) {
            /*
             * This dude is our player! Store this information
             */
            p.setOurPlayer(true);
            OurPlayer pl;
            if(m_game.getOurPlayer() == null) {
              pl = new OurPlayer();
            } else {
              pl = new OurPlayer(m_game.getOurPlayer());
            }
            pl.set(p);
            m_game.setOurPlayer(pl);
            m_game.getMapMatrix().addPlayer(pl);
            GameClient.getInstance().setOurPlayer(pl);
            GameClient.getInstance().getOurPlayer().setAnimating(true);
          } else{
            m_game.getMapMatrix().addPlayer(p);
          }
        }
        break;
      case 'a':
        //Add player
        details = message.substring(2).split(",");
        p = new Player();
        try {
          HMObject hm = new HMObject(HMObject.parseHMObject(details[0]));
          hm.setId(Integer.parseInt(details[1]));
          hm.setSprite(Integer.parseInt(details[2]));
          hm.setX(Integer.parseInt(details[3]));
          hm.setServerX(Integer.parseInt(details[3]));
          hm.setY(Integer.parseInt(details[4]));
          hm.setServerY(Integer.parseInt(details[4]));
          hm.setDirection(Direction.Down);
          hm.loadSpriteImage();
          p = hm;
          p.setId(hm.getId());
        } catch (Exception e) {
          p.setUsername(details[0]);
          p.setId(Integer.parseInt(details[1]));
          p.setSprite(Integer.parseInt(details[2]));
          p.setX(Integer.parseInt(details[3]));
View Full Code Here

Examples of org.pokenet.server.backend.entity.HMObject

  public void run() {
    try {
      Scanner reader = new Scanner(m_file);
      NonPlayerChar npc = null;
      WarpTile warp = null;
      HMObject hmObject = null;
      TradeChar t = null;
      String line;
      String [] details;
      String direction = "Down";
      while(reader.hasNextLine()) {
        line = reader.nextLine();
        if(line.equalsIgnoreCase("[npc]")) {
          npc = new NonPlayerChar();
          npc.setName(reader.nextLine());
          direction = reader.nextLine();
          if(direction.equalsIgnoreCase("UP")) {
            npc.setFacing(Direction.Up);
          } else if(direction.equalsIgnoreCase("LEFT")) {
            npc.setFacing(Direction.Left);
          } else if(direction.equalsIgnoreCase("RIGHT")) {
            npc.setFacing(Direction.Right);
          } else {
            npc.setFacing(Direction.Down);
          }
          npc.setSprite(Integer.parseInt(reader.nextLine()));
          npc.setX((Integer.parseInt(reader.nextLine())) * 32);
          npc.setY(((Integer.parseInt(reader.nextLine())) * 32) - 8);
          //Load possible Pokemons
          line = reader.nextLine();
          if(!line.equalsIgnoreCase("NULL")) {
            details = line.split(",");
            HashMap<String, Integer> pokes = new HashMap<String, Integer>();
            for(int i = 0; i < details.length; i = i + 2) {
              pokes.put(details[i], Integer.parseInt(details[i + 1]));
            }
            npc.setPossiblePokemon(pokes);
          }
          //Set minimum party level
          npc.setPartySize(Integer.parseInt(reader.nextLine()));
          npc.setBadge(Integer.parseInt(reader.nextLine()));
          //Add all speech, if any
          line = reader.nextLine();
          if(!line.equalsIgnoreCase("NULL")) {
            details = line.split(",");
            for(int i = 0; i < details.length; i++) {
              npc.addSpeech(Integer.parseInt(details[i]));
            }
          }
          npc.setHealer(Boolean.parseBoolean(reader.nextLine().toLowerCase()));
          npc.setBox(Boolean.parseBoolean(reader.nextLine().toLowerCase()));
         
          //Setting ShopKeeper as an int.
          String shop = reader.nextLine();
          try {
            npc.setShopKeeper(Integer.parseInt(shop.trim()));
          } catch(Exception e) {
            try {
              /* Must be an old shop */
              if(Boolean.parseBoolean(shop.trim().toLowerCase())){
                npc.setShopKeeper(1); //Its an old shop! Yay!
              } else {
                npc.setShopKeeper(0); //Its an old npc. Not a shop.
              }
            } catch(Exception ex) {
              npc.setShopKeeper(0);//Dunno what the hell it is, but its not a shop.
            }
          }
        } else if(line.equalsIgnoreCase("[/npc]")) {
          m_map.addChar(npc);
        } else if(line.equalsIgnoreCase("[warp]")) {
          warp = new WarpTile();
          warp.setX(Integer.parseInt(reader.nextLine()));
          warp.setY(Integer.parseInt(reader.nextLine()));
          warp.setWarpX(Integer.parseInt(reader.nextLine()) * 32);
          warp.setWarpY((Integer.parseInt(reader.nextLine()) * 32) - 8);
          warp.setWarpMapX(Integer.parseInt(reader.nextLine()));
          warp.setWarpMapY(Integer.parseInt(reader.nextLine()));
          warp.setBadgeRequirement(Integer.parseInt(reader.nextLine()));
        } else if(line.equalsIgnoreCase("[/warp]")) {
          m_map.addWarp(warp);
        } else if(line.equalsIgnoreCase("[hmobject]")) {
          hmObject = new HMObject();
          hmObject.setName(reader.nextLine());
          hmObject.setType(HMObject.parseHMObject(hmObject.getName()));
          hmObject.setX(Integer.parseInt(reader.nextLine()) * 32);
          hmObject.setOriginalX(hmObject.getX());
          hmObject.setY((Integer.parseInt(reader.nextLine()) * 32) - 8);
          hmObject.setOriginalY(hmObject.getY());
        } else if(line.equalsIgnoreCase("[/hmobject]")) {
          hmObject.setMap(m_map, Direction.Down);
        } else if(line.equalsIgnoreCase("[trade]")) {
          t = new TradeChar();
          t.setName(reader.nextLine());
          direction = reader.nextLine();
          if(direction.equalsIgnoreCase("UP")) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.