Package com.mojang.ld22.screen

Examples of com.mojang.ld22.screen.CraftingMenu


  public boolean interact(Level level, int x, int y, Player player, Item item, int attackDir) {
    if (item instanceof ToolItem) {
      ToolItem tool = (ToolItem) item;
      if (tool.type == ToolType.shovel) {
        if (player.payStamina(4 - tool.level)) {
          level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
          level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
          level.setTile(x, y, Tile.grass, 0);
          return true;
        }
      }
    }
View Full Code Here


  }

  public void hurt(Level level, int x, int y, Mob source, int dmg, int attackDir) {
    int count = random.nextInt(2) + 1;
    for (int i = 0; i < count; i++) {
      level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
    }
    level.setTile(x, y, Tile.grass, 0);
  }
View Full Code Here

  private void hurt(Level level, int x, int y, int dmg) {
    {
      int count = random.nextInt(10) == 0 ? 1 : 0;
      for (int i = 0; i < count; i++) {
        level.add(new ItemEntity(new ResourceItem(Resource.apple), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
      }
    }
    int damage = level.getData(x, y) + dmg;
    level.add(new SmashParticle(x * 16 + 8, y * 16 + 8));
    level.add(new TextParticle("" + dmg, x * 16 + 8, y * 16 + 8, Color.get(-1, 500, 500, 500)));
    if (damage >= 20) {
      int count = random.nextInt(2) + 1;
      for (int i = 0; i < count; i++) {
        level.add(new ItemEntity(new ResourceItem(Resource.wood), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
      }
      count = random.nextInt(random.nextInt(4) + 1);
      for (int i = 0; i < count; i++) {
        level.add(new ItemEntity(new ResourceItem(Resource.acorn), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
      }
      level.setTile(x, y, Tile.grass, 0);
    } else {
      level.setData(x, y, damage);
    }
View Full Code Here

  protected void die() {
    super.die();

    int count = random.nextInt(2) + 1;
    for (int i = 0; i < count; i++) {
      level.add(new ItemEntity(new ResourceItem(Resource.slime), x + random.nextInt(11) - 5, y + random.nextInt(11) - 5));
    }

    if (level.player != null) {
      level.player.score += 25*lvl;
    }
 
View Full Code Here

    add(items.size(), item);
  }

  public void add(int slot, Item item) {
    if (item instanceof ResourceItem) {
      ResourceItem toTake = (ResourceItem) item;
      ResourceItem has = findResource(toTake.resource);
      if (has == null) {
        items.add(slot, toTake);
      } else {
        has.count += toTake.count;
      }
View Full Code Here

  }

  private ResourceItem findResource(Resource resource) {
    for (int i = 0; i < items.size(); i++) {
      if (items.get(i) instanceof ResourceItem) {
        ResourceItem has = (ResourceItem) items.get(i);
        if (has.resource == resource) return has;
      }
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  public boolean hasResources(Resource r, int count) {
    ResourceItem ri = findResource(r);
    if (ri == null) return false;
    return ri.count >= count;
  }
View Full Code Here

    if (ri == null) return false;
    return ri.count >= count;
  }

  public boolean removeResource(Resource r, int count) {
    ResourceItem ri = findResource(r);
    if (ri == null) return false;
    if (ri.count < count) return false;
    ri.count -= count;
    if (ri.count <= 0) items.remove(ri);
    return true;
View Full Code Here

    return true;
  }

  public int count(Item item) {
    if (item instanceof ResourceItem) {
      ResourceItem ri = findResource(((ResourceItem)item).resource);
      if (ri!=null) return ri.count;
    } else {
      int count = 0;
      for (int i=0; i<items.size(); i++) {
        if (items.get(i).matches(item)) count++;
View Full Code Here

  protected void die() {
    super.die();

    int count = random.nextInt(2) + 1;
    for (int i = 0; i < count; i++) {
      level.add(new ItemEntity(new ResourceItem(Resource.cloth), x + random.nextInt(11) - 5, y + random.nextInt(11) - 5));
    }

    if (level.player != null) {
      level.player.score += 50 * lvl;
    }
 
View Full Code Here

TOP

Related Classes of com.mojang.ld22.screen.CraftingMenu

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.