Package ch.sahits.game.openpatrician.model.ship

Examples of ch.sahits.game.openpatrician.model.ship.IShip


      // Sub title
      y += positions.titleHeigth;
      int leftBorderX = getBounds().x+getInset().left;
      int x = leftBorderX + 20;
      ICity cityModel = city.getCity();
      IShip ship = city.getActiveShip();
      ITradingOffice office = city.getPlayer().findTradingOffice(cityModel);
      y += (int)Math.rint(positions.titleHeigth*2/3);
     
      synchronized (type) { // Avoid change of the type during rendering of one screen
        drawSubTitle(g2d, y, barrel, x, cityModel, ship, office);
View Full Code Here


    DisplayImageDIResolver resolver = DisplayImageDIResolver.getInstance();
    this.xmlLoader = resolver.getXMLImageLoader();
    this.loader = loader;
    imageUtils = resolver.getImageUtilities();
    city = new CityPlayerProxy(cl.getPlayer().getHometown(), cl.getPlayer());
    IShip ship = cl.getPlayer().getFleet().get(0);
    city.arrive(ship);
    logger.debug("MainView: "+rect);
    ISceneHandler sceneHandler = SceneHandlerFactory.getSceneLoader(EScene.PORT, getBounds(), xmlLoader, resolver);
    img = sceneHandler.init(resolver);
    sceneHandler = SceneHandlerFactory.getSceneLoader(EScene.MARKET, getBounds(), xmlLoader, resolver);
View Full Code Here

  }

  @Override
  public void run() {
    ICityPlayerProxy city = dialog.getCityPlayerProxy();
    IShip ship = city.getActiveShip();
    ITradingOffice office = city.getPlayer().findTradingOffice(city.getCity());
    int availableAmountStorage = office.getWare(ware).getAmount();
    if (availableAmountStorage>0 && office!=null){
      int amount2Move = dialog.getAmount(availableAmountStorage); // This is ware specific size
      int avgPrice = office.getWare(ware).getAVGPrice();
      int moved = office.move(ware, -amount2Move,avgPrice);
      ship.load(ware, moved, avgPrice);
    }
  }
View Full Code Here

  }

  @Override
  public void run() {
    ICityPlayerProxy city = dialog.getCityPlayerProxy();
    IShip ship = city.getActiveShip();
    int availableAmountShip = ship.getWare(ware).getAmount();
    ITradingOffice office = city.getPlayer().findTradingOffice(city.getCity());
    if (availableAmountShip>0 && office!=null){
      int amount2Move = dialog.getAmount(availableAmountShip); // This is ware specific size
      int avgPrice = ship.getWare(ware).getAVGPrice();
      int moved = ship.unload(ware, amount2Move);
      office.move(ware, moved,avgPrice);
    }

  }
