This commit is contained in:
karl 2020-01-27 18:04:49 +01:00
commit a8d78f70fe
4 changed files with 165 additions and 25 deletions

View File

@ -42,8 +42,8 @@ func _process(_delta):
_labelPillLevel.text = "curLevel: " + String(Pills.get_level()) _labelPillLevel.text = "curLevel: " + String(Pills.get_level())
_pillLevel.value = Pills.get_level() _pillLevel.value = Pills.get_level()
var val = int(Daytime.get_time()) var val = int(Daytime.get_time())
_labelDayTime.text = "dayTime: " + String(val) + " - %02d:%02d" % [val/60%24, val%60] #_labelDayTime.text = "dayTime: " + String(val) + " - %02d:%02d" % [val/60%24, val%60]
_dayTime.value = Daytime.get_time() _dayTime.value = val
_dayTimeVisual.rect_rotation = (val/_dayTime.max_value) * 360 _dayTimeVisual.rect_rotation = ((val/_dayTime.max_value) * 180) - 90

View File

@ -1,6 +1,7 @@
extends Node extends Node
const _max: int = 1440 # 24 hour + 60 mins #const _max: int = 1440 # 24 hour + 60 mins
const _max: int = 100
const WORK_TIME = _max * 0.3 const WORK_TIME = _max * 0.3
const SLEEP_TIME = _max * 0.6 const SLEEP_TIME = _max * 0.6

73
Global/Environment.gd Normal file
View File

@ -0,0 +1,73 @@
extends Spatial
#const
const LONGITUDE: int = -90 # we are on equator
const SUNRISE: Color = Color("ffdb00")
const SUNSET: Color = Color("ffdb00")
const STANDARD_SKY_TOP: Color = Color("a5d6f1") #godots standard sky top color
const SUNRISE_DEGREE: int = 15 #until this degree is sunset color
const RISE_INTERPOL: int = SUNRISE_DEGREE + 15 #until this degree, sunrise interpolates to day
const SUNSET_DEGREE: int = 170 #from this degree on is sunset color
const SET_INTERPOL: int = SUNSET_DEGREE - 15 #until this degree, day interpolates to sunset
#private members
var _worldEnvironment: WorldEnvironment
var _light: DirectionalLight
var _max: float #max Daytime
var _currentTime: float
var _degree: float #current degrees of sun & light ((currentTime/maxTime) * 180)
#var _standardSkyHorizon: Color = Color("d6eafa") #godots standard sky horizon color
var _setSkyColor: Color #for setting current skycolor
# Called when the node enters the scene tree for the first time.
func _ready():
#assign children
_worldEnvironment = get_node("WorldEnvironment")
assert(null != _worldEnvironment)
_light = get_node("DirectionalLight")
assert(null != _light)
#set values
_worldEnvironment.environment.background_sky.sun_longitude = LONGITUDE
#get values (from the other side - adele)
_max = Daytime.get_max()
func _process(_delta):
_currentTime = Daytime.get_time()
_degree = (_currentTime/_max) * 180
_sun_position()
_light_rotation()
_sky_light()
#update sun position
func _sun_position():
_worldEnvironment.environment.background_sky.sun_latitude = _degree
#update light position to sun position
func _light_rotation():
_light.rotation_degrees = Vector3(-(_degree), LONGITUDE, 0)
#set light color depending on daytime
func _sky_light():
if _degree <= SUNRISE_DEGREE:
#_worldEnvironment.environment.background_sky.sky_curve = 1
_setSkyColor = SUNRISE
elif _degree > SUNRISE_DEGREE and _degree < RISE_INTERPOL: #interpolate colors from sunrise sky to daytime sky
_setSkyColor = SUNRISE.linear_interpolate(STANDARD_SKY_TOP, ((_degree-SUNRISE_DEGREE)/(RISE_INTERPOL-SUNRISE_DEGREE)))
elif _degree >= RISE_INTERPOL and _degree <= SET_INTERPOL:
#_worldEnvironment.environment.background_sky.sky_curve = 0.09
_setSkyColor = STANDARD_SKY_TOP
elif _degree > SET_INTERPOL and _degree < SUNSET_DEGREE: #interpolate colors from daytime sky to sunset sky
_setSkyColor = STANDARD_SKY_TOP.linear_interpolate(SUNSET, ((_degree-SET_INTERPOL)/(SUNSET_DEGREE-SET_INTERPOL)))
elif _degree >= SUNSET_DEGREE:
_setSkyColor = SUNSET
_worldEnvironment.environment.background_sky.sky_horizon_color = _setSkyColor

View File

