From dd8ef49694c02351e013d49a6d7c72ebea01ef57 Mon Sep 17 00:00:00 2001 From: Leon Palluch Date: Mon, 27 Jan 2020 17:52:40 +0100 Subject: [PATCH 1/2] walls walls walls --- Level/InFactory.tscn | 108 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 21 deletions(-) diff --git a/Level/InFactory.tscn b/Level/InFactory.tscn index 6e9f866..b0fe6c8 100644 --- a/Level/InFactory.tscn +++ b/Level/InFactory.tscn @@ -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 ) [node name="Door" parent="Architecture/FactoryRoomWalls/BackWallTrue" instance=ExtResource( 5 )] +editor/display_folded = true collision_layer = 3 collision_mask = 3 invert_open = true @@ -235,6 +236,7 @@ card_door = true door_lvl = 1 [node name="DoorMesh" parent="Architecture/FactoryRoomWalls/BackWallTrue/Door" index="0"] +editor/display_folded = true layers = 2 [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 )] 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 -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 -[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall"] +[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall"] layers = 3 mesh = SubResource( 4 ) material/0 = null -[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall"] +[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall"] shape = SubResource( 5 ) -[node name="Wall2" type="StaticBody" parent="Architecture/Hallway"] +[node name="Wall2" type="StaticBody" parent="Architecture/OfficeSpace"] editor/display_folded = true transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 3, -10.3, 2, -36.8 ) collision_layer = 3 -[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall2"] +[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall2"] layers = 3 mesh = SubResource( 4 ) material/0 = null -[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall2"] +[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall2"] shape = SubResource( 5 ) -[node name="Wall3" type="StaticBody" parent="Architecture/Hallway"] +[node name="Wall3" type="StaticBody" parent="Architecture/OfficeSpace"] editor/display_folded = true transform = Transform( 0.2, 0, 0, 0, 2, 0, 0, 0, 1.5, -6.8, 2, -38.2 ) collision_layer = 3 -[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall3"] +[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall3"] layers = 3 mesh = SubResource( 4 ) material/0 = null -[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall3"] +[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall3"] shape = SubResource( 5 ) -[node name="Wall4" type="StaticBody" parent="Architecture/Hallway"] +[node name="Wall4" type="StaticBody" parent="Architecture/OfficeSpace"] editor/display_folded = true transform = Transform( 0.3, 0, 0, 0, 2, 0, 0, 0, 0.2, -7.25, 2, -39.4 ) collision_layer = 3 -[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall4"] +[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall4"] layers = 3 mesh = SubResource( 4 ) material/0 = null -[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall4"] +[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall4"] shape = SubResource( 5 ) -[node name="Wall5" type="StaticBody" parent="Architecture/Hallway"] +[node name="Wall5" type="StaticBody" parent="Architecture/OfficeSpace"] editor/display_folded = true transform = Transform( 0.3, 0, 0, 0, 2, 0, 0, 0, 0.2, -9.85, 2, -39.4 ) collision_layer = 3 -[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall5"] +[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall5"] layers = 3 mesh = SubResource( 4 ) material/0 = null -[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall5"] +[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall5"] shape = SubResource( 5 ) -[node name="Wall6" type="StaticBody" parent="Architecture/Hallway"] +[node name="Wall6" type="StaticBody" parent="Architecture/OfficeSpace"] editor/display_folded = true transform = Transform( 1, 0, 0, 0, 0.5, 0, 0, 0, 0.2, -8.55, 3.5, -39.4 ) collision_layer = 3 -[node name="MeshInstance" type="MeshInstance" parent="Architecture/Hallway/Wall6"] +[node name="MeshInstance" type="MeshInstance" parent="Architecture/OfficeSpace/Wall6"] layers = 3 mesh = SubResource( 4 ) material/0 = null -[node name="CollisionShape" type="CollisionShape" parent="Architecture/Hallway/Wall6"] +[node name="CollisionShape" type="CollisionShape" parent="Architecture/OfficeSpace/Wall6"] 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 ) invert_open = true card_door = true From 8a47c8f64f2a8a509053548c2ea7441948e082c4 Mon Sep 17 00:00:00 2001 From: Ententerminator Date: Mon, 27 Jan 2020 17:54:28 +0100 Subject: [PATCH 2/2] sun upper & sun downer --- Characters/Player/Player.tscn | 4 +- Characters/Player/UI/UI.gd | 6 +-- Global/Daytime.gd | 3 +- Global/Environment.gd | 73 +++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 Global/Environment.gd diff --git a/Characters/Player/Player.tscn b/Characters/Player/Player.tscn index cb160aa..224ab07 100644 --- a/Characters/Player/Player.tscn +++ b/Characters/Player/Player.tscn @@ -175,7 +175,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0461721, 1.84617, 0 ) script = ExtResource( 2 ) [node name="LookingAt" type="RayCast" parent="Body/PillCameras"] -transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0 ) +transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 0, 0 ) enabled = true cast_to = Vector3( 0, 0, 2 ) @@ -273,7 +273,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 ) script = ExtResource( 11 ) [node name="Pills" parent="PillTaker" instance=ExtResource( 12 )] -transform = Transform( 0.1, 0, 0, 0, -4.37114e-09, 0.1, 0, -0.1, -4.37114e-09, 0, 0.7, 0 ) +transform = Transform( 0.1, 0, 0, 0, -4.37114e-009, 0.1, 0, -0.1, -4.37114e-009, 0, 0.7, 0 ) visible = false [editable path="HUD"] diff --git a/Characters/Player/UI/UI.gd b/Characters/Player/UI/UI.gd index 842480f..de0bf77 100644 --- a/Characters/Player/UI/UI.gd +++ b/Characters/Player/UI/UI.gd @@ -42,8 +42,8 @@ func _process(_delta): _labelPillLevel.text = "curLevel: " + String(Pills.get_level()) _pillLevel.value = Pills.get_level() var val = int(Daytime.get_time()) - _labelDayTime.text = "dayTime: " + String(val) + " - %02d:%02d" % [val/60%24, val%60] - _dayTime.value = Daytime.get_time() + #_labelDayTime.text = "dayTime: " + String(val) + " - %02d:%02d" % [val/60%24, val%60] + _dayTime.value = val - _dayTimeVisual.rect_rotation = (val/_dayTime.max_value) * 360 + _dayTimeVisual.rect_rotation = ((val/_dayTime.max_value) * 180) - 90 \ No newline at end of file diff --git a/Global/Daytime.gd b/Global/Daytime.gd index 0f8789f..489181c 100644 --- a/Global/Daytime.gd +++ b/Global/Daytime.gd @@ -1,6 +1,7 @@ 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 SLEEP_TIME = _max * 0.6 diff --git a/Global/Environment.gd b/Global/Environment.gd new file mode 100644 index 0000000..5087f15 --- /dev/null +++ b/Global/Environment.gd @@ -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 \ No newline at end of file