Improve "New game" action after game over
This commit is contained in:
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
package com.bartlomiejpluta.demo.entity;
|
package com.bartlomiejpluta.demo.entity;
|
||||||
|
|
||||||
import com.bartlomiejpluta.base.api.character.Character;
|
import com.bartlomiejpluta.base.api.character.Character;
|
||||||
|
import com.bartlomiejpluta.base.util.random.DiceRoller;
|
||||||
import com.bartlomiejpluta.demo.world.item.Item;
|
import com.bartlomiejpluta.demo.world.item.Item;
|
||||||
import com.bartlomiejpluta.demo.world.item.ItemStack;
|
import com.bartlomiejpluta.demo.world.item.ItemStack;
|
||||||
import com.bartlomiejpluta.demo.world.weapon.Ammunition;
|
import com.bartlomiejpluta.demo.world.weapon.Ammunition;
|
||||||
@@ -8,6 +9,8 @@ import com.bartlomiejpluta.demo.world.weapon.Weapon;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.joml.Vector2i;
|
import org.joml.Vector2i;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Player extends Creature {
|
public class Player extends Creature {
|
||||||
public static final int EQUIPMENT_SIZE = 6 * 6;
|
public static final int EQUIPMENT_SIZE = 6 * 6;
|
||||||
private final Item[] equipment = new Item[EQUIPMENT_SIZE];
|
private final Item[] equipment = new Item[EQUIPMENT_SIZE];
|
||||||
@@ -15,8 +18,22 @@ public class Player extends Creature {
|
|||||||
|
|
||||||
public Player(@NonNull Character entity) {
|
public Player(@NonNull Character entity) {
|
||||||
super(entity);
|
super(entity);
|
||||||
this.hp = 20;
|
reset();
|
||||||
this.maxHp = 20;
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
var data = DB.dao.levels.find(1);
|
||||||
|
this.maxHp = DiceRoller.roll(data.getMaxHp());
|
||||||
|
this.hp = this.maxHp;
|
||||||
|
|
||||||
|
alive = true;
|
||||||
|
changeCharacterSet(A.charsets.luna.uid);
|
||||||
|
setScale(1f);
|
||||||
|
setSpeed(4f);
|
||||||
|
setAnimationSpeed(1f);
|
||||||
|
setBlocking(true);
|
||||||
|
|
||||||
|
Arrays.fill(equipment, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interact() {
|
public void interact() {
|
||||||
|
|||||||
@@ -57,18 +57,11 @@ public class DemoRunner implements GameRunner {
|
|||||||
this.player = new Player(context.createCharacter(A.charsets.luna.uid));
|
this.player = new Player(context.createCharacter(A.charsets.luna.uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetPlayer() {
|
|
||||||
this.player.changeCharacterSet(A.charsets.luna.uid);
|
|
||||||
this.player.setScale(1f);
|
|
||||||
this.player.setSpeed(4f);
|
|
||||||
this.player.setAnimationSpeed(1f);
|
|
||||||
this.player.setBlocking(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void newGame() {
|
public void newGame() {
|
||||||
|
context.resetMaps();
|
||||||
guiManager.closeAll();
|
guiManager.closeAll();
|
||||||
guiManager.enableGameMenu();
|
guiManager.enableGameMenu();
|
||||||
resetPlayer();
|
player.reset();
|
||||||
context.openMap(A.maps.hero_home.uid);
|
context.openMap(A.maps.hero_home.uid);
|
||||||
context.getMap().getObjectLayer(A.maps.hero_home.layers.main).addEntity(this.player);
|
context.getMap().getObjectLayer(A.maps.hero_home.layers.main).addEntity(this.player);
|
||||||
player.setCoordinates(11, 14);
|
player.setCoordinates(11, 14);
|
||||||
|
|||||||
Reference in New Issue
Block a user