예제 #1
0
  public boolean saveGame(String map) {
    Player p = m_game.getPlayer();
    GameConfig cfg = new GameConfig();
    cfg.put("tag", "GameSaveFile");
    cfg.put("x", (int) p.getX());
    cfg.put("y", (int) p.getY());
    cfg.put("name", p.getName());
    cfg.put("map", map);
    cfg.put("hp", p.HP);
    cfg.put("face", p.getFace());
    cfg.put("playtime", (int) m_game.getPlayTime());
    cfg.put("cansword", p.items[Player.ITEM_SWORD] != null);
    cfg.put("canshoot", p.items[Player.ITEM_RING] != null);
    cfg.put("canbomb", p.items[Player.ITEM_BOMB] != null);
    if (p.canShoot()) cfg.put("ring.num", p.items[Player.ITEM_RING].getCount());
    if (p.canBomb()) cfg.put("bomb.num", p.items[Player.ITEM_BOMB].getCount());
    if (p.curItem == p.items[Player.ITEM_SWORD]) cfg.put("curitem", "sword");
    else if (p.curItem == p.items[Player.ITEM_RING]) cfg.put("curitem", "ring");
    else if (p.curItem == p.items[Player.ITEM_BOMB]) cfg.put("curitem", "bomb");

    for (int i = 0; i < 256; i++) {
      if (p.hasKey[i]) cfg.put("key" + i, p.hasKey[i]);
      if (p.openedDoor[i]) cfg.put("door" + i, p.openedDoor[i]);
    }
    if (cfg.save(m_name + FILEDIR) == false) return false;
    cfg.reset();
    java.util.Map<String, String> vars = AbstractScript.getVars();
    Object[] keys = (vars.keySet().toArray());
    for (int i = 0; i < keys.length; i++) {
      cfg.put((String) keys[i], vars.get(keys[i]));
    }
    return cfg.save(m_name + FILEVARSDIR);
  }
예제 #2
0
 public void drawSelectIcon(Graphics2D g2d, int x, int y, boolean selected) {
   if (m_sicon == null) {
     g2d.setColor(Color.blue);
     g2d.drawRect(x, y, 32, 32);
     g2d.setColor(Color.yellow);
     if (selected) {
       g2d.fillRect(x + 1, y + 1, 30, 30);
     } else {
       g2d.fillRect(x, y, 32, 32);
     }
   } else {
     if (!selected) {
       Composite oldac = g2d.getComposite();
       AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
       g2d.setComposite(ac);
       g2d.drawImage(m_sicon, x, y, m_game.getPanel());
       g2d.setComposite(oldac);
     } else {
       g2d.drawImage(m_sicon, x, y, m_game.getPanel());
     }
   }
 }