@ -228,6 +228,7 @@ shape = SubResource( 5 )
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 8, 1.5, -33.8 ) transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 8, 1.5, -33.8 )
[node name="Door" parent="Architecture/FactoryRoomWalls/BackWallTrue" instance=ExtResource( 5 )] [node name="Door" parent="Architecture/FactoryRoomWalls/BackWallTrue" instance=ExtResource( 5 )]
editor/display_folded = true
collision_layer = 3 collision_layer = 3
collision_mask = 3 collision_mask = 3
invert_open = true invert_open = true
@ -235,6 +236,7 @@ card_door = true
door_lvl = 1 door_lvl = 1
[node name="DoorMesh" parent="Architecture/FactoryRoomWalls/BackWallTrue/Door" index="0"] [node name="DoorMesh" parent="Architecture/FactoryRoomWalls/BackWallTrue/Door" index="0"]
editor/display_folded = true
layers = 2 layers = 2
[node name="Outline" parent="Architecture/FactoryRoomWalls/BackWallTrue/Door/DoorMesh" index="0"] [node name="Outline" parent="Architecture/FactoryRoomWalls/BackWallTrue/Door/DoorMesh" index="0"]
@ -281,87 +283,151 @@ shape = SubResource( 5 )
[node name="Statue" parent="Architecture/FactoryRoomInterior" instance=ExtResource( 7 )] [node name="Statue" parent="Architecture/FactoryRoomInterior" instance=ExtResource( 7 )]
transform = Transform( -7.86805e-008, 0, -2.5, 0, 1.8, 0, 1.8, 0, -1.09278e-007, 9.5, 0.5, -25.8 ) transform = Transform( -7.86805e-008, 0, -2.5, 0, 1.8, 0, 1.8, 0, -1.09278e-007, 9.5, 0.5, -25.8 )
[node name="Hallway" type="Spatial" parent="Architecture"] [node name="OfficeSpace" type="Spatial" parent="Architecture"]
[node name="Wall" type="StaticBody" parent="Architecture/Hallway"] [node name="Wall" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true editor/display_folded = true
transform = Transform( 11, 0, 0, 0, 2, 0, 0, 0, 0.2, 4, 2, -36.8 ) transform = Transform( 23, 0, 0, 0, 2, 0, 0, 0, 0.2, 16, 2, -36.8 )
collision_layer = 3 collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall"] [node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall"]
layers = 3 layers = 3
mesh = SubResource( 4 ) mesh = SubResource( 4 )
material/0 = null material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall"]
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="Wall2" type="StaticBody" parent="Architecture/Hallway"] [node name="Wall2" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true editor/display_folded = true
transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 3, -10.3, 2, -36.8 ) transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 3, -10.3, 2, -36.8 )
collision_layer = 3 collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall2"] [node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall2"]
layers = 3 layers = 3
mesh = SubResource( 4 ) mesh = SubResource( 4 )
material/0 = null material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall2"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall2"]
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="Wall3" type="StaticBody" parent="Architecture/Hallway"] [node name="Wall3" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true editor/display_folded = true
transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 1.5, -6.8, 2, -38.2 ) transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 1.5, -6.8, 2, -38.2 )
collision_layer = 3 collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall3"] [node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall3"]
layers = 3 layers = 3
mesh = SubResource( 4 ) mesh = SubResource( 4 )
material/0 = null material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall3"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall3"]
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="Wall4" type="StaticBody" parent="Architecture/Hallway"] [node name="Wall4" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true editor/display_folded = true
transform = Transform( 0.3, 0, 0, 0, 2, 0, 0, 0, 0.2, -7.25, 2, -39.4 ) transform = Transform( 0.3, 0, 0, 0, 2, 0, 0, 0, 0.2, -7.25, 2, -39.4 )
collision_layer = 3 collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall4"] [node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall4"]
layers = 3 layers = 3
mesh = SubResource( 4 ) mesh = SubResource( 4 )
material/0 = null material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall4"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall4"]
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="Wall5" type="StaticBody" parent="Architecture/Hallway"] [node name="Wall5" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true editor/display_folded = true
transform = Transform( 0.3, 0, 0, 0, 2, 0, 0, 0, 0.2, -9.85, 2, -39.4 ) transform = Transform( 0.3, 0, 0, 0, 2, 0, 0, 0, 0.2, -9.85, 2, -39.4 )
collision_layer = 3 collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall5"] [node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall5"]
layers = 3 layers = 3
mesh = SubResource( 4 ) mesh = SubResource( 4 )
material/0 = null material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall5"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall5"]
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="Wall6" type="StaticBody" parent="Architecture/Hallway"] [node name="Wall6" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true editor/display_folded = true
transform = Transform( 1, 0, 0, 0, 0.5, 0, 0, 0, 0.2, -8.55, 3.5, -39.4 ) transform = Transform( 1, 0, 0, 0, 0.5, 0, 0, 0, 0.2, -8.55, 3.5, -39.4 )
collision_layer = 3 collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall6"] [node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall6"]
layers = 3 layers = 3
mesh = SubResource( 4 ) mesh = SubResource( 4 )
material/0 = null material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall6"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall6"]
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="Door" parent="Architecture/Hallway" instance=ExtResource( 5 )] [node name="Wall7" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true
transform = Transform( 4, 0, 0, 0, 2, 0, 0, 0, 0.2, 16, 2, -33.8 )
collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall7"]
layers = 3
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall7"]
shape = SubResource( 5 )
[node name="Wall8" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true
transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 16.5, 38.8, 2, -20.5 )
collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall8"]
layers = 3
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall8"]
shape = SubResource( 5 )
[node name="Wall9" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true
transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 6.8, 11.8, 2, -10.8 )
collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall9"]
layers = 3
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall9"]
shape = SubResource( 5 )
[node name="Wall10" type="StaticBody" parent="Architecture/OfficeSpace"]
transform = Transform( 13.5, 0, 0, 0, 2, 0, 0, 0, 0.2, 25.2, 2, -4.2 )
collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall10"]
layers = 3
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall10"]
shape = SubResource( 5 )
[node name="Ceiling" type="StaticBody" parent="Architecture/OfficeSpace"]
editor/display_folded = true
transform = Transform( 15.2, 0, 0, 0, 0.2, 0, 0, 0, 3, 4.8, 3.8, -36.8 )
collision_layer = 3
[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Ceiling"]
layers = 3
mesh = SubResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Ceiling"]
shape = SubResource( 5 )
[node name="Door" parent="Architecture/OfficeSpace" instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -9.55, 1.5, -39.5 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -9.55, 1.5, -39.5 )
invert_open = true invert_open = true
card_door = true card_door = true