Package Project1.Game

Examples of Project1.Game.Game


    else {
      R6.setSelected(true);
    }
  }
  private void updateArgs() {
    GameSize newSize;
    if (R8.isSelected()) {
      newSize = GameSize.C8;
    }
    else if (R7.isSelected()) {
      newSize = GameSize.C7;
View Full Code Here


    // Show the face
    this.setIcon(Child.getImage());
    current = Child.getImage();
   
    // Determine the type of match
    Matching MatchType;
    if (Game.get().FlippedCard == null) {
      MatchType = Matching.Reveal;
    }
    else if (Game.get().FlippedCard != this) {
      if (Game.get().FlippedCard.getCard() == this.getCard()) {
View Full Code Here

        }
      }
    }
    if (cTotal - cHerobrine == 0 ) {
      // Award the winner the game and exit
      Player victor =
        Player1.getScore() > Player2.getScore()
        ? Player1
        : Player2;
     
      victor.giveWin();
      GamePanel.get().updateLabels();
     
      // Play victory sound (eat for a second then burp) :)
      try {
        Card.Clips.get("Eat").loop();
        TimeUnit.SECONDS.sleep(1);
        Card.Clips.get("Eat").stop();
      } catch (InterruptedException ie) {
        Card.Clips.get("Eat").stop();
      }
      Card.Clips.get("Burp").play();
     
      // Show Congratulatory Message
      JOptionPane.showMessageDialog(
        MainFrame.get(),
        "Congratulations " + victor.getName() + "!",
        "You Won",
        JOptionPane.INFORMATION_MESSAGE
      );
     
      // Set ActiveGame to null
View Full Code Here

   * @param destination  The base to where the agents are going
   * @param player  The player owning the agents
   */
  public void addGroupAgent(int nbAgents, Base source, Base destination, Player player) {
   
    Game game = Game.getInstance();
 
    try {
      GroupAgent groupAgent = new GroupAgent(nbAgents, source, destination, player);
      AppliWindow.getInstance().getLabelAgent().add(groupAgent);
      game.getAgentManager().addAgent(groupAgent);
    } catch (IOException e) {
      System.out.println("failed "+e);
      e.printStackTrace();
    }
   
View Full Code Here

  /**
   * Builds the elements of the window corresponding to the bases
   */
  private void buildBases() {

    Game game = Game.getInstance();

    for(final Base base: game.getBaseManager().getBases()) {
      base.setBorder(BorderFactory.createLineBorder(Color.black));
      base.setContentAreaFilled(false);
      base.setBounds((int)base.getPosition().x, (int)base.getPosition().y, getTilesSize(), getTilesSize());
      base.setOpaque(true);
      try
View Full Code Here

   * @throws JDOMException
   * @throws MapFileException
   * @throws RealPlayerException
   */
  private void buildGame(String xmlFileName, String mapFileName) throws MapFileException, JDOMException, IOException, RealPlayerException {
    Game game = Game.getInstance();
    buildLabelAgents(0, 0, getWidth(), getHeight());
    game.initGame(xmlFileName, mapFileName);
    buildBases();
    // Add a line
    buildLine(0, 0, getWidth(), getHeight());
    buildLineCursor(0, 0, getWidth(), getHeight());
    buildInfoPlayers();
   
//    buildTowers();
//    //...
   
    game.start();
   
   

  }
View Full Code Here

  public int getAdversaireNumber() {
    return adversaireNumber;
  }

  public Options(int adv) {
    Game game = Game.getInstance();
    game.clearGame();
   
    // How many enemies ?
    this.adversaireNumber = adv;
   
    Player michel = new RealPlayer("Michel", Color.RED);
    Player jean_luc = new IAPlayer("Jean-Luc", Color.BLUE);
    Player patrick = new IAPlayer("Patrick", Color.GREEN);
    Player germaine = new IAPlayer("Germaine", Color.ORANGE);
   
    switch(this.getAdversaireNumber()) {
   
    case 0 :
      game.getPlayerManager().addPlayer(jean_luc);
      game.getPlayerManager().addPlayer(patrick);
      game.getPlayerManager().addPlayer(germaine);
     
      attributeBases();
     
      break;
   
    case 1 :
      game.getPlayerManager().addPlayer(michel);
      game.getPlayerManager().addPlayer(jean_luc);
     
      attributeBases();
     
      break;
   
    case 2 :
      game.getPlayerManager().addPlayer(michel);
      game.getPlayerManager().addPlayer(jean_luc);
      game.getPlayerManager().addPlayer(patrick);
     
      attributeBases();
     
      break;
   
    case 3 :
      game.getPlayerManager().addPlayer(michel);
      game.getPlayerManager().addPlayer(jean_luc);
      game.getPlayerManager().addPlayer(patrick);
      game.getPlayerManager().addPlayer(germaine);
     
      attributeBases();
     
      break;
   
    default :
      game.getPlayerManager().addPlayer(michel);
      game.getPlayerManager().addPlayer(jean_luc);
      game.getPlayerManager().addPlayer(patrick);
      game.getPlayerManager().addPlayer(germaine);
     
      attributeBases();
     
      break;
    }
View Full Code Here

  }

  @Override
  public void mouseClicked(MouseEvent event) {
   
    Game game = Game.getInstance();
   
    //Try to deselect the player
    RealPlayer realPlayer = null;
    try {
      realPlayer = (RealPlayer) Game.getInstance().getPlayerManager().getRealPlayer();
    } catch (RealPlayerException e) {

      e.printStackTrace();
      return;
    }
   
    int x = event.getX();
    int y = event.getY();
   
    // This click is it a click on an existing tower ?
    for(final Tower tower: Game.getInstance().getTowerManager().getTowers()) {
      float tx = tower.getPosition().x;
      float ty = tower.getPosition().y;
      if ( tower.getOwner().equals(realPlayer) && (x>= tx && x < tx + 40) && (y>= ty && y < ty + 40) ) {
       
        final JPopupMenu menu = new JPopupMenu();
       
        // item to upgrade the tower
        String price = (tower.getUpgradePrice() < Integer.MAX_VALUE) ? "-$"+tower.getUpgradePrice() : "impossible!";
          JMenuItem item = new JMenuItem("Upgrade tower ("+price+")");
          item.addActionListener(new ActionListener() {
         
          @Override
          public void actionPerformed(ActionEvent arg0) {
            // need to implement UpgradeTower
            UpgradeTower command = new UpgradeTower(tower);
            Engine.getInstance().getCommands().add(command);
          }
        });
          menu.add(item);
         
          // item to sell the tower
          JMenuItem item2 = new JMenuItem("Sell tower (+$"+tower.getSellPrice()+")");
          item2.addActionListener(new ActionListener() {
         
          @Override
          public void actionPerformed(ActionEvent arg0) {
            SellTower command = new SellTower(tower);
            Engine.getInstance().getCommands().add(command);
          }
        });
          menu.add(item2);
         
          menu.show(event.getComponent(), x, y);
         

         
        return;
      }
    }

   
    if(realPlayer.getSelectedBases() != null) {
      realPlayer.getSelectedBases().setBackground(realPlayer.getColor().brighter());
    }
    realPlayer.setSelectedBases(null);
   
    // Click on the map make disappear the line
    AppliWindow.getInstance().getLine().setDisplayed(false);
    AppliWindow.getInstance().getLine().displayLine(0, 0, 0, 0);
   
   
    // This clic is it in order to build a tower ?
    if (realPlayer.isBuildingTower()) {
      int numArea = game.getMapManager().getNumAreaAtPosition(event.getX(), event.getY());
     
      if (numArea == -1) {
        //System.out.println("C'est une zone de plaine !");
      }
      else if(numArea >= 0 && numArea < game.getBaseManager().getBases().size()) {
        Base baseArea = game.getBaseManager().getBases().get(numArea);
        if (realPlayer.equals(baseArea.getPlayer())) {
          realPlayer.buyTower(realPlayer, "GunTower", x, y);
        }
        else {
          //System.out.println("C'est pas ta zone !");
View Full Code Here

  @Override
  public void mouseMoved(MouseEvent event) {
   
    try {
      Game game = Game.getInstance();
      RealPlayer realPlayer = (RealPlayer)game.getPlayerManager().getRealPlayer();

      if (realPlayer.isBuildingTower()) {
        boolean acceptBuildTower = false;
       
        int numArea = game.getMapManager().getNumAreaAtPosition(event.getX(), event.getY() + 80);
       
        if(numArea >= 0 && numArea < game.getBaseManager().getBases().size()) {
          Base baseArea = game.getBaseManager().getBases().get(numArea);
          if (realPlayer.equals(baseArea.getPlayer())) {
            acceptBuildTower = true;
          }
        }
       
View Full Code Here

  /**
   * Pour la répartition des bases pour les joueurs, on crée une liste temporaire qui attribue
   * des bases neutres ou des bases joueurs initiales (IA ou Real)
   */
  private void attributeBases() {
    Game game = Game.getInstance();
    Random rand = new Random();
    rand.setSeed(System.currentTimeMillis());
   
   
    ArrayList<Player> listTemp = new ArrayList<Player>();
    do {
      listTemp.clear();
      for(int a = 0; a <= 9; ++a) {
        try {
          listTemp.add(a, game.getPlayerManager().getPlayers().get(rand.nextInt(3 + this.getAdversaireNumber())));
        }
        catch(IndexOutOfBoundsException e) {
          listTemp.add(a, null);
        }
      }
    } while(!(listTemp.containsAll(game.getPlayerManager().getPlayers())));
   
    Base base0 = new Base(0, 2, listTemp.get(0), new Vector2f(50, 100), 10);
    Base base1 = new Base(1, 3, listTemp.get(1), new Vector2f(500, 450), 5);
    Base base2 = new Base(2, 2, listTemp.get(2), new Vector2f(30, 380), 10);
    Base base3 = new Base(3, 3, listTemp.get(3), new Vector2f(80, 280), 5);
    Base base4 = new Base(4, 2, listTemp.get(4), new Vector2f(430, 180), 10);
    Base base5 = new Base(5, 3, listTemp.get(5), new Vector2f(750, 185), 5);
    Base base6 = new Base(6, 2, listTemp.get(6), new Vector2f(600, 285), 10);
    Base base7 = new Base(7, 3, listTemp.get(7), new Vector2f(350, 385), 5);
    Base base8 = new Base(8, 2, listTemp.get(8), new Vector2f(550, 385), 10);
   
    game.getBaseManager().addBase(base0);
    game.getBaseManager().addBase(base1);
    game.getBaseManager().addBase(base2);
    game.getBaseManager().addBase(base3);
    game.getBaseManager().addBase(base4);
    game.getBaseManager().addBase(base5);
    game.getBaseManager().addBase(base6);
    game.getBaseManager().addBase(base7);
    game.getBaseManager().addBase(base8);
   
    try {
      game.getPlayerManager().getRealPlayer();
    } catch(RealPlayerException e) {
      game.getPlayerManager().addPlayer(new RealPlayer("Michel", Color.MAGENTA));
    }
   
    listTemp.clear();
  }
View Full Code Here

TOP

Related Classes of Project1.Game.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.