mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 22:59:02 +00:00
Added Passive energy source for Cubots #14
This commit is contained in:
@@ -34,6 +34,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
private int energy;
|
||||
private int maxEnergy;
|
||||
|
||||
private static final float SOLAR_PANEL_MULTIPLIER = 1;
|
||||
|
||||
public Cubot() {
|
||||
|
||||
}
|
||||
@@ -46,6 +48,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
storeEnergy((int) (SOLAR_PANEL_MULTIPLIER * GameServer.INSTANCE.getDayNightCycle().getSunIntensity()));
|
||||
|
||||
if (currentAction == Action.WALKING) {
|
||||
if (spendEnergy(100)) {
|
||||
if (!incrementLocation()) {
|
||||
@@ -170,7 +174,11 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
energy -= spent;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void storeEnergy(int qty) {
|
||||
|
||||
energy = Math.min(energy + qty, maxEnergy);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user