Beispiel #1
0
 public void remove(ISprite sprite) {
   sprites.remove(sprite);
 }
Beispiel #2
0
  public synchronized void nextScript() {
    if (command != null && !isClose() && running) {
      for (; isRunning = command.next(); ) {
        String result = command.doExecute();
        if (result == null) {
          continue;
        }
        if (!nextScript(result)) {
          break;
        }
        List commands = Command.splitToList(result, " ");
        int size = commands.size();
        String cmdFlag = (String) commands.get(0);

        String mesFlag = null, orderFlag = null, lastFlag = null;
        if (size == 2) {
          mesFlag = (String) commands.get(1);
        } else if (size == 3) {
          mesFlag = (String) commands.get(1);
          orderFlag = (String) commands.get(2);
        } else if (size == 4) {
          mesFlag = (String) commands.get(1);
          orderFlag = (String) commands.get(2);
          lastFlag = (String) commands.get(3);
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_WAIT)) {
          scrFlag = true;
          break;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SNOW)
            || cmdFlag.equalsIgnoreCase(CommandType.L_RAIN)
            || cmdFlag.equalsIgnoreCase(CommandType.L_PETAL)) {
          if (sprites != null) {
            boolean flag = false;
            ISprite[] ss = sprites.getSprites();
            for (int i = 0; i < ss.length; i++) {
              ISprite s = ss[i];
              if (s instanceof FreedomEffect) {
                flag = true;
                break;
              }
            }
            if (!flag) {
              if (cmdFlag.equalsIgnoreCase(CommandType.L_SNOW)) {
                sprites.add(FreedomEffect.getSnowEffect());
              } else if (cmdFlag.equalsIgnoreCase(CommandType.L_RAIN)) {
                sprites.add(FreedomEffect.getRainEffect());
              } else if (cmdFlag.equalsIgnoreCase(CommandType.L_PETAL)) {
                sprites.add(FreedomEffect.getPetalEffect());
              }
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SNOWSTOP)
            || cmdFlag.equalsIgnoreCase(CommandType.L_RAINSTOP)
            || cmdFlag.equalsIgnoreCase(CommandType.L_PETALSTOP)) {
          if (sprites != null) {
            ISprite[] ss = sprites.getSprites();
            for (int i = 0; i < ss.length; i++) {
              ISprite s = ss[i];
              if (s instanceof FreedomEffect) {
                if (cmdFlag.equalsIgnoreCase(CommandType.L_SNOWSTOP)) {
                  if (((FreedomEffect) s).getKernels()[0] instanceof SnowKernel) {
                    sprites.remove(s);
                  }
                } else if (cmdFlag.equalsIgnoreCase(CommandType.L_RAINSTOP)) {
                  if (((FreedomEffect) s).getKernels()[0] instanceof RainKernel) {
                    sprites.remove(s);
                  }
                } else if (cmdFlag.equalsIgnoreCase(CommandType.L_PETALSTOP)) {
                  if (((FreedomEffect) s).getKernels()[0] instanceof PetalKernel) {
                    sprites.remove(s);
                  }
                }
              }
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_PLAY)) {
          playSound(mesFlag);
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_PLAYLOOP)) {
          // 待替换(J2SE版音频管理组件待完善,目前无法做到所有音频格式皆支持循环播放,预计0.3版完成)
          playSound(mesFlag);
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_PLAYSTOP)) {
          if (NumberUtils.isNumber(mesFlag)) {
            stopSound(Integer.parseInt(mesFlag));
          } else {
            stopSound();
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_FADEOUT)
            || cmdFlag.equalsIgnoreCase(CommandType.L_FADEIN)) {
          scrFlag = true;
          Color color = Color.black;
          if (mesFlag.equalsIgnoreCase("red")) {
            color = Color.red;
          } else if (mesFlag.equalsIgnoreCase("yellow")) {
            color = Color.yellow;
          } else if (mesFlag.equalsIgnoreCase("white")) {
            color = Color.white;
          } else if (mesFlag.equalsIgnoreCase("black")) {
            color = Color.black;
          } else if (mesFlag.equalsIgnoreCase("cyan")) {
            color = Color.cyan;
          } else if (mesFlag.equalsIgnoreCase("green")) {
            color = Color.green;
          } else if (mesFlag.equalsIgnoreCase("orange")) {
            color = Color.orange;
          } else if (mesFlag.equalsIgnoreCase("pink")) {
            color = Color.pink;
          }
          if (sprites != null) {
            sprites.removeAll();
            if (cmdFlag.equalsIgnoreCase(CommandType.L_FADEIN)) {
              sprites.add(Fade.getInstance(Fade.TYPE_FADE_IN, color));
            } else {
              sprites.add(Fade.getInstance(Fade.TYPE_FADE_OUT, color));
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SELLEN)) {
          if (mesFlag != null) {
            if (NumberUtils.isNumber(mesFlag)) {
              select.setLeftOffset(Integer.parseInt(mesFlag));
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SELTOP)) {
          if (mesFlag != null) {
            if (NumberUtils.isNumber(mesFlag)) {
              select.setTopOffset(Integer.parseInt(mesFlag));
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_MESLEN)) {
          if (mesFlag != null) {
            if (NumberUtils.isNumber(mesFlag)) {
              message.setMessageLength(Integer.parseInt(mesFlag));
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_MESTOP)) {
          if (mesFlag != null) {
            if (NumberUtils.isNumber(mesFlag)) {
              message.setTopOffset(Integer.parseInt(mesFlag));
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_MESLEFT)) {
          if (mesFlag != null) {
            if (NumberUtils.isNumber(mesFlag)) {
              message.setLeftOffset(Integer.parseInt(mesFlag));
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_MESCOLOR)) {
          if (mesFlag != null) {
            if (mesFlag.equalsIgnoreCase("red")) {
              message.setFontColor(Color.red);
            } else if (mesFlag.equalsIgnoreCase("yellow")) {
              message.setFontColor(Color.yellow);
            } else if (mesFlag.equalsIgnoreCase("white")) {
              message.setFontColor(Color.white);
            } else if (mesFlag.equalsIgnoreCase("black")) {
              message.setFontColor(Color.black);
            } else if (mesFlag.equalsIgnoreCase("cyan")) {
              message.setFontColor(Color.cyan);
            } else if (mesFlag.equalsIgnoreCase("green")) {
              message.setFontColor(Color.green);
            } else if (mesFlag.equalsIgnoreCase("orange")) {
              message.setFontColor(Color.orange);
            } else if (mesFlag.equalsIgnoreCase("pink")) {
              message.setFontColor(Color.pink);
            }
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_MES)) {
          if (select.isVisible()) {
            select.setVisible(false);
          }
          scrFlag = true;
          String nMessage = mesFlag;
          message.setMessage(StringUtils.replace(nMessage, "&", " "));
          message.setVisible(true);
          break;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_MESSTOP)) {
          scrFlag = true;
          message.setVisible(false);
          select.setVisible(false);
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SELECT)) {
          selectMessage = mesFlag;
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SELECTS)) {
          if (message.isVisible()) {
            message.setVisible(false);
          }
          select.setVisible(true);
          scrFlag = true;
          isSelectMessage = true;
          String[] selects = command.getReads();
          select.setMessage(selectMessage, selects);
          break;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SHAKE)) {
          shakeNumber = Integer.valueOf(mesFlag).intValue();
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_CGWAIT)) {
          scrFlag = false;
          break;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_SLEEP)) {
          sleep = Integer.valueOf(mesFlag).intValue();
          sleepMax = Integer.valueOf(mesFlag).intValue();
          scrFlag = false;
          break;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_FLASH)) {
          scrFlag = true;
          String[] colors = mesFlag.split(",");
          if (color == null && colors != null && colors.length == 3) {
            color =
                new Color(
                    Integer.valueOf(colors[0]).intValue(),
                    Integer.valueOf(colors[1]).intValue(),
                    Integer.valueOf(colors[2]).intValue());
            sleep = 20;
            sleepMax = sleep;
            scrFlag = false;
          } else {
            color = null;
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_GB)) {

          if (mesFlag == null) {
            return;
          }
          if (mesFlag.equalsIgnoreCase("none")) {
            scrCG.noneBackgroundCG();
          } else {
            scrCG.setBackgroundCG(mesFlag);
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_CG)) {

          if (mesFlag == null) {
            return;
          }
          if (mesFlag.equalsIgnoreCase(CommandType.L_DEL)) {
            if (orderFlag != null) {
              scrCG.removeImage(orderFlag);
            } else {
              scrCG.clear();
            }
          } else if (lastFlag != null && CommandType.L_TO.equalsIgnoreCase(orderFlag)) {
            Chara chara = scrCG.removeImage(mesFlag);
            if (chara != null) {
              int x = chara.getX();
              int y = chara.getY();
              chara = new Chara(lastFlag, 0, 0, getCurrentWidth());
              chara.setMove(false);
              chara.setX(x);
              chara.setY(y);
              scrCG.addChara(lastFlag, chara);
            }
          } else {
            int x = 0, y = 0;
            if (orderFlag != null) {
              x = Integer.parseInt(orderFlag);
            }
            if (size >= 4) {
              y = Integer.parseInt((String) commands.get(3));
            }
            scrCG.addImage(mesFlag, x, y, getCurrentWidth());
          }
          continue;
        }
        if (cmdFlag.equalsIgnoreCase(CommandType.L_EXIT)) {
          scrFlag = true;
          setFPS(LSystem.DEFAULT_MAX_FPS);
          running = false;
          onExit();
          break;
        }
      }
    }
  }
Beispiel #3
0
 public synchronized void remove(ISprite sprite) {
   if (sprites != null) {
     sprites.remove(sprite);
   }
 }