Examples of GameBoard


Examples of de.axxeed.animosy.model.GameBoard

    // 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);
View Full Code Here

Examples of de.axxeed.animosy.model.GameBoard

   
  }

  public void mouseReleased(MouseEvent me) {
       if ( me.isPopupTrigger() ) {
        GameBoard b = Manager.getGame().getBoard();
        if(b.getDetectives()!=null) {
          int activeDet = Manager.getGame().getActiveDetectiveIndex();
          // don't show the menu, if the user clicked anywhere else except the current detective
          if(me.getY()<detYOffset-12+pixPerDetective*activeDet || me.getY()>detYOffset+2+pixPerDetective*activeDet) {
            return;
          }
          detectiveMenu.removeAll();
          JMenuItem menu1 = new JMenuItem( "Find me");
          menu1.setEnabled(false);
          detectiveMenu.add( menu1 );
          detectiveMenu.addSeparator();
         
          TreeSet<Move> possibleMoves = b.getDetectives()[activeDet].getPossibleMoves();
          if(possibleMoves==null) {
            AbstractAction action = new AbstractAction("Skip turn")
              {
                private static final long  serialVersionUID  = 0L;
                public void actionPerformed( ActionEvent e ) {
                  Manager.getGame().nextDetective();
                  ((MapPanel)PanelRepository.get(PanelRepository.MAP_PANEL)).updatePositions();
                  PanelRepository.get(PanelRepository.STATUS_PANEL).repaint();
                }
              };
            detectiveMenu.add( action );
          }
          else {
            log.debug("Possible moves: "+possibleMoves.size()+" - "+possibleMoves);
            Iterator<Move> i = possibleMoves.iterator();
            while(i.hasNext()) {
              Move m = (Move) i.next();
              StringBuilder linkText = new StringBuilder();
              linkText.append(m.getNode()).append(" (");
              switch(m.getType()) {
                case BoardModel.TAXI: linkText.append("TAXI").append(")"); break;
                case BoardModel.BUS: linkText.append("BUS").append(")"); break;
                case BoardModel.UG: linkText.append("UG").append(")"); break;
                case BoardModel.BLACK: linkText.append("XXX").append(")"); break;
                case BoardModel.INF: linkText.append("INF").append(")"); break;
                default: linkText.append("???").append(")"); break;
              }
             
              // detectiveMenu.add( new JMenuItem(linkText.toString()) );
              AbstractAction action = new AbstractAction(linkText.toString())
                {
                  private static final long  serialVersionUID  = -4379938472159497577L;
                  public void actionPerformed( ActionEvent e ) {
                    log.debug("Selected move: "+((Move)this.getValue(e.getActionCommand())));
                    Manager.getGame().moveDetective((Move)this.getValue(e.getActionCommand()));
//                    Move selectedMove = (Move)this.getValue(e.getActionCommand());
//                    Detective d = (Detective)this.getValue("Detective");
//                    d.changePosition(BoardModel.getInstance().getNode(selectedMove.getNode()), selectedMove.getType());
//                    Manager.getGame().nextDetective();
//                    ((MapPanel)PanelRepository.get(PanelRepository.MAP_PANEL)).updatePositions();
                    PanelRepository.get(PanelRepository.STATUS_PANEL).repaint();
                  }
                };
              action.putValue(linkText.toString(), m);
              action.putValue("Detective", b.getDetectives()[activeDet]);
              detectiveMenu.add( action );
            }
            detectiveMenu.addSeparator();
            JMenuItem options = new JMenuItem( "Help");
            options.setEnabled(false);
View Full Code Here

Examples of de.creepsmash.client.grid.GameBoard

  public GameContext(BoardLocation location, Network network,
      SoundManagement mSound, IConstants.Map map) {
    this.location = location;
    this.network = network;
    this.mapfile = map;
    this.setGameBoard(new GameBoard(this));
    this.towers = Collections.synchronizedList(new ArrayList<Tower>());
    this.creeps = Collections.synchronizedList(new ArrayList<Creep>());
    this.transfer = Collections.synchronizedList(new ArrayList<Creep>());
    this.contextListeners = new ArrayList<ContextListener>();
    this.managementSound = mSound;
View Full Code Here

Examples of de.creepsmash.client.grid.GameBoard

  public GameContext(BoardLocation location, Network network,
      IConstants.Map map) {
    this.location = location;
    this.network = network;
    this.mapfile = map;
    this.setGameBoard(new GameBoard(this));
    this.towers = Collections.synchronizedList(new ArrayList<Tower>());
    this.creeps = Collections.synchronizedList(new ArrayList<Creep>());
    this.transfer = Collections.synchronizedList(new ArrayList<Creep>());
    this.contextListeners = new ArrayList<ContextListener>();
    this.managementSound = null;
View Full Code Here

Examples of main.arrays_06.aufgabe2.GameBoard

public class Aufgabe2Test {


  @Test
  public void testEasyGame() throws Exception {
    GameBoard b = new GameBoard(new int[][] {
        new int[] { 1, 0, 2, 3 },
        new int[] { 4, 5, 6, 7 },
        new int[] { 8, 9, 10, 11 },
        new int[] { 12, 13, 14, 15 }
    });
    b.startGame();
    Assert.assertFalse(b.isSolved());
    b.play(5);
    Assert.assertFalse(b.isSolved());
    b.play(5);
    b.play(1);
    Assert.assertFalse(b.isSolved());
  }
View Full Code Here

Examples of main.arrays_06.aufgabe2.GameBoard

    Assert.assertFalse(b.isSolved());
  }
 
  @Test
  public void testEasyGameWithModifiedVictoryCondition() throws Exception {
    GameBoard b = new GameBoard(new int[][] {
        new int[] { 1, 2, 3, 4 },
        new int[] { 5, 6, 7, 8 },
        new int[] { 9, 10, 11, 12 },
        new int[] { 13, 14, 0, 15 }
    });
    b.startGame();
    Assert.assertFalse(b.isSolved());
    b.play(15);
    Assert.assertTrue(b.isSolved());
  }
View Full Code Here

Examples of view.GameBoard

  private ArrayList<Snake> players;
 
  public Round(ArrayList<Snake> players , Window window) {
    this.players = players;
    this.window = window;
    gameBoard = new GameBoard();
    window.addToMainPanel(gameBoard);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.