add Orc monster implementation and enhance player-monster interaction
This commit is contained in:
@@ -176,45 +176,7 @@ public class Player extends Entity {
|
||||
}
|
||||
|
||||
}
|
||||
public void attacking() {
|
||||
if(attackCancel) return;
|
||||
spriteCount++;
|
||||
if(spriteCount <= 5) spriteNum = 1;
|
||||
if(spriteCount > 5 && spriteCount <= 25) {
|
||||
spriteNum = 2;
|
||||
int currentWorldX = worldX;
|
||||
int currentWorldY = worldY;
|
||||
int solidAreaWidth = solidArea.width;
|
||||
int solidAreaHeight = solidArea.height;
|
||||
|
||||
switch(direction) {
|
||||
case UP -> worldY -= attackArea.height;
|
||||
case DOWN -> worldY += attackArea.height;
|
||||
case LEFT -> worldX -= attackArea.width;
|
||||
case RIGHT -> worldX += attackArea.width;
|
||||
}
|
||||
solidArea.width = attackArea.width;
|
||||
solidArea.height = attackArea.height;
|
||||
|
||||
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
|
||||
damageMonster(monsterIndex, attack, currentWeapon.knockbackVal);
|
||||
|
||||
int iTileIndex = panel.collisionH.checkEntity(this, panel.iTile[panel.currentMap.getIndex()]);
|
||||
interactTile(iTileIndex);
|
||||
|
||||
worldX = currentWorldX;
|
||||
worldY = currentWorldY;
|
||||
solidArea.width = solidAreaWidth;
|
||||
solidArea.height = solidAreaHeight;
|
||||
|
||||
}
|
||||
if(spriteCount > 25) {
|
||||
spriteNum = 1;
|
||||
spriteCount = 0;
|
||||
attacking = false;
|
||||
}
|
||||
}
|
||||
public void damageMonster(int index, int attack, int knockbackVal) {
|
||||
public void damageMonster(int index, Entity attacker, int attack, int knockbackVal) {
|
||||
if(index == 999) return;
|
||||
if(panel.monster[panel.currentMap.getIndex()][index].invincible) return;
|
||||
|
||||
@@ -222,7 +184,7 @@ public class Player extends Entity {
|
||||
|
||||
if(damage > 0) {
|
||||
panel.playSE(5);
|
||||
if(knockbackVal > 0) knockback(panel.monster[panel.currentMap.getIndex()][index], knockbackVal);
|
||||
if(knockbackVal > 0) setKnockback(panel.monster[panel.currentMap.getIndex()][index], attacker, knockbackVal);
|
||||
panel.monster[panel.currentMap.getIndex()][index].life -= damage;
|
||||
panel.monster[panel.currentMap.getIndex()][index].invincible = true;
|
||||
}
|
||||
@@ -235,11 +197,6 @@ public class Player extends Entity {
|
||||
checkLevelUp();
|
||||
}
|
||||
}
|
||||
public void knockback(Entity entity, int knockbackVal) {
|
||||
entity.direction = direction;
|
||||
entity.speed += knockbackVal;
|
||||
entity.knockback = true;
|
||||
}
|
||||
|
||||
public void interactTile(int index) {
|
||||
if(index == 999 || !panel.iTile[panel.currentMap.getIndex()][index].destructible || panel.iTile[panel.currentMap.getIndex()][index].invincible) return;
|
||||
|
||||
Reference in New Issue
Block a user