From c684221bdd6f2bd4eef25626bee0b98a375a09c1 Mon Sep 17 00:00:00 2001 From: andreas Date: Tue, 11 Nov 2014 15:41:16 +0100 Subject: [PATCH] Anpassung in Opponent bei Kollisionserkennung --- HeatUp/src/de/heatup/testing/Opponent.java | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/HeatUp/src/de/heatup/testing/Opponent.java b/HeatUp/src/de/heatup/testing/Opponent.java index b2844a5..b2c3a03 100644 --- a/HeatUp/src/de/heatup/testing/Opponent.java +++ b/HeatUp/src/de/heatup/testing/Opponent.java @@ -54,26 +54,27 @@ public class Opponent extends Player { this.blocked = (this.blockedCounter >= 30) ? true : false; this.prevX = this.getGridLocation().x; this.prevY = this.getGridLocation().y; - - // Kreuzung erkennen + if ( d == 'x' ) { - if ( MapGrid.getGridCell(this.getGridLocation().x, this.getGridLocation().y+1).isPath() ) { + if ( CollisionHandler.checkCollision(this, 'd') ) { this.move = false; } - if ( MapGrid.getGridCell(this.getGridLocation().x, this.getGridLocation().y-1).isPath() ) { + if ( CollisionHandler.checkCollision(this, 'u') ) { this.move = false; } } if ( d == 'y' ) { - if ( MapGrid.getGridCell(this.getGridLocation().x-1, this.getGridLocation().y).isPath() ) { + if ( CollisionHandler.checkCollision(this, 'l') ) { this.move = false; } - if ( MapGrid.getGridCell(this.getGridLocation().x+1, this.getGridLocation().y).isPath() ) { + if ( CollisionHandler.checkCollision(this, 'r') ) { this.move = false; } } + + // Umentscheiden oder weiter in die vorgegeben Richtung if ( ! this.move ) { //Logger.write("Redeciding..."); @@ -85,7 +86,7 @@ public class Opponent extends Player { } } else { - Logger.write("Moving..."); + //Logger.write("Moving..."); } this.move = true; @@ -119,7 +120,6 @@ public class Opponent extends Player { } if (CollisionHandler.checkCollision(this, charDir)) { - System.out.println("Kollision!"); this.setGridLocation(testX, testY); this.prevd = d; this.previ = i; @@ -156,18 +156,11 @@ public class Opponent extends Player { } if (stepCounter <= 0) { stepCounter = 25; - - if ( ! MapGrid.getGridCell(newx,newy).isPath()) { - redecide = true; - animate = false; - } else { - animate = true; - } + redecide = true; + animate = false; + } else { + animate = true; } } - - - } - }