Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Martijn Fixed issue #2 #5

Merged
merged 2 commits into from
Oct 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion HackAttackFX/src/hackattackfx/FXMLDocumentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.shape.Ellipse;

/**
*
Expand Down Expand Up @@ -80,7 +81,8 @@ public Node getNode(String fxid){
for(Object n : list){
if(n instanceof Node){
Node node = (Node)n;
if(node.getId().equals(fxid)){
String s = node.getId();
if (node.getId() != null && s.equals(fxid)){
return node;
}
}
Expand Down
30 changes: 24 additions & 6 deletions HackAttackFX/src/hackattackfx/GraphicsEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.List;
import hackattackfx.exceptions.*;
import java.io.File;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
Expand Down Expand Up @@ -77,7 +78,8 @@ public AnchorPane getScene(){
* @return
*/
public Node getNode(String id){
return parent.getNode(id);
Node n = parent.getNode(id);
return n;
}

/**
Expand Down Expand Up @@ -137,8 +139,18 @@ public void run() {
if(n instanceof MinionImage){
MinionImage mi = (MinionImage)n;
Minion m = ((MinionImage)n).getMinion();

if (m.getHealth() > 0){
mi.setX(m.getPosition().x - (mi.getImage().getWidth()/2));
mi.setY(m.getPosition().y - (mi.getImage().getHeight()/2));
}
else{
try {
deSpawn(n);
} catch (InvalidObjectException ex) {
Logger.getLogger(GraphicsEngine.class.getName()).log(Level.SEVERE, null, ex);
}
}

}else if(n instanceof ModuleImage){
ModuleImage mi = (ModuleImage)n;
Expand All @@ -148,14 +160,20 @@ public void run() {
drawModuleRange((Module)mi.getReference());
}
}else{
if(moduleRange != null){
try {
deSpawn(moduleRange);
// loops through all nodes, if it is an ModuleRange node, remove it.
Iterator i = parent.getAllNodes().iterator();
while (i.hasNext())
{
Node node = (Node)i.next();
if ("ModuleRange".equals(node.getId())) {
deSpawn(node);
}
}
moduleRange = null;
} catch (InvalidObjectException ex) {
Logger.getLogger(GraphicsEngine.class.getName()).log(Level.SEVERE, null, ex);
}
}
}


Expand Down Expand Up @@ -232,8 +250,9 @@ public Ellipse drawModuleRange(Module module){
rangecircle.setStroke(Color.BLACK);
rangecircle.setFill(null);
rangecircle.setStrokeWidth(3);
parent.addNode(rangecircle);
rangecircle.setId("ModuleRange");
moduleRange = rangecircle;
parent.addNode(rangecircle);
return rangecircle;
}

Expand All @@ -250,7 +269,6 @@ public void run() {
lblPlayerHealth.setText(String.format("Health: %s", health));
lblPlayerBitcoins.setText(String.format("Bitcoins: %s", bitcoins));
}

});

}
Expand Down
3 changes: 3 additions & 0 deletions HackAttackFX/src/hackattackfx/Minion.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import hackattackfx.GameEngine.OnExecuteTick;
import hackattackfx.templates.MinionTemplate;
import hackattackfx.enums.MinionType;
import hackattackfx.exceptions.InvalidObjectException;
import hackattackfx.exceptions.UnsubscribeNonListenerException;
import hackattackfx.interfaces.IMoveable;
import java.awt.Point;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.Node;

/*
* To change this license header, choose License Headers in Project Properties.
Expand Down Expand Up @@ -86,6 +88,7 @@ public void onTick(long elapsedtime) {
public void deactivate(){
try {
GameEngine.getInstance().unsubscribeListener(tickListener);

} catch (UnsubscribeNonListenerException ex) {
Logger.getLogger(Minion.class.getName()).log(Level.SEVERE, null, ex);
}
Expand Down
1 change: 1 addition & 0 deletions HackAttackFX/src/hackattackfx/Wave.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private boolean removeMinion(Minion minion){
if (minionList.contains(minion)){
minionList.remove(minion);
killedMinions.add(minion);
minion.deactivate();
return true;
}
else{
Expand Down