Compare commits
3 Commits
e0986d4708
...
93467760db
| Author | SHA1 | Date | |
|---|---|---|---|
|
93467760db
|
|||
|
6be9927752
|
|||
|
1343b18753
|
@@ -108,6 +108,7 @@ public class Entity {
|
||||
knockbackCount = 0;
|
||||
knockback = false;
|
||||
speed = defaultSpeed;
|
||||
invincibleCounting();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,7 +120,10 @@ public class Entity {
|
||||
}
|
||||
|
||||
knockbackCount++;
|
||||
if(knockbackCount != 10) return;
|
||||
if(knockbackCount != 10) {
|
||||
invincibleCounting();
|
||||
return;
|
||||
}
|
||||
|
||||
knockback = false;
|
||||
knockbackCount = 0;
|
||||
@@ -146,14 +150,7 @@ public class Entity {
|
||||
spriteCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// INVINCIBLE COUNTER
|
||||
if(!invincible) return;
|
||||
invincibleCount++;
|
||||
if(invincibleCount > 40) {
|
||||
invincible = false;
|
||||
invincibleCount = 0;
|
||||
}
|
||||
invincibleCounting();
|
||||
}
|
||||
public void draw(Graphics2D graphics2d) {
|
||||
int screenX = worldX - panel.player.worldX + panel.player.screenX;
|
||||
@@ -262,7 +259,7 @@ public class Entity {
|
||||
panel.player.life -= Math.max(damage, (block ? 0 : 1));
|
||||
|
||||
if(damage != 0) {
|
||||
//setKnockback(panel.player, this, knockbackVal);
|
||||
setKnockback(panel.player, this, knockbackVal);
|
||||
panel.player.transparent = true;
|
||||
}
|
||||
panel.player.invincible = true;
|
||||
@@ -613,5 +610,13 @@ public class Entity {
|
||||
actionLock = 0;
|
||||
}
|
||||
}
|
||||
public void invincibleCounting() {
|
||||
if(!invincible) return;
|
||||
invincibleCount++;
|
||||
if(invincibleCount > 40) {
|
||||
invincible = false;
|
||||
invincibleCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,15 +52,50 @@ public class Player extends Entity {
|
||||
public void update() {
|
||||
if(life > maxLife) life = maxLife;
|
||||
|
||||
// ATTACKING
|
||||
if(attacking) {
|
||||
if(knockback) {
|
||||
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();
|
||||
invincibleCounting();
|
||||
return;
|
||||
}
|
||||
|
||||
// BLOCKING
|
||||
if(keyH.CTLKeyPressed) {
|
||||
guarding = true;
|
||||
transparent = false;
|
||||
invincibleCounting();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,15 +173,11 @@ public class Player extends Entity {
|
||||
|
||||
// INVINCIBLE COUNTER
|
||||
if(!invincible) return;
|
||||
invincibleCount++;
|
||||
if(invincibleCount > 60) {
|
||||
invincible = false;
|
||||
transparent = false;
|
||||
invincibleCount = 0;
|
||||
}
|
||||
invincibleCounting();
|
||||
|
||||
if(life <= 0) {
|
||||
panel.gameState = GameState.GAMEOVER;
|
||||
invincibleCount = 0;
|
||||
panel.ui.commandNum = -1;
|
||||
panel.stopMusic();
|
||||
panel.playSE(12);
|
||||
@@ -204,6 +235,7 @@ public class Player extends Entity {
|
||||
panel.playSE(5);
|
||||
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].transparent = true;
|
||||
panel.monster[panel.currentMap.getIndex()][index].invincible = true;
|
||||
}
|
||||
|
||||
@@ -395,5 +427,14 @@ public class Player extends Entity {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void invincibleCounting() {
|
||||
if(!invincible) return;
|
||||
invincibleCount++;
|
||||
if(invincibleCount > 60) {
|
||||
invincible = false;
|
||||
invincibleCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class OrcMON extends Entity {
|
||||
if(!onPath) checkStartChasing(panel.player, 10 ,100); else followPlayer();
|
||||
checkStopChasing(panel.player, 15, 100);
|
||||
setRandomDirection();
|
||||
if(!attacking) checkAttack(30, panel.tileSize*4, panel.tileSize);
|
||||
if(!attacking) checkAttack(50, panel.tileSize*4, panel.tileSize);
|
||||
}
|
||||
public void damageReaction() {
|
||||
actionLock = 0;
|
||||
|
||||
Reference in New Issue
Block a user