added stats to battle system
This commit is contained in:
@@ -82,7 +82,10 @@ public class Entity {
|
|||||||
if(this.type == EntityType.MONSTER && contactPlayer) {
|
if(this.type == EntityType.MONSTER && contactPlayer) {
|
||||||
if(panel.player.invincible) return;
|
if(panel.player.invincible) return;
|
||||||
panel.playSE(6);
|
panel.playSE(6);
|
||||||
panel.player.life -= 1;
|
|
||||||
|
int damage = attack - panel.player.defense;
|
||||||
|
panel.player.life -= Math.max(damage, 0);
|
||||||
|
|
||||||
panel.player.invincible = true;
|
panel.player.invincible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,8 +124,12 @@ public class Player extends Entity {
|
|||||||
if(index == 999) return;
|
if(index == 999) return;
|
||||||
if(invincible) return;
|
if(invincible) return;
|
||||||
if(panel.monster[index].dying || !panel.monster[index].alive) return;
|
if(panel.monster[index].dying || !panel.monster[index].alive) return;
|
||||||
life -= 1;
|
|
||||||
panel.playSE(6);
|
panel.playSE(6);
|
||||||
|
|
||||||
|
int damage = panel.monster[index].attack - defense;
|
||||||
|
life -= Math.max(damage, 0);
|
||||||
|
|
||||||
invincible = true;
|
invincible = true;
|
||||||
}
|
}
|
||||||
public void attacking() {
|
public void attacking() {
|
||||||
@@ -166,8 +170,11 @@ public class Player extends Entity {
|
|||||||
public void damageMonster(int index) {
|
public void damageMonster(int index) {
|
||||||
if(index == 999) return;
|
if(index == 999) return;
|
||||||
if(panel.monster[index].invincible) return;
|
if(panel.monster[index].invincible) return;
|
||||||
panel.monster[index].life -= 1;
|
|
||||||
panel.playSE(5);
|
panel.playSE(5);
|
||||||
|
|
||||||
|
int damage = attack - panel.monster[index].defense;
|
||||||
|
panel.monster[index].life -= Math.max(damage, 0);
|
||||||
|
|
||||||
panel.monster[index].invincible = true;
|
panel.monster[index].invincible = true;
|
||||||
panel.monster[index].damageReaction();
|
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;
|
||||||
@@ -210,7 +217,7 @@ public class Player extends Entity {
|
|||||||
return attack = strength * currentWeapon.attackValue;
|
return attack = strength * currentWeapon.attackValue;
|
||||||
}
|
}
|
||||||
public int getDefense() {
|
public int getDefense() {
|
||||||
return defense = dexterity * currentShield.attackValue;
|
return defense = dexterity * currentShield.defenseValue;
|
||||||
}
|
}
|
||||||
public void getPlayerImage() {
|
public void getPlayerImage() {
|
||||||
up1 = initEntitySprites("player/boy_up_1");
|
up1 = initEntitySprites("player/boy_up_1");
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ public class GreenSlimeMON extends Entity {
|
|||||||
speed = 1;
|
speed = 1;
|
||||||
maxLife = 4;
|
maxLife = 4;
|
||||||
life = maxLife;
|
life = maxLife;
|
||||||
|
attack = 5;
|
||||||
|
defense = 0;
|
||||||
|
|
||||||
solidArea.x = 3;
|
solidArea.x = 3;
|
||||||
solidArea.y = 18;
|
solidArea.y = 18;
|
||||||
|
|||||||
Reference in New Issue
Block a user