Package de.axxeed.animosy.model

Examples of de.axxeed.animosy.model.Game


  /* (non-Javadoc)
   * @see de.axxeed.animosy.ai.MrXInterface#run()
   */
  public void run() {
    int moveNo = -1;
    Game game = Manager.getGame();
    while (true) {
      if(game.getState()==Game.MOVE_MRX) {
        if(game.getCurrentMove() != moveNo) {
          this.setPriority(6);
          log.info("Moving MrX in separate thread (move #"+game.getCurrentMove()+")...");
          moveNo = game.getCurrentMove();
         
          Node mrXMove = moveMrX();
          int type = game.getBoard().getMrX().changePosition(mrXMove);
          Manager.getGame().getTracker().nextMove(type);
          log.debug("MrX move done...");
          this.setPriority(Thread.NORM_PRIORITY);
          Manager.getGame().nextDetective();

        }
      }
      if(game.getState()==Game.WIN_MRX || game.getState()==Game.WIN_DET || game.getState()==Game.NO_GAME) {
        break;
      }
      else {
        try {
          Thread.sleep(1000);
View Full Code Here


  private List<HistoryTableRow> rows = new ArrayList<HistoryTableRow>()
 
  public void fill() {
    if (rows.size()>0) rows.clear();
   
    Game g = Manager.getGame();
    Detective[] det = g.getBoard().getDetectives();
    Fugitive mrX = g.getBoard().getMrX();
    for(int i=0;i<=g.getCurrentMove();i++) {
      HistoryTableRow htr = new HistoryTableRow(i);
      htr.setNumberOfDetectives(det.length);
      if(g.isCheckPoint(i) || Manager.getOptions().isCheat()) {
        if(i<mrX.getPrevPos().length) {
          htr.setMrXMove(mrX.getPrevPos()[i]);
        }
      }
      else {
View Full Code Here

    {
    // log.debug(".paint()");
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
   
    Game game = Manager.getGame();
    GameBoard b = game.getBoard();
    Options opt = Manager.getOptions();
    int maxMoves = opt.getNumberOfMoves();
    int mrXPos = detYOffset+pixPerDetective*opt.getNumberOfDetectives()+10;
      int y = 0;

    if(b.getDetectives()!=null && game.getState() != Game.NO_GAME) {
      if(startGameButton!=null && startGameButton.isVisible()) startGameButton.setVisible(false);
      g2d.drawString("Current turn: "+game.getCurrentMove()+" of "+maxMoves, 10, 20);
      g2d.drawString(""+game.getStateText(), 10, 40);

      g2d.drawString("Detective positions:", 10, detYOffset-20);
      g2d.drawLine(10, detYOffset-18, 120, detYOffset-18);
      int activeDet = game.getActiveDetectiveIndex();
      for(int i=0;i<opt.getNumberOfDetectives();i++) {
        if(i==activeDet) {
                g2d.setColor(Color.CYAN);
                g2d.fillRect(18, detYOffset-12+pixPerDetective*i, 100, 15);
        }
        Detective d = b.getDetectives()[i];
              g2d.setColor(Color.BLACK);
        if(d.isStranded()) {
                g2d.setColor(Color.RED);
        }
        g2d.drawString("Detective "+(i+1)+": "+d.getPosition().getPosition(), 20, detYOffset+pixPerDetective*i);
              g2d.setColor(Detective.getColor(i));
              g2d.fillOval(5, detYOffset-9+pixPerDetective*i, 10, 10);
              g2d.setColor(Move.getColor(TAXI));
        g2d.drawString(""+d.getTaxiTickets()+"x T", 20, detYOffset+pixPerDetective*i+20);
              g2d.setColor(Move.getColor(BUS));
        g2d.drawString(""+d.getBusTickets()+"x B", 60, detYOffset+pixPerDetective*i+20);
              g2d.setColor(Move.getColor(UG));
        g2d.drawString(""+d.getUndergroundTickets()+"x U", 100, detYOffset+pixPerDetective*i+20);
             
      }
     
      if(Manager.getOptions().isCheat() || game.isCheckPoint()) {
            g2d.setColor(Color.BLACK);
        g2d.drawString("MrX: "+b.getMrX().getPosition().getPosition(), 20, mrXPos);
            g2d.fillOval(5, mrXPos-9, 10, 10);
      }
         
          // here goes the movement history of MrX
          y = mrXPos + 20;
          int maxY = y;
          int x = 10;
          Move[] mrXmoves = b.getMrX().getPrevPos();
          for(int i=0;i<=maxMoves;i++) {
              g2d.setColor(Color.BLACK);
              if(i>=game.getCurrentMove()) {
                  g2d.setColor(Color.GRAY);
                g2d.drawRect(x, y, 30, 15);
              }
              if(game.isCheckPoint(i+1)) {
                  g2d.setColor(new Color(120,200,255));
                g2d.fillRect(x, y, 30, 15);
              }
              if(i==game.getCurrentMove()-1 && game.getState() == Game.MOVE_MRX) {
                  g2d.setColor(Color.RED);
                g2d.drawRect(x, y, 30, 15);
              }
            if((i+1)<mrXmoves.length) {
                  g2d.setColor(Move.getColor(mrXmoves[i+1].getType()));
                if(opt.isCheat() || game.isCheckPoint()) {
                      g2d.drawString(""+mrXmoves[i+1].getNode(), x+3, y+12);
                }
                else {
                      g2d.drawString(""+mrXmoves[i+1].toStringTicket(), x+3, y+12);
                }
            }
            else if((i+1)==mrXmoves.length && game.getState() == Game.MOVE_MRX) {
                g2d.drawString("???", x+3, y+12);
            }
            else {
                g2d.drawString(""+(i+1), x+3, y+12);
            }
            y += 18;
            if(i%((maxMoves/3)+1)==((maxMoves/3))) {
              x += 35;
              y = mrXPos + 20;
            }
            if(y>maxY) maxY = y;
          }
          y = maxY;
    }
    else {
      if(startGameButton!=null && !startGameButton.isVisible()) startGameButton.setVisible(true);
      startGameButton.repaint();
      g2d.drawString("no game yet", 10, 75);

    }

    // Minimap
    if(y==0) {
      y = this.getHeight()-MINIMAP_Y-55;
    }
    else {
      y+=30;
    }
    MapPanel mp = (MapPanel)PanelRepository.get(PanelRepository.MAP_PANEL);
    g2d.drawImage(mp.getMiniImage(MINIMAP_X, MINIMAP_Y), 3, y, null);
   
    int x  = 3+Math.min(MINIMAP_X-1, (int) (mp.getOffset().x*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)));
    int y2 = y+Math.min(MINIMAP_Y-1, (int) (mp.getOffset().y*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)));
    int w = Math.min(MINIMAP_X, (int)(mp.getWidth()*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)*(1.0/mp.getZoom())));
    int h = Math.min(MINIMAP_Y, (int)(mp.getHeight()*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)*(1.0/mp.getZoom())));
    g2d.drawRect(x, y2, w, h);

   
    g2d.drawString("Time: "+game.getGameTime(), 10, this.getHeight()-40);
    g2d.drawString("Zoom: "+mp.getZoomInfo(), 10, this.getHeight()-25);
    g2d.drawString("mem:  "+Runtime.getRuntime().totalMemory()/1024+"k", 10, this.getHeight()-10);
    g2d.dispose();
   
    }
View Full Code Here

      BufferedImage copy = gc.createCompatibleImage(mapImageStatic.getWidth(), mapImageStatic.getHeight(), transparency);
      Graphics2D g2d = copy.createGraphics();
      g2d.drawImage(mapImageStatic,0,0,null);

        g2d.setStroke(new BasicStroke(3f));
        Game game = Manager.getGame();
       
        Fugitive fugitive = game.getBoard().getMrX();
//        // if(fugitive!=null && showMrX) {
        if(fugitive!=null && ( Manager.getOptions().isCheat() || game.isCheckPoint() ) && game.getState() != Game.NO_GAME) {
          if(fugitive.getPrevPos().length>game.getCurrentMove()) {
              int pp = fugitive.getPosition().getPosition();
              g2d.setColor(new Color(255,255,255));
              g2d.fillRect(pos[pp].x, pos[pp].y-12, 30, 13);
              g2d.setColor(Color.BLACK);
              g2d.drawOval(pos[pp].x, pos[pp].y, 30, 30);
              g2d.drawString("X-"+pp, pos[pp].x, pos[pp].y);
          }
          else {
            log.debug("MrX hasn't moved yet!");
          }
        }
        else {
        // log.debug("don't draw MrX...");
        }
        Detective[] detectives = game.getBoard().getDetectives();
        if(detectives != null && game.getState() != Game.NO_GAME) {
          int cd = game.getActiveDetectiveIndex();
            for(int i=0;i<detectives.length;i++) {
                int pp = detectives[i].getPosition().getPosition();
                if(i==cd) {
                  //g2d.setColor(new Color(255,255,255));
                  //g2d.fillRect(pos[pp].x, pos[pp].y-12, 30, 13);
                  g2d.setColor(Detective.getColor(i));
                  //g2d.drawString(""+(i+1)+":"+pp, pos[pp].x, pos[pp].y);
                  g2d.drawOval(pos[pp].x-pulseState, pos[pp].y-pulseState, 30+pulseState*2, 30+pulseState*2);
                }
                else if(game.getState()==Game.WIN_DET && pp==game.getBoard().getMrX().getPosition().getPosition()) {
                  if(pulseOut) {
//                    g2d.setColor(Detective.getColor(i));
//                    g2d.drawOval(pos[pp].x, pos[pp].y, 30, 30);
                    pulseOut = false;
                  }
                  else {
                      g2d.setStroke(new BasicStroke(10f));
                    g2d.setColor(Detective.getColor(i));
                    g2d.drawOval(pos[pp].x, pos[pp].y, 30, 30);
                    pulseOut = true;
                  g2d.setStroke(new BasicStroke(3f));
                  }
                }
                else {
                  //g2d.setColor(new Color(255,255,255));
                  //g2d.fillRect(pos[pp].x, pos[pp].y-12, 30, 13);
                  g2d.setColor(Detective.getColor(i));
                  //g2d.drawString(""+(i+1)+":"+pp, pos[pp].x, pos[pp].y);
                  g2d.drawOval(pos[pp].x, pos[pp].y, 30, 30);
                }
            }
        }
        else {
        log.debug("no detectives to draw...");
        }
       
        // MrX Tracker
      if(((JCheckBoxMenuItem) PanelRepository.get(PanelRepository.TRACKER_ITEM)).isSelected()) {
        if(game.getTracker()!=null) {
              g2d.setStroke(new BasicStroke(2f));
          for(int n : game.getTracker().getPotentialNodes()) {
                g2d.setColor(Color.WHITE);
                g2d.drawOval(pos[n].x, pos[n].y, 30, 30);
          }
        }
        else {
View Full Code Here

TOP

Related Classes of de.axxeed.animosy.model.Game

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.