Package com.mojang.ld22.item.resource

Examples of com.mojang.ld22.item.resource.PlantableResource


    if (len == 0) selected = 0;
    if (selected < 0) selected += len;
    if (selected >= len) selected -= len;

    if (input.attack.clicked && len > 0) {
      Recipe r = recipes.get(selected);
      r.checkCanCraft(player);
      if (r.canCraft) {
        r.deductCost(player);
        r.craft(player);
        Sound.craft.play();
      }
      for (int i = 0; i < recipes.size(); i++) {
        recipes.get(i).checkCanCraft(player);
      }
View Full Code Here


    Font.renderFrame(screen, "Cost", 12, 4, 19, 11);
    Font.renderFrame(screen, "Crafting", 0, 1, 11, 11);
    renderItemList(screen, 0, 1, 11, 11, recipes, selected);

    if (recipes.size() > 0) {
      Recipe recipe = recipes.get(selected);
      int hasResultItems = player.inventory.count(recipe.resultTemplate);
      int xo = 13 * 8;
      screen.render(xo, 2 * 8, recipe.resultTemplate.getSprite(), recipe.resultTemplate.getColor(), 0);
      Font.draw("" + hasResultItems, screen, xo + 8, 2 * 8, Color.get(-1, 555, 555, 555));

View Full Code Here

    for (int i = 0; i < w * h; i++) {
      entitiesInTiles[i] = new ArrayList<Entity>();
    }
   
    if (level==1) {
      AirWizard aw = new AirWizard();
      aw.x = w*8;
      aw.y = h*8;
      add(aw);
    }
  }
 
View Full Code Here

    for (int y = yo - r; y <= h + yo + r; y++) {
      for (int x = xo - r; x <= w + xo + r; x++) {
        if (x < 0 || y < 0 || x >= this.w || y >= this.h) continue;
        List<Entity> entities = entitiesInTiles[x + y * this.w];
        for (int i = 0; i < entities.size(); i++) {
          Entity e = entities.get(i);
          // e.render(screen);
          int lr = e.getLightRadius();
          if (lr > 0) screen.renderLight(e.x - 1, e.y - 4, lr * 8);
        }
        int lr = getTile(x, y).getLightRadius(this, x, y);
        if (lr > 0) screen.renderLight(x * 16 + 8, y * 16 + 8, lr * 8);
      }
 
View Full Code Here

      int xt = random.nextInt(w);
      int yt = random.nextInt(w);
      getTile(xt, yt).tick(this, xt, yt);
    }
    for (int i = 0; i < entities.size(); i++) {
      Entity e = entities.get(i);
      int xto = e.x >> 4;
      int yto = e.y >> 4;

      e.tick();

      if (e.removed) {
        entities.remove(i--);
        removeEntity(xto, yto, e);
      } else {
View Full Code Here

    for (int y = yt0; y <= yt1; y++) {
      for (int x = xt0; x <= xt1; x++) {
        if (x < 0 || y < 0 || x >= w || y >= h) continue;
        List<Entity> entities = entitiesInTiles[x + y * this.w];
        for (int i = 0; i < entities.size(); i++) {
          Entity e = entities.get(i);
          if (e.intersects(x0, y0, x1, y1)) result.add(e);
        }
      }
    }
    return result;
  }
View Full Code Here

    return "Pow glove";
  }

  public boolean interact(Player player, Entity entity, int attackDir) {
    if (entity instanceof Furniture) {
      Furniture f = (Furniture) entity;
      f.take(player);
      return true;
    }
    return false;
  }
View Full Code Here

      int tmp = selected;
      selected = oSelected;
      oSelected = tmp;
    }

    Inventory i = window == 1 ? player.inventory : container;
    Inventory i2 = window == 0 ? player.inventory : container;

    int len = i.items.size();
    if (selected < 0) selected = 0;
    if (selected >= len) selected = len - 1;

    if (input.up.clicked) selected--;
    if (input.down.clicked) selected++;

    if (len == 0) selected = 0;
    if (selected < 0) selected += len;
    if (selected >= len) selected -= len;

    if (input.attack.clicked && len > 0) {
      i2.add(oSelected, i.items.remove(selected));
      if (selected >= i.items.size()) selected = i.items.size() - 1;
    }
  }
View Full Code Here

  private void harvest(Level level, int x, int y) {
    int age = level.getData(x, y);

    int count = random.nextInt(2);
    for (int i = 0; i < count; i++) {
      level.add(new ItemEntity(new ResourceItem(Resource.seeds), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
    }

    count = 0;
    if (age == 50) {
      count = random.nextInt(3) + 2;
    } else if (age >= 40) {
      count = random.nextInt(2) + 1;
    }
    for (int i = 0; i < count; i++) {
      level.add(new ItemEntity(new ResourceItem(Resource.wheat), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
    }

    level.setTile(x, y, Tile.dirt, 0);
  }
View Full Code Here

      if (tool.type == ToolType.shovel) {
        if (player.payStamina(4 - tool.level)) {
          level.setTile(xt, yt, Tile.dirt, 0);
          Sound.monsterHurt.play();
          if (random.nextInt(5) == 0) {
            level.add(new ItemEntity(new ResourceItem(Resource.seeds), xt * 16 + random.nextInt(10) + 3, yt * 16 + random.nextInt(10) + 3));
            return true;
          }
        }
      }
      if (tool.type == ToolType.hoe) {
        if (player.payStamina(4 - tool.level)) {
          Sound.monsterHurt.play();
          if (random.nextInt(5) == 0) {
            level.add(new ItemEntity(new ResourceItem(Resource.seeds), xt * 16 + random.nextInt(10) + 3, yt * 16 + random.nextInt(10) + 3));
            return true;
          }
          level.setTile(xt, yt, Tile.farmland, 0);
          return true;
        }
View Full Code Here

TOP

Related Classes of com.mojang.ld22.item.resource.PlantableResource

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.