added notifications and added leveling system
This commit is contained in:
@@ -125,12 +125,14 @@ public class Player extends Entity {
|
||||
if(invincible) return;
|
||||
if(panel.monster[index].dying || !panel.monster[index].alive) return;
|
||||
|
||||
panel.playSE(6);
|
||||
|
||||
int damage = panel.monster[index].attack - defense;
|
||||
life -= Math.max(damage, 0);
|
||||
|
||||
invincible = true;
|
||||
if(damage > 0) {
|
||||
panel.playSE(6);
|
||||
life -= damage;
|
||||
invincible = true;
|
||||
}
|
||||
|
||||
}
|
||||
public void attacking() {
|
||||
if(attackCancel) return;
|
||||
@@ -170,14 +172,22 @@ public class Player extends Entity {
|
||||
public void damageMonster(int index) {
|
||||
if(index == 999) return;
|
||||
if(panel.monster[index].invincible) return;
|
||||
panel.playSE(5);
|
||||
|
||||
int damage = attack - panel.monster[index].defense;
|
||||
panel.monster[index].life -= Math.max(damage, 0);
|
||||
|
||||
panel.monster[index].invincible = true;
|
||||
if(damage > 0) {
|
||||
panel.playSE(5);
|
||||
panel.monster[index].life -= damage;
|
||||
panel.monster[index].invincible = true;
|
||||
}
|
||||
|
||||
panel.monster[index].damageReaction();
|
||||
if(panel.monster[index].life <= 0) panel.monster[index].dying = true;
|
||||
if(panel.monster[index].life <= 0) {
|
||||
panel.monster[index].dying = true;
|
||||
panel.ui.addMessage("Gained +" + panel.monster[index].exp + " XP!");
|
||||
exp += panel.monster[index].exp;
|
||||
checkLevelUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void interactNPC(int index) {
|
||||
@@ -192,6 +202,22 @@ public class Player extends Entity {
|
||||
super.speak();
|
||||
}
|
||||
|
||||
// BACKGROUND CHECKS
|
||||
public void checkLevelUp() {
|
||||
if(exp < nextLevelExp) return;
|
||||
level++;
|
||||
nextLevelExp = nextLevelExp*2;
|
||||
maxLife += 2;
|
||||
strength++;
|
||||
dexterity++;
|
||||
attack = getAttack();
|
||||
defense = getDefense();
|
||||
panel.playSE(8);
|
||||
|
||||
panel.gameState = GameState.DIALOGUE;
|
||||
panel.ui.currentDialogue = "You are level " + level + " now!\nYou feel stronger!";
|
||||
}
|
||||
|
||||
// SETTING THINGS UP
|
||||
public void setDefaultValues() {
|
||||
worldX = panel.tileSize * 23;
|
||||
|
||||
Reference in New Issue
Block a user