mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
Anpassung in Opponent bei Kollisionserkennung
This commit is contained in:
@@ -54,26 +54,27 @@ public class Opponent extends Player {
|
|||||||
this.blocked = (this.blockedCounter >= 30) ? true : false;
|
this.blocked = (this.blockedCounter >= 30) ? true : false;
|
||||||
this.prevX = this.getGridLocation().x;
|
this.prevX = this.getGridLocation().x;
|
||||||
this.prevY = this.getGridLocation().y;
|
this.prevY = this.getGridLocation().y;
|
||||||
|
|
||||||
// Kreuzung erkennen
|
|
||||||
if ( d == 'x' ) {
|
if ( d == 'x' ) {
|
||||||
if ( MapGrid.getGridCell(this.getGridLocation().x, this.getGridLocation().y+1).isPath() ) {
|
if ( CollisionHandler.checkCollision(this, 'd') ) {
|
||||||
this.move = false;
|
this.move = false;
|
||||||
}
|
}
|
||||||
if ( MapGrid.getGridCell(this.getGridLocation().x, this.getGridLocation().y-1).isPath() ) {
|
if ( CollisionHandler.checkCollision(this, 'u') ) {
|
||||||
this.move = false;
|
this.move = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( d == 'y' ) {
|
if ( d == 'y' ) {
|
||||||
if ( MapGrid.getGridCell(this.getGridLocation().x-1, this.getGridLocation().y).isPath() ) {
|
if ( CollisionHandler.checkCollision(this, 'l') ) {
|
||||||
this.move = false;
|
this.move = false;
|
||||||
}
|
}
|
||||||
if ( MapGrid.getGridCell(this.getGridLocation().x+1, this.getGridLocation().y).isPath() ) {
|
if ( CollisionHandler.checkCollision(this, 'r') ) {
|
||||||
this.move = false;
|
this.move = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Umentscheiden oder weiter in die vorgegeben Richtung
|
// Umentscheiden oder weiter in die vorgegeben Richtung
|
||||||
if ( ! this.move ) {
|
if ( ! this.move ) {
|
||||||
//Logger.write("Redeciding...");
|
//Logger.write("Redeciding...");
|
||||||
@@ -85,7 +86,7 @@ public class Opponent extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Logger.write("Moving...");
|
//Logger.write("Moving...");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.move = true;
|
this.move = true;
|
||||||
@@ -119,7 +120,6 @@ public class Opponent extends Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CollisionHandler.checkCollision(this, charDir)) {
|
if (CollisionHandler.checkCollision(this, charDir)) {
|
||||||
System.out.println("Kollision!");
|
|
||||||
this.setGridLocation(testX, testY);
|
this.setGridLocation(testX, testY);
|
||||||
this.prevd = d;
|
this.prevd = d;
|
||||||
this.previ = i;
|
this.previ = i;
|
||||||
@@ -156,18 +156,11 @@ public class Opponent extends Player {
|
|||||||
}
|
}
|
||||||
if (stepCounter <= 0) {
|
if (stepCounter <= 0) {
|
||||||
stepCounter = 25;
|
stepCounter = 25;
|
||||||
|
redecide = true;
|
||||||
if ( ! MapGrid.getGridCell(newx,newy).isPath()) {
|
animate = false;
|
||||||
redecide = true;
|
} else {
|
||||||
animate = false;
|
animate = true;
|
||||||
} else {
|
|
||||||
animate = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user