-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fleshed out the health, hunger, and stamina systems; also added an apple
- Loading branch information
Showing
5 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package miniventure.game.item; | ||
|
||
import miniventure.game.GameCore; | ||
import miniventure.game.world.Level; | ||
import miniventure.game.world.entity.TextParticle; | ||
import miniventure.game.world.entity.mob.Player; | ||
import miniventure.game.world.entity.mob.Player.Stat; | ||
|
||
import com.badlogic.gdx.graphics.Color; | ||
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public enum FoodItem { | ||
|
||
Apple(2); | ||
|
||
private final int healthGained; | ||
|
||
FoodItem(int healthGained) { | ||
this.healthGained = healthGained; | ||
} | ||
|
||
@NotNull | ||
public Item get() { | ||
return new Item(name(), GameCore.icons.size() > 0 ? GameCore.icons.get(name().toLowerCase()) : new TextureRegion()) { | ||
@Override public Item copy() { return this; } | ||
|
||
@Override public void interact(Player player) { | ||
int gained = player.changeStat(Stat.Hunger, healthGained); | ||
Level level = player.getLevel(); | ||
if(level != null) | ||
level.addEntity(new TextParticle(gained+"", Color.CORAL), player.getCenter(), true); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.