Don't deactivate the portal if a gem wasn't purified
Signed-off-by: Chris Cromer <chris@cromer.cl>
This commit is contained in:
parent
c32efe7db0
commit
5b8e36876c
@ -369,7 +369,7 @@ public class Canvas extends java.awt.Canvas implements Constants {
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Gem> gems = player.getInventoryGems();
|
||||
ArrayList<Gem> gems = player.getInventoryGems(false);
|
||||
for (Gem gem : gems) {
|
||||
gem.drawAnimation(graphicBuffer, xPixels, 8);
|
||||
xPixels = xPixels + 3 + (gem.getAnimationWidth());
|
||||
|
@ -82,7 +82,7 @@ public class Player extends Object implements Constants {
|
||||
*/
|
||||
public void keyPressed(int keyCode) {
|
||||
if (getScene().isDoorOpen()) {
|
||||
ArrayList<Gem> gems = getInventoryGems();
|
||||
ArrayList<Gem> gems = getInventoryGems(true);
|
||||
if (gems.size() < 2) {
|
||||
getScene().openDoor(false);
|
||||
}
|
||||
@ -485,13 +485,17 @@ public class Player extends Object implements Constants {
|
||||
/**
|
||||
* Get the gems the player has
|
||||
*
|
||||
* @param all Whether or not to return the gems that are still in transition to inventory
|
||||
* @return Returns an array of the gems the player is carrying
|
||||
*/
|
||||
public ArrayList<Gem> getInventoryGems() {
|
||||
public ArrayList<Gem> getInventoryGems(boolean all) {
|
||||
ArrayList<Gem> gems = new ArrayList<>();
|
||||
for (Object object : carrying) {
|
||||
if (object instanceof Gem && object.getCell().getObjectOnTop() == null) {
|
||||
// Only count the gem as in inventory once it stops showing
|
||||
if (object instanceof Gem) {
|
||||
if (!all && object.getCell().getObjectOnTop() != null) {
|
||||
// Only count the gem as in inventory once it stops showing
|
||||
continue;
|
||||
}
|
||||
gems.add((Gem) object);
|
||||
}
|
||||
}
|
||||
|
@ -92,15 +92,21 @@ public class Portal extends Object implements Constants {
|
||||
*/
|
||||
public void purifyGems() {
|
||||
if (state == State.ACTIVE) {
|
||||
ArrayList<Gem> gems = getScene().getCanvas().getPlayer().getInventoryGems();
|
||||
ArrayList<Gem> gems = getScene().getCanvas().getPlayer().getInventoryGems(true);
|
||||
boolean purified = false;
|
||||
for (Gem gem : gems) {
|
||||
if (gem.getState() == Gem.State.TAINTED) {
|
||||
gem.setState(Gem.State.PURIFIED);
|
||||
getScene().getCanvas().getPlayer().gainHealth(2);
|
||||
if (!purified) {
|
||||
purified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(State.INACTIVE);
|
||||
playPortalSound();
|
||||
if (purified) {
|
||||
setState(State.INACTIVE);
|
||||
playPortalSound();
|
||||
}
|
||||
if (gems.size() == 2) {
|
||||
getScene().openDoor(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user