main
Brett 2023-03-02 13:19:34 -05:00
parent 9a7aa7c6b3
commit 0495018430
6 changed files with 31 additions and 18 deletions

View File

@ -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) {}
}

View File

@ -11,6 +11,6 @@ public class IronMine extends ResourceBuilding {
@Override
public void harvest(Village_Hall hall) {
hall.addCurrentIron(getHarvestRate());
}
}

View File

@ -10,7 +10,7 @@ public class LumberMine extends ResourceBuilding {
}
public void harvest(Village_Hall hall) {
hall.addCurrentWood(getHarvestRate());
}
}

View File

@ -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;
}
}

View File

@ -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());
}
}

View File

@ -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() {