implement knockback mechanics and adjust attack detection for OrcMON
This commit is contained in:
@@ -52,8 +52,40 @@ public class Player extends Entity {
|
|||||||
public void update() {
|
public void update() {
|
||||||
if(life > maxLife) life = maxLife;
|
if(life > maxLife) life = maxLife;
|
||||||
|
|
||||||
// ATTACKING
|
if(knockback) {
|
||||||
if(attacking) {
|
collisionOn = false;
|
||||||
|
panel.collisionH.checkTile(this);
|
||||||
|
panel.collisionH.checkObject(this, false);
|
||||||
|
panel.collisionH.checkEntity(this, panel.npc[panel.currentMap.getIndex()]);
|
||||||
|
// panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
|
||||||
|
panel.collisionH.checkEntity(this, panel.iTile[panel.currentMap.getIndex()]);
|
||||||
|
if(collisionOn) {
|
||||||
|
knockbackCount = 0;
|
||||||
|
knockback = false;
|
||||||
|
speed = defaultSpeed;
|
||||||
|
invincibleCounting();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(knockbackDirection) {
|
||||||
|
case UP -> worldY -= speed;
|
||||||
|
case DOWN -> worldY += speed;
|
||||||
|
case LEFT -> worldX -= speed;
|
||||||
|
case RIGHT -> worldX += speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
knockbackCount++;
|
||||||
|
if(knockbackCount != 10) {
|
||||||
|
invincibleCounting();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
knockback = false;
|
||||||
|
knockbackCount = 0;
|
||||||
|
speed = defaultSpeed;
|
||||||
|
invincibleCounting();
|
||||||
|
return;
|
||||||
|
} else if(attacking) {
|
||||||
attacking();
|
attacking();
|
||||||
invincibleCounting();
|
invincibleCounting();
|
||||||
return;
|
return;
|
||||||
@@ -62,6 +94,7 @@ public class Player extends Entity {
|
|||||||
// BLOCKING
|
// BLOCKING
|
||||||
if(keyH.CTLKeyPressed) {
|
if(keyH.CTLKeyPressed) {
|
||||||
guarding = true;
|
guarding = true;
|
||||||
|
transparent = false;
|
||||||
invincibleCounting();
|
invincibleCounting();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -101,7 +134,7 @@ public class Player extends Entity {
|
|||||||
switch (direction) {
|
switch (direction) {
|
||||||
case UP -> worldY -= speed;
|
case UP -> worldY -= speed;
|
||||||
case DOWN -> worldY += speed;
|
case DOWN -> worldY += speed;
|
||||||
case LEFT ->worldX -= speed;
|
case LEFT -> worldX -= speed;
|
||||||
case RIGHT -> worldX += speed;
|
case RIGHT -> worldX += speed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,6 +177,7 @@ public class Player extends Entity {
|
|||||||
|
|
||||||
if(life <= 0) {
|
if(life <= 0) {
|
||||||
panel.gameState = GameState.GAMEOVER;
|
panel.gameState = GameState.GAMEOVER;
|
||||||
|
invincibleCount = 0;
|
||||||
panel.ui.commandNum = -1;
|
panel.ui.commandNum = -1;
|
||||||
panel.stopMusic();
|
panel.stopMusic();
|
||||||
panel.playSE(12);
|
panel.playSE(12);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class OrcMON extends Entity {
|
|||||||
if(!onPath) checkStartChasing(panel.player, 10 ,100); else followPlayer();
|
if(!onPath) checkStartChasing(panel.player, 10 ,100); else followPlayer();
|
||||||
checkStopChasing(panel.player, 15, 100);
|
checkStopChasing(panel.player, 15, 100);
|
||||||
setRandomDirection();
|
setRandomDirection();
|
||||||
if(!attacking) checkAttack(30, panel.tileSize*4, panel.tileSize);
|
if(!attacking) checkAttack(50, panel.tileSize*4, panel.tileSize);
|
||||||
}
|
}
|
||||||
public void damageReaction() {
|
public void damageReaction() {
|
||||||
actionLock = 0;
|
actionLock = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user