Ejemplo n.º 1
0
 public void tick(Level level, int xt, int yt) {
   int damage = level.getData(xt, yt); // gets the amount of damage the cactus has
   if (damage > 0)
     level.setData(
         xt,
         yt,
         damage - 1); // If the number of damage is above 0, then it will minus itself by 1 (heal)
   // Commenter note: I had no idea that cactuses healed themselves.
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 /** Determines what happens when the resource is used on a certain tile */
 public boolean interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir) {
   if (sourceTiles.contains(tile)) { // if the sourceTiles contains the called tile...
     level.setTile(xt, yt, targetTile, 0); // sets the source tile into the targetTile
     return true;
   }
   return false;
 }
Ejemplo n.º 4
0
 public void hurt(Level level, int x, int y, int dmg) {
   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 >= 200) {
     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);
   }
 }
Ejemplo n.º 5
0
  public void render(Screen screen, Level level, int x, int y) {
    super.render(screen, level, x, y);

    int data = level.getData(x, y);
    int shape = (data / 16) % 2;
    int flowerCol = Color.get(10, level.grassColor, 555, 440);

    if (shape == 0) screen.render(x * 16 + 0, y * 16 + 0, 1 + 1 * 32, flowerCol, 0);
    if (shape == 1) screen.render(x * 16 + 8, y * 16 + 0, 1 + 1 * 32, flowerCol, 0);
    if (shape == 1) screen.render(x * 16 + 0, y * 16 + 8, 1 + 1 * 32, flowerCol, 0);
    if (shape == 0) screen.render(x * 16 + 8, y * 16 + 8, 1 + 1 * 32, flowerCol, 0);
  }
Ejemplo n.º 6
0
 /* Damage do to the cactus by the player */
 public void hurt(Level level, int x, int y, Mob source, int dmg, int attackDir) {
   int damage =
       level.getData(x, y)
           + dmg; // Damage done to the cactus (it's "health" in some sense). dmg is the amount the
                  // player did to the cactus.
   level.add(new SmashParticle(x * 16 + 8, y * 16 + 8)); // creates a smash particle
   level.add(
       new TextParticle(
           "" + dmg,
           x * 16 + 8,
           y * 16 + 8,
           Color.get(
               -1, 500, 500,
               500))); // creates a text particle about how much damage has been done.
   if (damage >= 10) { // If the damage is equal to, or larger than 10 then...
     int count = random.nextInt(2) + 1; // count is random from 0 to 1 and adds one. (1-2 count)
     for (int i = 0; i < count; i++) { // cycles through the count
       level.add(
           new ItemEntity(
               new ResourceItem(Resource.cactusFlower),
               x * 16 + random.nextInt(10) + 3,
               y * 16 + random.nextInt(10) + 3)); // adds a cactus flower
     }
     level.setTile(x, y, Tile.sand, 0); // sets the tile to cactus
   } else {
     level.setData(x, y, damage); // else it will set the data to damage
   }
 }
Ejemplo n.º 7
0
 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;
       }
     }
   }
   return false;
 }
Ejemplo n.º 8
0
  public void render(Screen screen, Level level, int x, int y) {
    int col = Color.get(334, 334, 223, 223);
    int transitionColor = Color.get(001, 334, 445, level.dirtColor);

    boolean u = level.getTile(x, y - 1) != this;
    boolean d = level.getTile(x, y + 1) != this;
    boolean l = level.getTile(x - 1, y) != this;
    boolean r = level.getTile(x + 1, y) != this;

    boolean ul = level.getTile(x - 1, y - 1) != this;
    boolean dl = level.getTile(x - 1, y + 1) != this;
    boolean ur = level.getTile(x + 1, y - 1) != this;
    boolean dr = level.getTile(x + 1, y + 1) != this;

    if (!u && !l) {
      if (!ul) screen.render(x * 16 + 0, y * 16 + 0, 0, col, 0);
      else screen.render(x * 16 + 0, y * 16 + 0, 7 + 0 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 0, y * 16 + 0, (l ? 6 : 5) + (u ? 2 : 1) * 32, transitionColor, 3);

    if (!u && !r) {
      if (!ur) screen.render(x * 16 + 8, y * 16 + 0, 1, col, 0);
      else screen.render(x * 16 + 8, y * 16 + 0, 8 + 0 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 8, y * 16 + 0, (r ? 4 : 5) + (u ? 2 : 1) * 32, transitionColor, 3);

    if (!d && !l) {
      if (!dl) screen.render(x * 16 + 0, y * 16 + 8, 2, col, 0);
      else screen.render(x * 16 + 0, y * 16 + 8, 7 + 1 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 0, y * 16 + 8, (l ? 6 : 5) + (d ? 0 : 1) * 32, transitionColor, 3);
    if (!d && !r) {
      if (!dr) screen.render(x * 16 + 8, y * 16 + 8, 3, col, 0);
      else screen.render(x * 16 + 8, y * 16 + 8, 8 + 1 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 8, y * 16 + 8, (r ? 4 : 5) + (d ? 0 : 1) * 32, transitionColor, 3);
  }
Ejemplo n.º 9
0
 public void tick(Level level, int xt, int yt) {
   int damage = level.getData(xt, yt);
   if (damage > 0) level.setData(xt, yt, damage - 1);
 }