/** * 定義を設定します。 * * @param descript 定義 */ public void setDescript(String descript) { this.descript = descript; try { BufferedReader r = new BufferedReader(new StringReader(descript)); while (true) { String line = r.readLine(); if (line == null) break; if (line.length() == 0) continue; String[] split = line.split(","); String id = split[0]; if (id.startsWith("collision")) { int x = Integer.parseInt(split[1]); int y = Integer.parseInt(split[2]); int w = Integer.parseInt(split[3]); int h = Integer.parseInt(split[4]); String name = split[5]; SerikoCollision collision = new SerikoCollision(x, y, w, h, name); collisions.put(id, collision); log.debug("collision id=" + id + ", " + collision); } else if (id.matches(".+interval")) { Matcher m = Pattern.compile("(.+)interval").matcher(id); m.matches(); id = m.group(1); String type = split[1]; SerikoAnimation animation = new SerikoAnimation(this, id, type); animations.put(id, animation); log.debug("interval id=" + id + ", " + animation); } else if (id.matches(".+pattern.+")) { Matcher m = Pattern.compile("(.+)pattern(.+)").matcher(id); m.matches(); id = m.group(1); // String index = m.group(2); String method; String surfaceId; int interval; if (split[3].matches("[0-9]+")) { method = split[1]; surfaceId = split[2]; interval = Integer.parseInt(split[3]); } else { surfaceId = split[1]; interval = Integer.parseInt(split[2]); method = split[3]; } int offsetX = Integer.parseInt(split[4]); int offsetY = Integer.parseInt(split[5]); SerikoAnimation animation = animations.get(id); animation.addPattern(method, surfaceId, interval, offsetX, offsetY); log.debug("pattern id=" + id + ", " + animation + ", method=" + method); } else { log.debug("unknown id=" + id); } } } catch (IOException x) { log.error("不正な定義です。", x); } }