/** * 读取游戏脚本 * * @return */ boolean nextCommand() { if (this.sequenceCount < 0) { Enumeration<?> e = this.stgObjects.elements(); while (e.hasMoreElements()) { STGObject shot = (STGObject) e.nextElement(); if (shot.attribute == ENEMY) { return true; } } this.sequenceCount = 0; } if (this.sequenceCount > 0) { --this.sequenceCount; return true; } else { try { for (; command.next(); ) { String cmd = command.doExecute(); if (cmd == null) { continue; } else { if (onCommandAction(cmd)) { return true; } List<?> commands = Command.splitToList(cmd, " "); if (commands.size() > 0) { String cmdName = (String) commands.get(0); if (cmdName.equalsIgnoreCase("sleep")) { this.sequenceCount = Integer.parseInt((String) commands.get(1)); } else if (cmdName.equalsIgnoreCase("wait")) { this.sequenceCount = -1; } else if (cmdName.equalsIgnoreCase("enemy")) { String enemy = (String) commands.get(1); int x = Integer.parseInt((String) commands.get(2)); int y = Integer.parseInt((String) commands.get(3)); if (StringUtils.charCount(enemy, '.') > 0) { addClass(enemy, x, y, cmd_enemy_no); } else { addClass(cmd_pack + "." + enemy, x, y, cmd_enemy_no); } } else if (cmdName.equalsIgnoreCase("package")) { this.cmd_pack = (String) commands.get(1); } else if (cmdName.equalsIgnoreCase("leader")) { String hero = (String) commands.get(1); int x = Integer.parseInt((String) commands.get(2)); int y = Integer.parseInt((String) commands.get(3)); if (StringUtils.charCount(hero, '.') > 0) { addHeroClass(hero, x, y); } else { addHeroClass(cmd_pack + "." + hero, x, y); } } return true; } } } return false; } catch (Exception ex) { return false; } } }