2022-06-17 09:09:23 +02:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
|
|
|
|
# Declare member variables here. Examples:
|
|
|
|
# var a = 2
|
|
|
|
# var b = "text"
|
|
|
|
|
|
|
|
var wantToQuit = false
|
|
|
|
|
|
|
|
var mood = 0 #[-1,+1]
|
|
|
|
|
|
|
|
#taken pills that effects current state
|
|
|
|
var antiDep = 0
|
|
|
|
var moodStab = 0
|
|
|
|
|
|
|
|
var vision
|
|
|
|
var player
|
|
|
|
|
|
|
|
var averageDownPhase = 3
|
|
|
|
var averageUpPhase = 2
|
|
|
|
var averageStable = 2
|
|
|
|
|
|
|
|
var stableTimer
|
|
|
|
var maniaTimer
|
|
|
|
var depressionTimer
|
|
|
|
|
|
|
|
#var moodStabilizerTimer
|
|
|
|
#var antiDepressantTimer
|
|
|
|
|
|
|
|
var secondsPerWeek = 10
|
|
|
|
|
|
|
|
var rng = RandomNumberGenerator.new()
|
|
|
|
|
|
|
|
var hudMood
|
|
|
|
var hudAnti
|
|
|
|
var hudStab
|
|
|
|
|
|
|
|
var takingPill = false
|
|
|
|
|
|
|
|
#smoothing curves points
|
|
|
|
var p0 = 0
|
|
|
|
var p1 = 0
|
|
|
|
|
|
|
|
var t = 0.0
|
|
|
|
|
|
|
|
|
|
|
|
var sun
|
|
|
|
|
2022-06-20 10:06:58 +02:00
|
|
|
var theEnd
|
|
|
|
|
2022-06-17 09:09:23 +02:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
vision = $Player/CameraPivot/Camera
|
|
|
|
player = $Player
|
|
|
|
sun = $Lighting/Sun
|
|
|
|
hudMood = $HUD/debug/Mood
|
|
|
|
hudAnti = $HUD/debug/AntiDepActive
|
|
|
|
hudStab = $HUD/debug/MoodStabActive
|
|
|
|
|
|
|
|
|
|
|
|
stableTimer = $Timer/StableTimer
|
|
|
|
maniaTimer = $Timer/ManiaTimer
|
|
|
|
depressionTimer = $Timer/DepressionTimer
|
|
|
|
|
|
|
|
# moodStabilizerTimer = $Collectibles/MoodStabilizer/Timer
|
|
|
|
# antiDepressantTimer = $Collectibles/AntiDepressant/Timer
|
|
|
|
|
|
|
|
|
|
|
|
#add_child(stableTimer)
|
|
|
|
#add_child(maniaTimer)
|
|
|
|
#add_child(depressionTimer)
|
|
|
|
# add_child(moodStabilizerTimer)
|
|
|
|
# add_child(antiDepressantTimer)
|
|
|
|
|
|
|
|
stableTimer.connect("timeout", self, "_on_StableTimer_timeout")
|
|
|
|
maniaTimer.connect("timeout", self, "_on_ManiaTimer_timeout")
|
|
|
|
depressionTimer.connect("timeout", self, "_on_DepressionTimer_timeout")
|
|
|
|
# moodStabilizerTimer.connect("timeout", self, "_on_MoodStabilizerTimer_timeout")
|
|
|
|
# antiDepressantTimer.connect("timeout", self, "_on_AntiDepressantTimer_timeout")
|
2022-06-20 10:06:58 +02:00
|
|
|
|
2022-06-17 09:09:23 +02:00
|
|
|
stableTimer.set_wait_time(secondsPerWeek*averageStable+rng.randf_range(-secondsPerWeek/5,+secondsPerWeek/5))
|
|
|
|
stableTimer.start()
|
|
|
|
print("stabletimer started with waitime: ",stableTimer.get_wait_time())
|
2022-06-20 10:06:58 +02:00
|
|
|
|
|
|
|
theEnd = $HUD/AcceptDialog
|
2022-06-17 09:09:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _input(event):
|
|
|
|
if Input.is_action_pressed("click"):
|
|
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
|
|
|
wantToQuit = false
|
|
|
|
|
|
|
|
if Input.is_action_just_released("depression"):
|
|
|
|
#take antidepressend
|
|
|
|
if(takingPill):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if(player.getAntiDepressant()>0):
|
|
|
|
player.takeAntiDepressant()
|
|
|
|
antiDep = antiDep + 1
|
|
|
|
var antiDepressantTimer = Timer.new()
|
|
|
|
antiDepressantTimer.one_shot = true
|
|
|
|
antiDepressantTimer.set_wait_time(secondsPerWeek*averageDownPhase/2)
|
|
|
|
add_child(antiDepressantTimer)
|
|
|
|
antiDepressantTimer.connect("timeout", self, "_on_AntiDepressantTimer_timeout")
|
|
|
|
antiDepressantTimer.start()
|
|
|
|
print("antiDepressantTimer started with waitime: ",antiDepressantTimer.get_wait_time())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
takingPill = true
|
|
|
|
yield(get_tree().create_timer(1.0), "timeout")
|
|
|
|
takingPill = false
|
|
|
|
|
|
|
|
if Input.is_action_just_released("mania"):
|
|
|
|
if(takingPill):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if(player.getMoodStabilizer()>0):
|
|
|
|
player.takeMoodStabilizer()
|
|
|
|
moodStab = moodStab + 1
|
|
|
|
var moodStabilizerTimer = Timer.new()
|
|
|
|
moodStabilizerTimer.one_shot = true;
|
|
|
|
moodStabilizerTimer.set_wait_time(secondsPerWeek*averageUpPhase/2)
|
|
|
|
add_child(moodStabilizerTimer)
|
|
|
|
moodStabilizerTimer.connect("timeout", self, "_on_MoodStabilizerTimer_timeout")
|
|
|
|
moodStabilizerTimer.start()
|
|
|
|
print("moodStabilizerTimer started with waitime: ",moodStabilizerTimer.get_wait_time())
|
|
|
|
|
|
|
|
takingPill = true
|
|
|
|
yield(get_tree().create_timer(1.0), "timeout")
|
|
|
|
takingPill = false
|
|
|
|
if Input.is_action_pressed("reset"):
|
|
|
|
mood = 0
|
|
|
|
vision.reset()
|
|
|
|
player.setNormal()
|
|
|
|
changeEffectsByMood()
|
|
|
|
|
|
|
|
if Input.is_action_pressed("quit"):
|
|
|
|
if wantToQuit && Input.get_mouse_mode()==Input.MOUSE_MODE_CONFINED:
|
|
|
|
get_tree().quit()
|
|
|
|
else:
|
|
|
|
if Input.get_mouse_mode()==Input.MOUSE_MODE_CONFINED:
|
|
|
|
wantToQuit = true
|
|
|
|
else:
|
|
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED)
|
|
|
|
|
|
|
|
if Input.is_action_just_released("flashlight"):
|
|
|
|
if($Player/CameraPivot/Flashlight.visible):
|
|
|
|
$Player/CameraPivot/Flashlight.visible = false
|
|
|
|
else:
|
|
|
|
$Player/CameraPivot/Flashlight.visible = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func changeEffectsByMood():
|
|
|
|
|
|
|
|
#depression
|
|
|
|
if(mood<0):
|
|
|
|
player.setDepressed(1+(1*abs(mood)))
|
|
|
|
#regulare med
|
|
|
|
if(antiDep>0):
|
|
|
|
vision.changeDownForce(0)
|
|
|
|
player.setDepressed(1)
|
|
|
|
#overdose of regulare med
|
|
|
|
if(antiDep>1):
|
|
|
|
vision.changeDownForce(+0.005*antiDep)
|
|
|
|
#none regular med
|
|
|
|
if(antiDep==0):
|
|
|
|
vision.changeDownForce(-0.005*abs(mood))
|
|
|
|
|
|
|
|
#wrong med
|
|
|
|
if(moodStab>0):
|
|
|
|
vision.changeShaking(1*moodStab)
|
|
|
|
#none wrong med
|
|
|
|
else:
|
|
|
|
vision.changeShaking(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#mania
|
|
|
|
if (mood>0):
|
|
|
|
#wrong med
|
|
|
|
if(antiDep>0):
|
|
|
|
player.setDepressed(1*antiDep)
|
|
|
|
else:
|
|
|
|
player.setManic(1+(1*mood))
|
|
|
|
|
|
|
|
#regulare med
|
|
|
|
if(moodStab>0):
|
|
|
|
vision.changeShaking(0)
|
|
|
|
#overdose regulare med
|
|
|
|
if(moodStab>1):
|
|
|
|
player.setManic(2)
|
|
|
|
if(moodStab==0):
|
|
|
|
vision.changeShaking(1*mood)
|
|
|
|
|
|
|
|
vision.changeDownForce(0)
|
|
|
|
|
|
|
|
#stable
|
|
|
|
if (mood==0):
|
|
|
|
vision.changeDownForce(mood)
|
|
|
|
vision.changeShaking(mood)
|
|
|
|
vision.reset()
|
|
|
|
player.setNormal()
|
|
|
|
|
|
|
|
if(antiDep>0):
|
|
|
|
player.setDepressed(1*antiDep)
|
|
|
|
|
|
|
|
if(moodStab>0):
|
|
|
|
vision.changeShaking(1*moodStab)
|
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
|
|
|
smoothMood(delta/secondsPerWeek*0.7)
|
|
|
|
|
|
|
|
changeEffectsByMood()
|
|
|
|
|
2022-06-20 10:06:58 +02:00
|
|
|
sun.rotate_x(delta/2)
|
2022-06-17 09:09:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
hudMood.text = String(mood)
|
|
|
|
hudAnti.text = String(antiDep)
|
|
|
|
hudStab.text = String(moodStab)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_StableTimer_timeout():
|
|
|
|
print("StableTimer_timeout")
|
|
|
|
#mood = -1
|
|
|
|
p0 = 0
|
|
|
|
p1 = -1
|
|
|
|
t = 0
|
|
|
|
depressionTimer.set_wait_time(secondsPerWeek*averageDownPhase+rng.randf_range(-secondsPerWeek/5,+secondsPerWeek/5))
|
|
|
|
depressionTimer.start()
|
|
|
|
print("depressionTimer started with waitime: ",depressionTimer.get_wait_time())
|
|
|
|
|
|
|
|
|
|
|
|
func _on_ManiaTimer_timeout():
|
|
|
|
print("ManiaTimer_timeout")
|
|
|
|
#mood = 0
|
|
|
|
p0 = 1
|
|
|
|
p1 = 0
|
|
|
|
t = 0
|
|
|
|
stableTimer.set_wait_time(secondsPerWeek*averageStable+rng.randf_range(-secondsPerWeek/5,+secondsPerWeek/5))
|
|
|
|
stableTimer.start()
|
|
|
|
print("stabletimer started with waitime: ",stableTimer.get_wait_time())
|
|
|
|
|
|
|
|
func _on_DepressionTimer_timeout():
|
|
|
|
print("DepressionTimer_timeout")
|
|
|
|
#mood = +1
|
|
|
|
p0 = -1
|
|
|
|
p1 = +1
|
|
|
|
t = 0
|
|
|
|
maniaTimer.set_wait_time(secondsPerWeek*averageUpPhase+rng.randf_range(-secondsPerWeek/5,+secondsPerWeek/5))
|
|
|
|
maniaTimer.start()
|
|
|
|
print("maniaTimer started with waitime: ",maniaTimer.get_wait_time())
|
|
|
|
|
|
|
|
func _on_AntiDepressantTimer_timeout():
|
|
|
|
print("AntiDepressantTimer_timeout")
|
|
|
|
antiDep = antiDep - 1
|
|
|
|
|
|
|
|
func _on_MoodStabilizerTimer_timeout():
|
|
|
|
print("MoodStabilizerTimer_timeout")
|
|
|
|
moodStab = moodStab - 1
|
|
|
|
|
|
|
|
func takingpill():
|
|
|
|
takingPill = false
|
|
|
|
|
|
|
|
func smoothMood(deltaTime: float):
|
|
|
|
#print(p0," ",p1)
|
|
|
|
t += deltaTime
|
|
|
|
if(t>1):
|
|
|
|
t=1
|
|
|
|
if(t<-1):
|
|
|
|
t=-1
|
|
|
|
mood = p0 * (1 - t) + p1 * t
|
|
|
|
#print(mood)
|
2022-06-20 10:06:58 +02:00
|
|
|
|
|
|
|
func showEnd():
|
|
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED)
|
|
|
|
theEnd.show()
|