public static void createGeometry(Node node, GeometryData d) { if (d.getType().equals("box")) { if (d.getPhy()) { CG.createPhyBox(node, d); } else { CG.createBox(node, d); } } }
public static void createSinglePlayerArea(Node node) { node.setLocalTranslation(0, 100, 0); CG.createPhyBox( node, "floor", T.v3f(50, 0.1f, 50), T.v3f(0, -1, 0), T.getMaterialPath("lava_rock"), T.v2f(5, 5)); CG.createPhyBox( node, "wall", T.v3f(30, 20, 0.1f), T.v3f(0, 20, -60), T.getMaterialPath("BC_Tex"), T.v2f(15, 10)); CG.createPhyBox(node, "savior", T.v3f(10, 0.1f, 10), T.v3f(0, -101, 0), ColorRGBA.Yellow); }
public final void paint(LGraphics g) { if (!running || isClose()) { return; } if (sleep == 0) { if (scrCG == null) { return; } if (scrCG.getBackgroundCG() != null) { if (shakeNumber > 0) { g.drawImage( scrCG.getBackgroundCG(), shakeNumber / 2 - LSystem.random.nextInt(shakeNumber), shakeNumber / 2 - LSystem.random.nextInt(shakeNumber)); } else { g.drawImage(scrCG.getBackgroundCG(), 0, 0); } } int moveCount = 0; for (int i = 0; i < scrCG.getCharas().size(); i++) { Chara chara = (Chara) scrCG.getCharas().get(i); float value = 1.0f; if (chara.next()) { value = chara.getNextAlpha(); moveCount++; } g.setAlpha(value); chara.draw(g); g.setAlpha(1.0F); } drawScreen(g); if (desktop != null) { desktop.createUI(g); } if (sprites != null) { sprites.createUI(g); } } else { sleep--; if (color != null) { double alpha = (double) (sleepMax - sleep) / sleepMax; if (alpha < 1.0) { if (scrCG.getBackgroundCG() != null) { g.drawImage(scrCG.getBackgroundCG(), 0, 0); } g.setAlpha(alpha); g.setColor(color); g.fillRect(0, 0, getCurrentWidth(), getCurrentHeight()); g.setAlpha(1.0f); } } if (sleep <= 0) { sleep = 0; color = null; } } }
public void dispose() { running = false; try { if (avgThread != null) { avgThread.interrupt(); avgThread = null; } } catch (Exception e) { } if (desktop != null) { desktop = null; } if (sprites != null) { sprites = null; } if (command != null) { command = null; } if (scrCG != null) { scrCG.dispose(); scrCG = null; } super.dispose(); }
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; } } } }