Fixed selection bug and changed the astar a bit but its still not right

This commit is contained in:
Ziver Koc 2007-04-19 15:41:31 +00:00
parent bdb12e2000
commit 397fb7ebd0
4 changed files with 15 additions and 10 deletions

View file

@ -27,7 +27,7 @@ public class AStar{
}
public List<AStarNode> startSearch(Vector2i start, Vector2i goal){
map[goal.getX()][goal.getY()].setBlocked(false);
//map[goal.getX()][goal.getY()].setBlocked(false);
return pathfinder.findPath(map[start.getX()][start.getY()], map[goal.getX()][goal.getY()]);
}

View file

@ -47,11 +47,12 @@ public class AStarPathfinder{
start.costFromStart = 0;
open.add(start);
AStarNode node = null;
// Go through all the items in the open storage.
int order = 0; // defines the order of which the nodes were visited (used in gui visuals)
while (!open.isEmpty()) {
// Let's retrieve the first item from the storage.
AStarNode node = (AStarNode) open.removeFirst();
node = (AStarNode) open.removeFirst();
node.setVisited(true);
node.setVisitOrder(order++);
@ -96,7 +97,8 @@ public class AStarPathfinder{
}
}
return null;
//return null;
return constructPath(node);
}

View file

@ -98,7 +98,10 @@ public class InGameMouseInput extends MouseInput{
}
}
else{
if(oldMouseOver != null)oldMouseOver.setMouseOver(false);
if(oldMouseOver != null){
oldMouseOver.setMouseOver(false);
oldMouseOver = null;
}
}
}
}

View file

@ -3,7 +3,6 @@ package ei.game.scene.units;
import java.util.LinkedList;
import ei.engine.effects.Particles;
import ei.engine.math.Vector2f;
import ei.engine.math.Vector2i;
import ei.engine.math.Vector3f;
@ -209,13 +208,14 @@ public abstract class Unit extends GameEntity{
unitNode.getLocation().add(0f, -getVelocity(), 0f);
}
if(attack != null && getWeapon(new Vector2f(unitNode.getLocation().getX(), unitNode.getLocation().getY()))
.onRange(new Vector2f(attack.getNode().getLocation().getX(), attack.getNode().getLocation().getY()))){
moveTo = null;
}
else if(Math.abs(moveTo.getX() - unitNode.getLocation().getX()) < getVelocity()+1
&& Math.abs(moveTo.getY() - unitNode.getLocation().getY())< getVelocity()+1 ){
if(path != null && !path.isEmpty()){
if(attack != null && getWeapon(new Vector2f(unitNode.getLocation().getX(), unitNode.getLocation().getY()))
.onRange(new Vector2f(attack.getNode().getLocation().getX(), attack.getNode().getLocation().getY()))){
moveTo = null;
}
else if(path != null && !path.isEmpty()){
AStarNode temp = path.poll();
if(InGameState.getMap().isPosEmpty(temp.getX(), temp.getY())){
oldVect = new Vector2i((int)moveTo.getX(), (int)moveTo.getY());