mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-15 23:59:09 +00:00
Merge a3064ef8d6 into 6fc583d6f0
This commit is contained in:
@@ -44,6 +44,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
private int energy;
|
||||
private int maxEnergy;
|
||||
|
||||
private int jumpDistance;
|
||||
|
||||
private static final float SOLAR_PANEL_MULTIPLIER = 1;
|
||||
private static final int CONSOLE_BUFFER_MAX_SIZE = 40;
|
||||
|
||||
@@ -63,13 +65,22 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
|
||||
if (currentAction == Action.WALKING) {
|
||||
if (spendEnergy(100)) {
|
||||
if (!incrementLocation()) {
|
||||
if (!incrementLocation(1)) {
|
||||
//Couldn't walk
|
||||
currentAction = Action.IDLE;
|
||||
}
|
||||
} else {
|
||||
currentAction = Action.IDLE;
|
||||
}
|
||||
} else if (currentAction == Action.JUMPING) {
|
||||
if (spendEnergy(jumpDistance * 300)) {
|
||||
if (!incrementLocation(jumpDistance)) {
|
||||
//Couldn't jump
|
||||
currentAction = Action.IDLE;
|
||||
}
|
||||
} else {
|
||||
currentAction = Action.IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -165,6 +176,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
return heldItem;
|
||||
}
|
||||
|
||||
public void setJumpDistance(int jumpDistance) {
|
||||
this.jumpDistance = jumpDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyboardBuffer(ArrayList<Integer> kbBuffer) {
|
||||
keyboardBuffer = kbBuffer;
|
||||
|
||||
@@ -18,6 +18,7 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable {
|
||||
|
||||
private static final int LEGS_SET_DIR = 1;
|
||||
private static final int LEGS_SET_DIR_AND_WALK = 2;
|
||||
private static final int LEGS_JUMP = 3;
|
||||
|
||||
/**
|
||||
* Hardware ID (Should be unique)
|
||||
@@ -72,6 +73,15 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable {
|
||||
cubot.setCurrentAction(Action.WALKING);
|
||||
}
|
||||
}
|
||||
} else if (a == LEGS_JUMP) {
|
||||
// jump up to 3 spaces, each space costs 300
|
||||
if (b < 4 && cubot.getMaxEnergy() >= b * 300) {
|
||||
cubot.setJumpDistance(b);
|
||||
cubot.setCurrentAction(Action.JUMPING);
|
||||
status.setErrorFlag(false);
|
||||
} else {
|
||||
status.setErrorFlag(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user