View Full Code Here

   * @throws FontFormatException
   */
  private void createTradeNotice(ICityPlayerProxy proxy) throws FontFormatException, IOException {
    ICity city = proxy.getCity();
    ITradingOffice office = proxy.getPlayer().findTradingOffice(city);
    IShip ship = proxy.getActiveShip();
    boolean city2ShipFlag = proxy.getActiveShip()!=null; // if true this is active
    boolean hasTradingOffice = office!=null;
    boolean hasWeapons = (city2ShipFlag&&hasTradingOffice&&office.hasWeapons()&&ship.getUpgradeSpaceReduction()>0&&ship.hasWeapons());
    EStringSelectionState city2ship;
    if (city2ShipFlag){
      city2ship = EStringSelectionState.ACTIVE;
    } else if (proxy.getPlayersShips().isEmpty()){
      // no active ship => disable
View Full Code Here

           
            ICity homeCity = CityFactory.createCityByName(ECityName.values()[homeTownIndex]);
            IPlayer player = GameFactory.createPlayer(name.getValue(), lastName.getValue(), homeCity, male.isSelected() && !female.isSelected(),difficulity.getStartingCapital());
            RandomNameLoader shipLoader = new RandomNameLoader("shipnames.properties");
            IShip ship = ShipFactory.createCrayer(shipLoader.getRandomName(), EShipUpgrade.LEVEL1,3000); // TODO check the value
            player.addShip(ship);

            // Initialize the player
            new NewGameEvent(ENewGame.SINGELPLAYER).notify(player);
            // Initialize the game/server
View Full Code Here

      BufferedImage bale = loader.getImage("bale_icon");
      g2d.drawImage(barrel, x, y-(int)Math.rint(positions.titleHeigth), null); // Is y correct ???
     
      // loaded on ship and ship capacity
      x += 50;
      IShip ship = city.getActiveShip();
      StringBuilder sb = new StringBuilder();
      sb.append(ship.getLoad()).append(" / ").append(ship.getSize()).append(" ").append(ship.getName());
      gv = OpenPatricianPainter.createGlyphVector(g2d, sb.toString(), 18);
      g2d.drawGlyphVector(gv, x, y); // TODO this is a dynamic line
     
      BufferedImage waxSeal = loader.getImage("waxseal");
      // Table header
      y += positions.lineHeight; // more space to the title
      y += positions.lineHeight;
     
      // Table
      EWare[] wares = EWare.values();
      for (EWare ware : wares) {
        // Ware name
        y += positions.lineHeight;
       
        // Available amount in the city
        AmountablePrice<EWare> wareInCity = cityModel.getWare(ware);
        int availableAmount = wareInCity.getAmount();
        int value = availableAmount; // amount available
        if (value>0){
          gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
          g2d.drawGlyphVector(gv, positions.xCity, y);
          // draw barrel or burden
          if (ware.getSizeAsBarrels()==1){
            // barrel
            g2d.drawImage(barrel, (int)(positions.xCity+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
          } else {
            g2d.drawImage(bale, (int)(positions.xCity+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
          }
        }
        g2d.setColor(new Color(0xEA,0xC1,0x17)); // Gold
        // buy
        if (availableAmount>0){
          value = ware.computeBuyPrice(availableAmount, getAmount(availableAmount));
        } else {
          value = 0; // cannot buy anything if nothing is there
        }
        gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
        int xPadding = ImageUtil.computeCenterAlignX(positions.xBuy, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
        g2d.drawGlyphVector(gv, xPadding, y);
        // sell
        if (movableAmount==ETransferAmount.MAX){
          value = ware.getMaxValueSell();
        } else {
          value = ware.computeSellPrice(availableAmount, getAmount(availableAmount));
        }
        gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
        xPadding = ImageUtil.computeCenterAlignX(positions.xSell, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
        g2d.drawGlyphVector(gv, xPadding, y);
        g2d.setColor(Color.BLACK);
        // amount loaded
        value = city.getActiveShip().getWare(ware).getAmount(); // differ between ship and convoi
        if (value>0){
          gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
          g2d.drawGlyphVector(gv, positions.xShip, y); // this value is dynamic
          // draw barrel or burden
        }
        if (ship.getWare(ware).getAmount()>0){
          value = ship.getWare(ware).getAVGPrice();
          gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
          g2d.drawGlyphVector(gv, positions.xPrice+10, y);
        }
      } // end for wares
     
View Full Code Here

            int homeTownIndex = home.getSelectedIndex();
            IMap gameMap = GameFactory.createMap(); // TODO consider custom maps
            ICity homeCity = CityFactory.createCityByName(ECityName.values()[homeTownIndex]);
            IPlayer player = GameFactory.createPlayer(name.getValue(), lastName.getValue(), homeCity, male.isSelected() && !female.isSelected(),difficulity.getStartingCapital());
            RandomNameLoader shipLoader = new RandomNameLoader("shipnames.properties");
            IShip ship = ShipFactory.createCrayer(shipLoader.getRandomName(), EShipUpgrade.LEVEL1);
            player.addShipp(ship);

            EObjective obj = EObjective.values()[objective.getSelectedIndex()];
            Difficulty diff = difficulity;
            EGameSpeed gameSpeed = EGameSpeed.values()[speed.getSelectedIndex()];
View Full Code Here

   */
  public MainView(Rectangle rect, ImagesLoader loader, IClient cl) {
    super(rect);
    this.loader = loader;
    city = new CityPlayerProxy(cl.getPlayer().getHometown(), cl.getPlayer());
    IShip ship = cl.getPlayer().getFleet().get(0);
    city.arrive(ship);
System.out.println("MainView: "+rect);
    BufferedImage tmpImg = loader.getImage(imageNames[0]);
    img = ImageUtil.scale(tmpImg, getBounds().getSize());
    dialogScale = ImageUtil.computeScaleFactor(getBounds().getSize(), tmpImg.getWidth(), tmpImg.getHeight());
View Full Code Here

TOP

Related Classes of ch.sahits.game.openpatrician.model.ship.IShip

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.