Change initial world time
This commit is contained in:
5
data.sql
5
data.sql
@@ -107,12 +107,13 @@ CREATE MEMORY TABLE "PUBLIC"."CONFIG"(
|
||||
"VALUE" VARCHAR
|
||||
);
|
||||
ALTER TABLE "PUBLIC"."CONFIG" ADD CONSTRAINT "PUBLIC"."CONSTRAINT_7" PRIMARY KEY("KEY");
|
||||
-- 4 +/- SELECT COUNT(*) FROM PUBLIC.CONFIG;
|
||||
-- 5 +/- SELECT COUNT(*) FROM PUBLIC.CONFIG;
|
||||
INSERT INTO "PUBLIC"."CONFIG" VALUES
|
||||
('start_game', 'Hero Home,Main,Start'),
|
||||
('screen', '1000x800'),
|
||||
('camera_scale', '2'),
|
||||
('full_day_duration', '600');
|
||||
('full_day_duration', '600'),
|
||||
('initial_time', '08:30');
|
||||
CREATE MEMORY TABLE "PUBLIC"."LEVELS"(
|
||||
"LEVEL" INT DEFAULT NEXT VALUE FOR "PUBLIC"."SYSTEM_SEQUENCE_704587BB_DC0E_44AB_A7F0_3DE0CA44FE3F" NOT NULL NULL_TO_DEFAULT SEQUENCE "PUBLIC"."SYSTEM_SEQUENCE_704587BB_DC0E_44AB_A7F0_3DE0CA44FE3F",
|
||||
"MAX_HP" VARCHAR NOT NULL
|
||||
|
||||
@@ -74,13 +74,13 @@ public class DemoRunner implements GameRunner {
|
||||
var layer = map.layer(start[1]);
|
||||
var label = layer.label(start[2]);
|
||||
|
||||
time.setTime(dao.config.find("initial_time").getValue());
|
||||
|
||||
context.openMap(map.$);
|
||||
context.getMap().getObjectLayer(layer.$).addEntity(this.player);
|
||||
player.setCoordinates(label.getX(), label.getY());
|
||||
context.resume();
|
||||
hud.show();
|
||||
|
||||
var x = A.maps.hero_home.main.entry;
|
||||
}
|
||||
|
||||
public void returnToStartMenu() {
|
||||
|
||||
@@ -6,7 +6,11 @@ import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
import static java.lang.Math.min;
|
||||
|
||||
public class WorldTime {
|
||||
private static final float MINUTES_PER_DAY = 1440f; // 60min * 24
|
||||
|
||||
@Getter
|
||||
private float progress = 0;
|
||||
@@ -18,6 +22,19 @@ public class WorldTime {
|
||||
this.period = Float.parseFloat(dao.config.find("full_day_duration").getValue());
|
||||
}
|
||||
|
||||
public void setProgress(float progress) {
|
||||
this.progress = max(0, min(1, progress));
|
||||
}
|
||||
|
||||
public void setTime(@NonNull String time) {
|
||||
var splitted = time.split(":");
|
||||
this.setTime(Integer.valueOf(splitted[0], 10), Integer.valueOf(splitted[1], 10));
|
||||
}
|
||||
|
||||
public void setTime(int h, int m) {
|
||||
this.progress = (h * 60 + m) / MINUTES_PER_DAY;
|
||||
}
|
||||
|
||||
public int getHour() {
|
||||
return (int) (progress * 24);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user