Ejemplo n.º 1
0
 public void remove(String name) {
   if (!StringUtils.isEmpty(name)) {
     String funName = name.trim().toLowerCase();
     _system_functs.remove(funName);
     _rocFunctions.remove(funName);
   }
 }
Ejemplo n.º 2
0
 /**
  * 添加自定义函数到脚本中
  *
  * @param name
  * @param rfunction
  */
 public void add(String name, IRocFunction rfunction) {
   if (!StringUtils.isEmpty(name)) {
     String funName = name.trim().toLowerCase();
     _system_functs.add(funName);
     _rocFunctions.put(funName, rfunction);
   }
 }
Ejemplo n.º 3
0
 @Override
 public void drawString(GLEx g, String string, float tx, float ty, float angle, LColor c) {
   if (c == null || c.a <= 0.01) {
     return;
   }
   if (StringUtils.isEmpty(string)) {
     return;
   }
   LSTRDictionary.drawString(g, this, string, _offset.x + tx, _offset.y + ty, angle, c);
 }
Ejemplo n.º 4
0
 public Object getValue(RocScript script, String name, String value) {
   if (name == null) {
     return value;
   }
   String key = name.trim().toLowerCase();
   if ("trim".equals(key)) {
     if (value.indexOf(",") == -1) {
       return StringUtils.trim(value);
     }
   } else if ("rtrim".equals(key)) {
     if (value.indexOf(",") == -1) {
       return StringUtils.rtrim(value);
     }
   } else if ("isnan".equals(key)) {
     if (value.indexOf(",") == -1) {
       return MathUtils.isNan(value);
     }
   } else if ("ischinese".equals(key)) {
     if (value.indexOf(",") == -1) {
       return StringUtils.isChinaLanguage(value);
     }
   } else if ("indexof".equals(key)) {
     if (value.indexOf(",") != -1) {
       String[] split = StringUtils.split(value, ',');
       if (split.length == 2) {
         return split[0].indexOf(split[1]) != -1;
       }
     }
   } else if ("jump".equals(key)) {
     script._sleep = JUMP_TYPE;
   }
   IRocFunction roc = (IRocFunction) _rocFunctions.get(key);
   if (roc != null) {
     String[] args = StringUtils.split(value, ',');
     Object o = roc.call(args);
     if (o != null) {
       return o;
     }
   }
   return name;
 }
Ejemplo n.º 5
0
 public static String getResourcePath(String name) throws IOException {
   if (self == null) {
     return name;
   }
   if (LSystem.base().type() == LGame.Type.ANDROID) {
     if (name.toLowerCase().startsWith("assets/")) {
       name = StringUtils.replaceIgnoreCase(name, "assets/", "");
     }
     if (name.startsWith("/") || name.startsWith("\\")) {
       name = name.substring(1, name.length());
     }
   }
   File file = new File(self.getFilesDir(), name);
   if (!file.exists()) {
     retrieveFromAssets(self, name);
   }
   return file.getAbsolutePath();
 }
Ejemplo n.º 6
0
 /**
  * 读取游戏脚本
  *
  * @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;
     }
   }
 }