Compare commits
3 Commits
e0986d4708
...
93467760db
| Author | SHA1 | Date | |
|---|---|---|---|
|
93467760db
|
|||
|
6be9927752
|
|||
|
1343b18753
|
@@ -108,6 +108,7 @@ public class Entity {
|
|||||||
knockbackCount = 0;
|
knockbackCount = 0;
|
||||||
knockback = false;
|
knockback = false;
|
||||||
speed = defaultSpeed;
|
speed = defaultSpeed;
|
||||||
|
invincibleCounting();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +120,10 @@ public class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
knockbackCount++;
|
knockbackCount++;
|
||||||
if(knockbackCount != 10) return;
|
if(knockbackCount != 10) {
|
||||||
|
invincibleCounting();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
knockback = false;
|
knockback = false;
|
||||||
knockbackCount = 0;
|
knockbackCount = 0;
|
||||||
@@ -146,14 +150,7 @@ public class Entity {
|
|||||||
spriteCount = 0;
|
spriteCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
invincibleCounting();
|
||||||
// INVINCIBLE COUNTER
|
|
||||||
if(!invincible) return;
|
|
||||||
invincibleCount++;
|
|
||||||
if(invincibleCount > 40) {
|
|
||||||
invincible = false;
|
|
||||||
invincibleCount = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void draw(Graphics2D graphics2d) {
|
public void draw(Graphics2D graphics2d) {
|
||||||
int screenX = worldX - panel.player.worldX + panel.player.screenX;
|
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));
|
panel.player.life -= Math.max(damage, (block ? 0 : 1));
|
||||||
|
|
||||||
if(damage != 0) {
|
if(damage != 0) {
|
||||||
//setKnockback(panel.player, this, knockbackVal);
|
setKnockback(panel.player, this, knockbackVal);
|
||||||
panel.player.transparent = true;
|
panel.player.transparent = true;
|
||||||
}
|
}
|
||||||
panel.player.invincible = true;
|
panel.player.invincible = true;
|
||||||
@@ -613,5 +610,13 @@ public class Entity {
|
|||||||
actionLock = 0;
|
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() {
|
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();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BLOCKING
|
// BLOCKING
|
||||||
if(keyH.CTLKeyPressed) {
|
if(keyH.CTLKeyPressed) {
|
||||||
guarding = true;
|
guarding = true;
|
||||||
|
transparent = false;
|
||||||
|
invincibleCounting();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,15 +173,11 @@ public class Player extends Entity {
|
|||||||
|
|
||||||
// INVINCIBLE COUNTER
|
// INVINCIBLE COUNTER
|
||||||
if(!invincible) return;
|
if(!invincible) return;
|
||||||
invincibleCount++;
|
invincibleCounting();
|
||||||
if(invincibleCount > 60) {
|
|
||||||
invincible = false;
|
|
||||||
transparent = false;
|
|
||||||
invincibleCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
@@ -204,6 +235,7 @@ public class Player extends Entity {
|
|||||||
panel.playSE(5);
|
panel.playSE(5);
|
||||||
if(knockbackVal > 0) setKnockback(panel.monster[panel.currentMap.getIndex()][index], attacker, 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].life -= damage;
|
||||||
|
panel.monster[panel.currentMap.getIndex()][index].transparent = true;
|
||||||
panel.monster[panel.currentMap.getIndex()][index].invincible = true;
|
panel.monster[panel.currentMap.getIndex()][index].invincible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,5 +427,14 @@ public class Player extends Entity {
|
|||||||
}
|
}
|
||||||
return false;
|
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();
|
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