private void breed() throws VariableException { // マスコットを1個作成 final Mascot mascot = new Mascot(); log.log(Level.INFO, "増殖({0},{1},{2})", new Object[] {getMascot(), this, mascot}); // 範囲外から開始 if (getMascot().isLookRight()) { mascot.setAnchor( new Point( getMascot().getAnchor().x - getBornX(), getMascot().getAnchor().y + getBornY().intValue())); } else { mascot.setAnchor( new Point( getMascot().getAnchor().x + getBornX(), getMascot().getAnchor().y + getBornY().intValue())); } mascot.setLookRight(getMascot().isLookRight()); try { mascot.setBehavior(Main.getInstance().getConfiguration().buildBehavior(getBornBehavior())); getMascot().getManager().add(mascot); } catch (final BehaviorInstantiationException e) { log.log(Level.SEVERE, "生まれた時の行動の初期化に失敗しました", e); mascot.dispose(); } catch (final CantBeAliveException e) { log.log(Level.SEVERE, "生き続けることが出来ない状況", e); mascot.dispose(); } }
private void mousePressed(final MouseEvent event) { // Switch to drag the animation when the mouse is down if (getBehavior() != null) { try { getBehavior().mousePressed(event); } catch (final CantBeAliveException e) { log.log(Level.SEVERE, "Fatal Error", e); Main.showError("Severe Shimeji Error.\nSee log for more details."); dispose(); } } }
void tick() { if (isAnimating()) { if (getBehavior() != null) { try { getBehavior().next(); } catch (final CantBeAliveException e) { log.log(Level.SEVERE, "Fatal Error.", e); Main.showError("Could not get next behavior.\nSee log for more details."); dispose(); } setTime(getTime() + 1); } } }
private void mouseReleased(final MouseEvent event) { if (event.isPopupTrigger()) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { showPopup(event.getX(), event.getY()); } }); } else { if (getBehavior() != null) { try { getBehavior().mouseReleased(event); } catch (final CantBeAliveException e) { log.log(Level.SEVERE, "Fatal Error", e); Main.showError("Severe Shimeji Error.\nSee log for more details."); dispose(); } } } }