Skip to content

Commit

Permalink
Finished basic features
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterCavespider committed Jul 23, 2016
1 parent 6e77ef3 commit 4c837f1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 22 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/build/
/nbproject/private/
/build/
/nbproject/private/
/dist/
12 changes: 1 addition & 11 deletions src/mygame/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,13 @@ public void simpleInitApp() {
//Create the View
View v = new View(this);
g.register(v);
v.construct();
v.construct(p1, p2);
}

public void initMappings() {
inputManager.addMapping("Pick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(click, "Pick");
}

public static Material getRandomMat() {
Material mat = new Material(shortcut, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.randomColor());
return mat;
}

public static Material getColoredMaterial(ColorRGBA color) {
Material mat = new Material(shortcut, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", color);
return mat;
}
}
2 changes: 0 additions & 2 deletions src/nl/ibe/hex/game/HexCoordinate.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public HexCoordinate getNeighbor(int i)
public ArrayList<HexCoordinate> ring(int radius)
{

System.out.println("this: " + this.toString());
ArrayList<HexCoordinate> result = new ArrayList();
HexCoordinate neigh4 = this.getNeighbor(4);
//HexCoordinate cube = this.add(neigh4.scale(radius));
Expand All @@ -78,7 +77,6 @@ public ArrayList<HexCoordinate> ring(int radius)
{
for (int j =0; j < radius; j++)
{
System.out.println("cube: " + cube.toString());
result.add(cube);
cube = cube.getNeighbor(i);
}
Expand Down
3 changes: 1 addition & 2 deletions src/nl/ibe/hex/game/HexGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ private void executeMove(HexMove move)
{
neighTile.setOwner(currPlayer);

HexTile src = bord.get(move.getFrom());
HexTile dst = bord.get(move.getTo());
HexChange change = new HexChange(src, dst, HexChange.Type.CONQUEST);
HexChange change = new HexChange(dst, neighTile, HexChange.Type.CONQUEST);
changedTiles.add(change);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/nl/ibe/hex/view/HexSpatial.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void setOwner(HexPlayer.Type type) {
//Attach the stuff
if(type != null) {
ownerNode.attachChild(ModelSupplier.getPlayerShape(type));
ownerNode.attachChild(ParticleSupplier.getFire(ColorSupplier.getPlayerColor(type), ColorRGBA.White));
//ownerNode.attachChild(ParticleSupplier.getFire(ColorSupplier.getPlayerColor(type), ColorRGBA.White));
}
}

Expand All @@ -107,6 +107,10 @@ public void placeCorrectly() {
public HexCoordinate getCoord() {
return coord;
}

public HexPlayer.Type getOwnerType() {
return ownerType;
}

public Node getOwnerAttach() {
return ownerNode;
Expand Down
36 changes: 32 additions & 4 deletions src/nl/ibe/hex/view/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public View(SimpleApplication app) {
* It will populate the ViewGrid using the board from
* the game. It will also create and register a clicker.
*/
public void construct() {
public void construct(HexPlayer p1, HexPlayer p2) {
//Is there a game?
if(game == null) {
//No
Expand All @@ -85,6 +85,16 @@ public void construct() {
app.getInputManager().addMapping(Clicker.mapping, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
app.getInputManager().addListener(click, Clicker.mapping);
}

//Load the starters.
ArrayList<HexCoordinate> p1POS = game.getBoard().getPlayerPositions(p1);
for (HexCoordinate hexCoordinate : p1POS) {
grid.getGrid().get(hexCoordinate).setOwner(p1.getType());
}
ArrayList<HexCoordinate> p2POS = game.getBoard().getPlayerPositions(p2);
for (HexCoordinate hexCoordinate : p2POS) {
grid.getGrid().get(hexCoordinate).setOwner(p2.getType());
}
}

/**
Expand All @@ -105,27 +115,38 @@ public void tilesChanged(ArrayList<HexChange> hexagons) {

HexCoordinate c = change.getEnd().getCoordinate();
grid.getGrid().get(c).setOwner(change.getStart().getOwner().getType());
break;
}
case JUMP: {
//A certain blob has to jump (through the air)
//To the end position.

HexPlayer.Type jumper = change.getStart().getOwner().getType();

HexPlayer.Type jumper = change.getEnd().getOwner().getType();

HexCoordinate s = change.getStart().getCoordinate();
HexCoordinate e = change.getEnd().getCoordinate();

///test
grid.getGrid().get(s).setOwner(null);
grid.getGrid().get(e).setOwner(jumper);

break;
}
case CONQUEST: {
//Some blob has been conquered by another blob.

HexPlayer.Type conqueror = change.getStart().getOwner().getType();
HexPlayer.Type ded = change.getStart().getOwner().getType();
System.out.println(conqueror);

HexSpatial s = grid.getGrid().get(change.getEnd().getCoordinate());
System.out.println("spatial" + s.getOwnerType());

s.setOwner(conqueror);

grid.getGrid().get(change.getStart().getCoordinate()).setOwner(conqueror);
break;
}

}

}
Expand Down Expand Up @@ -188,6 +209,9 @@ public void onClick(HexSpatial hex) {
HexMove move = new HexMove(p, c1, c2);

boolean canItMove = game.move(move);
if(canItMove) {
game.nextTurn();
}

LOG.log(Level.INFO, "Can it move? {0}", canItMove);
selected = false;
Expand All @@ -200,6 +224,7 @@ public void onClick(HexSpatial hex) {
value.setMaterial(MaterialSupplier.getColoredMaterial(ColorSupplier.getBoardColor()));
}


} else { //!selected
//Select what we have here
selection = hex;
Expand Down Expand Up @@ -236,6 +261,9 @@ public void onClick(HexSpatial hex) {

LOG.log(Level.INFO, "HexCoord(!selected): {0}", hex.getCoord());
}



}

/**
Expand Down

0 comments on commit 4c837f1

Please sign in to comment.