sun upper & sun downer
This commit is contained in:
parent
a51eec71b1
commit
8a47c8f64f
@ -175,7 +175,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0461721, 1.84617, 0 )
|
|||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="LookingAt" type="RayCast" parent="Body/PillCameras"]
|
[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
|
enabled = true
|
||||||
cast_to = Vector3( 0, 0, 2 )
|
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 )
|
script = ExtResource( 11 )
|
||||||
|
|
||||||
[node name="Pills" parent="PillTaker" instance=ExtResource( 12 )]
|
[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
|
visible = false
|
||||||
|
|
||||||
[editable path="HUD"]
|
[editable path="HUD"]
|
||||||
|
@ -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
|
||||||
|
|
@ -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
73
Global/Environment.gd
Normal 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
|
Loading…
x
Reference in New Issue
Block a user