Package com.mojang.ld22.entity

Examples of com.mojang.ld22.entity.Zombie


public class ResourceRecipe extends Recipe {
  private Resource resource;

  public ResourceRecipe(Resource resource) {
    super(new ResourceItem(resource, 1));
    this.resource = resource;
  }
View Full Code Here


    super(new ResourceItem(resource, 1));
    this.resource = resource;
  }

  public void craft(Player player) {
    player.inventory.add(0, new ResourceItem(resource, 1));
  }
View Full Code Here

  public Recipe(Item resultTemplate) {
    this.resultTemplate = resultTemplate;
  }

  public Recipe addCost(Resource resource, int count) {
    costs.add(new ResourceItem(resource, count));
    return this;
  }
View Full Code Here

  public void checkCanCraft(Player player) {
    for (int i = 0; i < costs.size(); i++) {
      Item item = costs.get(i);
      if (item instanceof ResourceItem) {
        ResourceItem ri = (ResourceItem) item;
        if (!player.inventory.hasResources(ri.resource, ri.count)) {
          canCraft = false;
          return;
        }
      }
View Full Code Here

  public void deductCost(Player player) {
    for (int i = 0; i < costs.size(); i++) {
      Item item = costs.get(i);
      if (item instanceof ResourceItem) {
        ResourceItem ri = (ResourceItem) item;
        player.inventory.removeResource(ri.resource, ri.count);
      }
    }
  }
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

    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 >= 50) {
      int count = random.nextInt(4) + 1;
      for (int i = 0; i < count; i++) {
        level.add(new ItemEntity(new ResourceItem(Resource.stone), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
      }
      count = random.nextInt(2);
      for (int i = 0; i < count; i++) {
        level.add(new ItemEntity(new ResourceItem(Resource.coal), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
      }
      level.setTile(x, y, Tile.dirt, 0);
    } else {
      level.setData(x, y, damage);
    }
View Full Code Here

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

    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 >= 10) {
      int count = random.nextInt(2) + 1;
      for (int i = 0; i < count; i++) {
        level.add(new ItemEntity(new ResourceItem(Resource.cactusFlower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
      }
      level.setTile(x, y, Tile.sand, 0);
    } else {
      level.setData(x, y, damage);
    }
View Full Code Here

TOP

Related Classes of com.mojang.ld22.entity.Zombie

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.