protected void reset() { paused = false; Sprite.spriteContext = this; sprites.clear(); try { level = currentLevel.clone(); } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } level.resetSpriteTemplate(); layer = new LevelRenderer(level, graphicsConfiguration, 320, 240); double oldX = 0; if (mario != null) oldX = mario.x; mario = new Mario(this); sprites.add(mario); startTime = 1; timeLeft = 200 * 15; Art.startMusic(1); tick = 0; // recorder = new DataRecorder(this,level,keys,gametype); // recorder.detailedLog = ""; gameStarted = false; }
public Emitter clone() throws CloneNotSupportedException { try { return (Emitter) super.clone(); } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } }
/** * Clones this Step. * * @return a clone of this step */ public Object clone() { try { Step step = (Step) super.clone(); step.points = new TPoint[points.length]; step.screenPoints = new Point[points.length]; step.marks = new HashMap<TrackerPanel, Mark>(); return step; } catch (CloneNotSupportedException ex) { ex.printStackTrace(); } return null; }
/** A check for cloning. */ public void testCloning2() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); r1.setBasePaint(Color.blue); r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); MyRendererChangeListener listener = new MyRendererChangeListener(); r2.addChangeListener(listener); r2.setBasePaint(Color.red); assertTrue(listener.lastEvent.getRenderer() == r2); assertFalse(r1.hasListener(listener)); }
public void handleHeroRespawnRequest(HeroRespawnRequest request) { Cell cell = dao.getHeroBeginPosition(request.getHeroSlot()); cell.setX(cell.getColPos() * Utilizer.TILE_SIZE); cell.setY(cell.getRowPos() * Utilizer.TILE_SIZE); try { request.setRespawnPos(cell.clone()); for (Iterator it = team2.iterator(); it.hasNext(); ) { Player player = (Player) it.next(); player.getCom().write(request); } for (Iterator it = team1.iterator(); it.hasNext(); ) { Player player = (Player) it.next(); // if(player.getSlotIndex()!=request.getSlotIndex()) player.getCom().write(request); } } catch (CloneNotSupportedException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } }
@Override public void mouseClicked(MouseEvent e) { // To change body of implemented methods use File | Settings | File Templates. GameMap temp = panel; temp.setStatus("selected"); Cell selectCell = new Cell(); Point curPos = e.getPoint(); int x = (curPos.x + panel.getScrollX()) / Utilizer.TILE_SIZE; selectCell.setColPos(x); x = x * Utilizer.TILE_SIZE; selectCell.setX(x); int y = (curPos.y + panel.getScrollY()) / Utilizer.TILE_SIZE; selectCell.setRowPos(y); y = y * Utilizer.TILE_SIZE; selectCell.setY(y); temp.setSelectedCell(selectCell); panel.requestFocus(); if (e.isMetaDown()) { panel.getFacade().getMainHero().setIsChosen(false); } model.Character clickedCharacter = panel.getFacade().getCharacterByCord(selectCell.getRowPos(), selectCell.getColPos()); mainHero = panel.getFacade().getMainHero(); if (clickedCharacter != null && !mainHero.getStatus().equals(HeroStatus.attacking)) { if (mainHero.getStatus().equals(HeroStatus.standing)) controlPanel.setCharacter(clickedCharacter); // panel.getFacade().setCurrentHero(clickedHero); if (clickedCharacter instanceof Hero) { Hero clickedHero = (Hero) clickedCharacter; if (clickedHero.equals(mainHero)) { mainHero.setIsChosen(true); mainHero.resetPath(); mainHero.calculateRange( mainHero.getRow(), mainHero.getCol(), ((int) mainHero.getAP() / 2) + 1); if ((mainHero.getCurrentSkill()) != null) { if (mainHero.getCurrentSkill() instanceof AOESkill) ((AOESkill) mainHero.getCurrentSkill()).clearRangeCell(); } } } if (panel.getFacade().getIsLocked()) { panel.repaint(); return; } } // To set Hero /*if(selectCell.getRowPos()==panel.getHero().getRow() && selectCell.getColPos()==panel.getHero().getCol()){ panel.getHero().setIsChosen(true); panel.getHero().setStatus(HeroStatus.standing); panel.getHero().resetPath(); panel.getHero().calculateRange(panel.getHero().getRow(), panel.getHero().getCol(), ((int) panel.getHero().getAP() / 2) + 1); if(( panel.getHero().getCurrentSkill())!=null){ if( panel.getHero().getCurrentSkill() instanceof AOESkill) ((AOESkill) panel.getHero().getCurrentSkill()).clearRangeCell(); } }*/ else if (panel.getFacade().getIsLocked()) { panel.repaint(); return; } else if (mainHero.getIsChosen() && mainHero.getStatus().equals(HeroStatus.standing) && Utilizer.inRange(selectCell, mainHero.getRange())) { // send moving request int gameIndex = panel.getFacade().getGameIndex(); int heroSlot = panel.getFacade().getHeroSlot(); mainHero.setShortestPathSelect(mainHero.getShortestpathHover()); HeroMoveRequest moveRequest = null; try { moveRequest = new HeroMoveRequest(gameIndex, heroSlot, mainHero.clone()); moveRequest.setSelectedCell(selectCell.clone()); com.write(moveRequest); } catch (CloneNotSupportedException e1) { e1.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } // HeroAnimation.move(mainHero,panel); if ((mainHero.getCurrentSkill()) != null) { if (mainHero.getCurrentSkill() instanceof AOESkill) ((AOESkill) mainHero.getCurrentSkill()).clearRangeCell(); } } // cast AOE skill else if (mainHero.getIsChosen() && mainHero.getStatus().equals(HeroStatus.attacking) && mainHero.getCurrentSkill().getStatus().equals(SkillStatus.before) && mainHero.getCurrentSkill().getPath().contains(selectCell) && (mainHero.getAP() - mainHero.getCurrentSkill().getAP()) >= 0 && mainHero.getCurrentSkill() != null && Utilizer.inRange(selectCell, mainHero.getCurrentSkill().getRangeCell())) { // send attack request int gameIndex = panel.getFacade().getGameIndex(); int heroSlot = panel.getFacade().getHeroSlot(); if (selectCell.getColPos() < mainHero.getCol()) mainHero.setCurrentSprite(16); else mainHero.setCurrentSprite(20); HeroAttackRequest attackReq = null; if (mainHero.getCurrentSkill() instanceof NormalSkill) mainHero.getCurrentSkill().getDmgCell().clear(); mainHero.getCurrentSkill().getDmgCell().add(selectCell); try { Hero cloneHero = mainHero.clone(); // cloneHero.getCurrentSkill().clonePath(mainHero.getCurrentSkill().getPath()); attackReq = new HeroAttackRequest(gameIndex, heroSlot, cloneHero); attackReq.setSelectedCell(selectCell.clone()); attackReq.setPath(mainHero.getCurrentSkill().getPath()); attackReq.setDmgCell(mainHero.getCurrentSkill().getDmgCell()); com.write(attackReq); } catch (CloneNotSupportedException e1) { e1.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } /*if(mainHero.getCurrentSkill() instanceof NormalSkill) mainHero.getCurrentSkill().getDmgCell().clear(); mainHero.getCurrentSkill().getDmgCell().add(selectCell); if(Utilizer.inRange(new Cell(panel.getMonster().getCol(),panel.getMonster().getRow()), mainHero.getCurrentSkill().getDmgCell()) ){ panel.getMonster().setHP(panel.getMonster().getHP()-panel.getHero().getCurrentSkill().getDamage(mainHero)); panel.setDamage(mainHero.getCurrentSkill().getDamage(panel.getHero())); }else panel.setDamage(0);*/ } /*//cast cleave skill else if(panel.getHero().getIsChosen() && panel.getHero().getStatus().equals(HeroStatus.attacking) && panel.getHero().getCurrentSkill().getStatus().equals(SkillStatus.before) && panel.getHero().getCurrentSkill().getPath().contains(selectCell) && (panel.getHero().getAP()-panel.getHero().getCurrentSkill().getAP())>=0 && ! (panel.getHero().getCurrentSkill() instanceof AOESkill) && ! (panel.getHero().getCurrentSkill() instanceof NormalSkill)){ HeroAnimation.attack(panel.getHero(),panel); if(Utilizer.inRange(new Cell(panel.getMonster().getCol(),panel.getMonster().getRow()), panel.getHero().getCurrentSkill().getPath())){ panel.getMonster().setHP(panel.getMonster().getHP()-panel.getHero().getCurrentSkill().getDamage()); } }*/ // cast normal skill /* else if(panel.getHero().getIsChosen() && panel.getHero().getStatus().equals(HeroStatus.attacking) && panel.getHero().getCurrentSkill().getStatus().equals(SkillStatus.before) && panel.getHero().getCurrentSkill().getPath().contains(selectCell) && (panel.getHero().getAP()-panel.getHero().getCurrentSkill().getAP())>=0 && (panel.getHero().getCurrentSkill() instanceof NormalSkill)){ HeroAnimation.attack(panel.getHero(),panel); Cell c = new Cell(panel.getMonster().getCol(),panel.getMonster().getRow()); if(selectCell.equals(c)){ panel.getMonster().setHP(panel.getMonster().getHP()-panel.getHero().getCurrentSkill().getDamage()); } }*/ // System.out.println(panel.getHero().getStatus()); panel.repaint(); }
/** Confirm that cloning works. */ public void testCloning() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); Rectangle2D shape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); Rectangle2D baseShape = new Rectangle2D.Double(11.0, 12.0, 13.0, 14.0); r1.setShape(shape); r1.setBaseShape(baseShape); r1.setBaseLegendShape(new Rectangle(4, 3, 2, 1)); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 3)); r1.setBaseLegendTextPaint(new Color(1, 2, 3)); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1.setSeriesVisible(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesVisible(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setSeriesVisibleInLegend(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesVisibleInLegend(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setSeriesPaint(0, Color.black); assertFalse(r1.equals(r2)); r2.setSeriesPaint(0, Color.black); assertTrue(r1.equals(r2)); r1.setSeriesFillPaint(0, Color.yellow); assertFalse(r1.equals(r2)); r2.setSeriesFillPaint(0, Color.yellow); assertTrue(r1.equals(r2)); r1.setSeriesOutlinePaint(0, Color.yellow); assertFalse(r1.equals(r2)); r2.setSeriesOutlinePaint(0, Color.yellow); assertTrue(r1.equals(r2)); r1.setSeriesStroke(0, new BasicStroke(2.2f)); assertFalse(r1.equals(r2)); r2.setSeriesStroke(0, new BasicStroke(2.2f)); assertTrue(r1.equals(r2)); r1.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); assertFalse(r1.equals(r2)); r2.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); assertTrue(r1.equals(r2)); shape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); baseShape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setBaseShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); r1.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelsVisible(0, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelsVisible(0, Boolean.TRUE); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelPaint(0, Color.red); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelPaint(0, Color.red); assertTrue(r1.equals(r2)); r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertTrue(r1.equals(r2)); r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); assertTrue(r1.equals(r2)); r1.setSeriesCreateEntities(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesCreateEntities(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setLegendShape(0, new Rectangle(9, 7, 3, 4)); assertFalse(r1.equals(r2)); r2.setLegendShape(0, new Rectangle(9, 7, 3, 4)); assertTrue(r1.equals(r2)); r1.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); assertFalse(r1.equals(r2)); r2.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); assertTrue(r1.equals(r2)); r1.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); assertFalse(r1.equals(r2)); r2.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); assertTrue(r1.equals(r2)); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); assertFalse(r1.equals(r2)); r2.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); assertTrue(r1.equals(r2)); r1.setLegendTextPaint(3, Color.red); assertFalse(r1.equals(r2)); r2.setLegendTextPaint(3, Color.red); assertTrue(r1.equals(r2)); r1.setBaseLegendTextPaint(Color.green); assertFalse(r1.equals(r2)); r2.setBaseLegendTextPaint(Color.green); assertTrue(r1.equals(r2)); }