import code
This commit is contained in:
24
src/com/mojang/ld22/item/resource/FoodResource.java
Normal file
24
src/com/mojang/ld22/item/resource/FoodResource.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.mojang.ld22.item.resource;
|
||||
|
||||
import com.mojang.ld22.entity.Player;
|
||||
import com.mojang.ld22.level.Level;
|
||||
import com.mojang.ld22.level.tile.Tile;
|
||||
|
||||
public class FoodResource extends Resource {
|
||||
private int heal;
|
||||
private int staminaCost;
|
||||
|
||||
public FoodResource(String name, int sprite, int color, int heal, int staminaCost) {
|
||||
super(name, sprite, color);
|
||||
this.heal = heal;
|
||||
this.staminaCost = staminaCost;
|
||||
}
|
||||
|
||||
public boolean interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir) {
|
||||
if (player.health < player.maxHealth && player.payStamina(staminaCost)) {
|
||||
player.heal(heal);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user