implemented PlayerBase.pickZPM() (former pickItem()) callback method

This commit is contained in:
Kjistóf 2016-04-24 22:48:17 +02:00
parent 69a2384160
commit d0d656452c
3 changed files with 15 additions and 6 deletions

View File

@ -25,7 +25,7 @@ public class Field extends cicaprojekt.Tile
return; return;
playerBase.setCurrentTile(this); playerBase.setCurrentTile(this);
if(zpmOnTile != null) if(zpmOnTile != null)
playerBase.pickItem(); playerBase.pickZPM(this);
} }
public void onExit(PlayerBase playerBase) { public void onExit(PlayerBase playerBase) {

View File

@ -1,5 +1,6 @@
package cicaprojekt; package cicaprojekt;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Player extends PlayerBase{ public class Player extends PlayerBase{
@ -8,6 +9,7 @@ public class Player extends PlayerBase{
public Player(Tile startTile, Direction startDirection){ public Player(Tile startTile, Direction startDirection){
zpmContainer = new ArrayList<>();
currentTile = startTile; currentTile = startTile;
facingDirection = startDirection; /* Be lehetne állítani egy defaultot is, nem tudom, mennyire kéne */ facingDirection = startDirection; /* Be lehetne állítani egy defaultot is, nem tudom, mennyire kéne */
} }
@ -21,6 +23,12 @@ public class Player extends PlayerBase{
boxLifted = null; boxLifted = null;
} }
@Override
public void pickZPM(Tile tile)
{
zpmContainer.add(tile.getZPMFromTile());
}
public void shootStargate(Stargate stargate) { public void shootStargate(Stargate stargate) {
this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection); this.currentTile.getAdjacentTile(facingDirection).spawnStargate(stargate, facingDirection);
} }

View File

@ -6,8 +6,7 @@ public class PlayerBase implements Destroyable{
protected Direction facingDirection; protected Direction facingDirection;
public void destroy() { public void destroy() {}
}
public Tile getCurrentTile() { public Tile getCurrentTile() {
return currentTile; return currentTile;
@ -20,10 +19,12 @@ public class PlayerBase implements Destroyable{
public void move(Direction direction) { public void move(Direction direction) {
this.setFacingDirection(direction); this.setFacingDirection(direction);
Tile tile = this.getCurrentTile().getAdjacentTile(direction); Tile tile = this.getCurrentTile().getAdjacentTile(direction);
tile.onEntry(); tile.onEntry(this);
setCurrentTile(tile); setCurrentTile(tile);
} }
public void pickZPM(Tile tile) { /* PlayerBase does not collect ZPM modules */ }
public void rotateLeft() { public void rotateLeft() {
switch (facingDirection) { switch (facingDirection) {
case NORTH: case NORTH: