reformat
parent
9a7aa7c6b3
commit
0495018430
|
@ -8,11 +8,9 @@ public class Farm extends ResourceBuilding {
|
|||
}
|
||||
|
||||
public int getPopulationContribution() {
|
||||
return 0;
|
||||
return getHarvestRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvest(Village_Hall hall) {
|
||||
|
||||
}
|
||||
public void harvest(Village_Hall hall) {}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ public class IronMine extends ResourceBuilding {
|
|||
|
||||
@Override
|
||||
public void harvest(Village_Hall hall) {
|
||||
|
||||
hall.addCurrentIron(getHarvestRate());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class LumberMine extends ResourceBuilding {
|
|||
}
|
||||
|
||||
public void harvest(Village_Hall hall) {
|
||||
|
||||
hall.addCurrentWood(getHarvestRate());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,36 @@
|
|||
package ca.cosc3p91.a2.gameobjects;
|
||||
|
||||
import ca.cosc3p91.a2.util.Time;
|
||||
|
||||
public abstract class ResourceBuilding extends Building {
|
||||
|
||||
public static String resource;
|
||||
|
||||
private final Time harvestMinTime = new Time().offsetSeconds(10);
|
||||
|
||||
private int harvest_rate;
|
||||
private Time nextHarvestTime;
|
||||
|
||||
public ResourceBuilding() {
|
||||
nextHarvestTime = Time.getTime().offsetTime(harvestMinTime);
|
||||
}
|
||||
|
||||
public void upgrade(ResourceStage stage) {
|
||||
super.upgrade(stage);
|
||||
this.harvest_rate += stage.getHarvestRateIncrease();
|
||||
}
|
||||
|
||||
public abstract void harvest(Village_Hall hall);
|
||||
public void update(Village_Hall hall){
|
||||
if (nextHarvestTime.occurred()){
|
||||
harvest(hall);
|
||||
nextHarvestTime = Time.getTime().offsetTime(harvestMinTime);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void harvest(Village_Hall hall);
|
||||
|
||||
public int getHarvestRate(){
|
||||
return harvest_rate;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ca.cosc3p91.a2.gameobjects;
|
||||
|
||||
import ca.cosc3p91.a2.util.Time;
|
||||
|
||||
public class SaulGoodMine extends ResourceBuilding {
|
||||
|
||||
public static String resource = "gold";
|
||||
|
@ -11,6 +13,6 @@ public class SaulGoodMine extends ResourceBuilding {
|
|||
|
||||
@Override
|
||||
public void harvest(Village_Hall hall) {
|
||||
|
||||
hall.addCurrentGold(getHarvestRate());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,16 +37,8 @@ public class Time {
|
|||
return timeSeconds;
|
||||
}
|
||||
|
||||
public static class FutureTime {
|
||||
private final Time futureTime;
|
||||
|
||||
public FutureTime(Time futureTime) {
|
||||
this.futureTime = futureTime;
|
||||
}
|
||||
|
||||
public boolean occurred() {
|
||||
return getTime().timeSeconds >= futureTime.timeSeconds;
|
||||
}
|
||||
return getTime().timeSeconds >= timeSeconds;
|
||||
}
|
||||
|
||||
public static Time getTime() {
|
||||
|
|
Loading…
Reference in New Issue