This commit is contained in:
SlightlyObscure 2020-01-29 00:28:24 +01:00
commit 7a0b26c4a6
23 changed files with 715 additions and 143 deletions

View File

@ -20,11 +20,11 @@ enum BEHAVIOR {
var _curMood # current set behavior
var _voice_clips = {
"go_to_work": preload("res://Resources/Audio/to-work.wav"),
"go_home": preload("res://Resources/Audio/go-home.wav"),
"take_pills": preload("res://Resources/Audio/take-pills.wav"),
"do_job": preload("res://Resources/Audio/do-job.wav"),
"stop": preload("res://Resources/Audio/Stop you violated the law.wav")
"go_to_work": preload("res://Resources/Audio/meldewesen-go-to-work.wav"),
"go_home": preload("res://Resources/Audio/meldewesen-go-home.wav"),
"take_pills": preload("res://Resources/Audio/meldewesen-eat-food.wav"),
"do_job": preload("res://Resources/Audio/meldewesen-do-job.wav"),
"stop": preload("res://Resources/Audio/meldewesen-stop.wav")
}
var _visibility: Area
@ -100,6 +100,7 @@ func _process(_delta):
if _audioPlayer.stream != null:
var cur_time = OS.get_ticks_msec()
if cur_time - _lastSound > CMD_DIFF_MS:
#Logger.info("playing last command again")
_audioPlayer.play()
_lastSound = cur_time
_countCmds += 1
@ -152,8 +153,9 @@ func _set_behavior ():
reason = "player outside during worktime"
#elif _playerRef.IsInFactory and daytime < Daytime.WORK_TIME and daytime > Daytime.SLEEP_TIME: # at work after out of WORK_TIME
# EDIT: too early at work is not an angry reason :p
elif _playerRef.IsInFactory and daytime > Daytime.SLEEP_TIME: # at work after out of WORK_TIME
elif _playerRef.IsInFactory and daytime > Daytime.SLEEP_TIME + Daytime.TIGGER_TIME: # at work after out of WORK_TIME
reason = "player in factory out of worktime"
Logger.info("daytime: " + String(daytime) + " SLEEP_TIME: " + String(Daytime.SLEEP_TIME))
elif _countCmds > MAX_CMDS: # after MAX_CMDS repeats of the same command
reason = "player is seemingly not coorperativ"
@ -162,17 +164,19 @@ func _set_behavior ():
Logger.info("catch player! reason: " + reason)
_huntingPlayer = true
_playerRef.IsHunted = true
change_visibility_cone_color(Color.red)
if _followingPlayer == false:
# If the player didn't take enough pills lately, they're suspicious -> following
if Pills.get_round_level() <= _player_follow_pill_level:
Logger.info("The player's pill level is too low - following!")
_followingPlayer = true
change_visibility_cone_color(Color.yellow)
if _huntingPlayer or _followingPlayer:
current_target = _playerRef.transform.origin
if _huntingPlayer:
change_visibility_cone_color(Color.red)
if _followingPlayer:
change_visibility_cone_color(Color.yellow)
else:
change_visibility_cone_color(Color.green)
@ -180,11 +184,8 @@ func _set_behavior ():
var daytime = Daytime.get_time()
if _playerRef.IsHunted:
mood = BEHAVIOR.ANGRY
# do your job
elif _playerRef.is_in_workzone():
mood = BEHAVIOR.DO_JOB
# take your pills
elif Pills.get_level() < Pills.get_max()*0.5:
elif Pills.get_level() < _player_follow_pill_level:
mood = BEHAVIOR.TAKE_PILLS
# go to work
elif daytime < Daytime.WORK_TIME:
@ -192,6 +193,10 @@ func _set_behavior ():
# go home
elif daytime > Daytime.SLEEP_TIME:
mood = BEHAVIOR.GO_HOME
# do your job
elif _playerRef.is_in_workzone():
_countCmds = 0 # hard block -> work is always good :D
mood = BEHAVIOR.DO_JOB
if mood != _curMood:
Logger.info("new mood: " + BEHAVIOR.keys()[mood] + " with cntcmd: " + String(_countCmds))
@ -205,7 +210,6 @@ func _on_body_entered_visibility (body: PhysicsBody):
if body.is_in_group("Player"):
Logger.info("Seeing player!")
_seeingPlayer = true
#_set_behavior()
func _on_body_exited_visibility(body: PhysicsBody):
@ -214,6 +218,7 @@ func _on_body_exited_visibility(body: PhysicsBody):
_seeingPlayer = false
_countCmds = 0
if _huntingPlayer == false and _followingPlayer == false:
change_visibility_cone_color(Color.green)
# dirty quickfix: TODO: refactor
if current_target != _start_pos:
current_target = null

File diff suppressed because one or more lines are too long

View File

@ -106,12 +106,21 @@ func _ready():
area.connect("area_exited", self, "_on_area_exited")
Daytime.connect("respawn", self, "_on_respawn")
Daytime.connect("go_home", self, "_on_go_home")
Daytime.connect("go_to_work", self, "_on_go_to_work")
Pills.connect("low_pill_level", self, "_on_pill_level_low")
Pills.connect("very_low_pill_level", self, "_on_pill_level_very_low")
if IsOutside:
var player = get_node("AudioStreamPlayer3D")
player.stream = load("res://Resources/Audio/cock.wav")
player.play()
# only message Player at the beginning
if Daytime.get_time() < 10:
showMessage("Press 'F' to eat your food", 4)
func showMessage (text, duration):
_labelMessage.text = text
@ -234,6 +243,7 @@ func _input(event):
# Prevent player from doing a purzelbaum
_camera.rotation_degrees.x = clamp(_camera.rotation_degrees.x, -70, 70)
func _on_area_entered (area: Area):
if area.is_in_group("Forbidden"):
Logger.info("entering forbidden area!")
@ -246,27 +256,24 @@ func _on_area_entered (area: Area):
_work_areas += 1
elif area.is_in_group("FactoryEntry"):
Logger.info("entering factory")
IsInFactory = true
IsOutside = false
#IsInFactory = true
#IsOutside = false
get_tree().change_scene("res://Level/InFactory.tscn")
elif area.is_in_group("TunnelEntry"):
Logger.info("entering factory")
IsInFactory = false
IsOutside = false
# TODO: move not change_scene!
#IsInFactory = false
#IsOutside = false
get_tree().change_scene("res://Level/Tunnel.tscn")
# TODO: other entries
elif area.is_in_group("OutsideEntry"):
Logger.info("leaving factory")
IsInFactory = false
IsOutside = true
# TODO: move not change_scene!
get_tree().change_scene("res://Level/OutsideWorld.tscn")
#IsInFactory = false
#IsOutside = true
get_tree().change_scene("res://Level/OutsideWorldReverse.tscn")
elif area.is_in_group("LabyrinthEntry"):
Logger.info("entering labyrinth")
IsInFactory = false
IsInLabyrinth = true
# TODO: move not change_scene!
#IsInFactory = false
#IsInLabyrinth = true
get_tree().change_scene("res://Level/Labyrinth.tscn")
@ -307,3 +314,23 @@ func _on_respawn ():
get_tree().change_scene("res://Level/OutsideWorld.tscn")
_inventory.show() # enable hud again
func _on_go_home ():
if IsInFactory:
showMessage("Jobs done! Time to go home", 4)
func _on_go_to_work ():
if IsOutside:
showMessage("Time to go to work", 4)
func _on_pill_level_low ():
Logger.info("player received low pill")
showMessage("Don't starve! Press 'F' to eat your food!", 4)
func _on_pill_level_very_low ():
Logger.info("player received very low pill")
showMessage("REALLY! You should eat your food!", 4)

View File

@ -36,17 +36,31 @@ visible = false
modulate = Color( 0, 0, 0, 1 )
self_modulate = Color( 0, 0, 0, 1 )
anchor_left = 0.5
anchor_top = 1.0
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -153.0
margin_top = -106.0
margin_right = 153.0
margin_bottom = -82.0
anchor_bottom = 0.5
margin_left = -460.0
margin_top = 162.0
margin_right = 460.0
margin_bottom = 186.0
custom_fonts/font = ExtResource( 2 )
text = "you don't havve the right key"
text = "this is a very long text. just needed to be able to center it at the beginning of the game"
align = 1
[node name="labelHealth" type="Label" parent="."]
modulate = Color( 0, 0, 0, 1 )
self_modulate = Color( 0, 0, 0, 1 )
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -790.869
margin_top = -402.863
margin_right = -640.869
margin_bottom = -378.863
custom_fonts/font = ExtResource( 2 )
text = "Health"
[node name="InventoryContainer" type="GridContainer" parent="."]
anchor_left = 1.0
anchor_top = 0.5

View File

@ -3,30 +3,17 @@ extends NPC
const diffPerSecond = 5
var _arrived_distance_threshold = 0.1
var _interactArea: Area
var _navPath: Path
var _followPath: PathFollow
var _current_nav_index = 0
func _ready():
#Logger.set_logger_level(Logger.LOG_LEVEL_FINE)
_followPath = get_node("../") as PathFollow
_navPath = get_node("../../") as Path
var _interactArea = get_node("InteractArea") as Area
assert(null != _interactArea)
_interactArea.connect("area_entered", self, "_on_area_entered")
func _process(_delta):
# TODO: movement
#if current_target: # should not be needed -> handled per navigation path
if _followPath != null:
_followPath.offset += diffPerSecond * _delta
func _on_area_entered (area: Area):
if area.is_in_group("FactoryEntry"):
# despawn
queue_free()
if _followPath.unit_offset > 0.99:
#Logger.info("freeing worker! name: " + name)
queue_free()

View File

@ -1,15 +1,18 @@
extends Node
#const _max: int = 1440 # 24 hour + 60 mins
const _max: int = 1440
const _max: int = 1440 # 24 hour + 60 mins
const WORK_TIME = _max * 0.3
const SLEEP_TIME = _max * 0.6
const TIGGER_TIME = _max * 0.2
var _time: float setget _set_time, get_time
var _time: float = 0 setget _set_time, get_time
var _prev_time: float = _time
var increase_per_second: float = 5.0
signal respawn
signal go_to_work
signal go_home
func _set_time (new_time: float):
@ -26,7 +29,16 @@ func get_max () -> int:
func _process (delta: float) -> void:
# continually increases daytime
_set_time(_time + increase_per_second * delta)
_time = _time + increase_per_second * delta
if _time >= _max:
_time = 0
emit_signal("respawn")
if _prev_time < WORK_TIME - TIGGER_TIME and _time > WORK_TIME - TIGGER_TIME:
Logger.info("time to go to work @" + String(_time))
emit_signal("go_to_work")
if _prev_time < SLEEP_TIME and _time > SLEEP_TIME:
Logger.info("time to go home @" + String(_time))
emit_signal("go_home")
_prev_time = _time

View File

@ -1,12 +1,16 @@
extends Node
var _level: float setget _set_level, get_level
var _min: float = 0.0
var _max: float = 6.0
var _level: float = _max setget _set_level, get_level
var _prev_level: float = _max
var _decrease_per_second: float = 0.2
var _pill_add_amount: float = 2.0
signal low_pill_level
signal very_low_pill_level
enum LEVELS {
SOBRE = 0,
VERY_LOW = 1,
@ -51,6 +55,15 @@ func _ready() -> void:
func _process(delta: float) -> void:
# Gradually decrease the level by the decrease per second
_set_level(_level - _decrease_per_second * delta)
if _prev_level > LEVELS.VERY_LOW and _level < LEVELS.VERY_LOW:
Logger.info("very low pill level")
emit_signal("very_low_pill_level")
elif _prev_level > LEVELS.MEDIUM and _level < LEVELS.MEDIUM:
Logger.info("low pill level")
emit_signal("low_pill_level")
_prev_level = _level
func take_pill():

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@ extends Spatial
export(NodePath) var _nodepath
export(float) var _offset
export(bool) var ToFactory = true # otherwise it's FromFactory
const SPAWN_TIME_MIN = 1000 # min spawntime in ms
const SPAWN_TIME_MAX = 3000 # max spawntime in ms
@ -19,15 +20,22 @@ func _ready():
func _process(delta):
var day_time = Daytime.get_time()
if ToFactory:
if day_time > Daytime.WORK_TIME:
return
elif day_time < Daytime.SLEEP_TIME:
return
# spawns new workers after defined time
var cur_time = OS.get_ticks_msec()
if cur_time - _lastSpawn > diff:
#Logger.info(name + " spawning new worker")
var pathFollow = PathFollow.new()
pathFollow.offset = _offset
pathFollow.add_child(_worker.instance())
var worker = _worker.instance()
pathFollow.add_child(worker)
_path.add_child(pathFollow)
_lastSpawn = cur_time
#Logger.info(name + " spawning new worker: " + worker.name + ". daytime " + String(day_time) + " <-> " + String(Daytime.WORK_TIME))
diff = rand_range(SPAWN_TIME_MIN, SPAWN_TIME_MAX)

View File

@ -9,11 +9,13 @@ brief game description, about 3 sentences
## Controls
- standard fps: walk with WASD, look around with mouse
- take pills with 'R'
- take pills with 'R' / 'F'
- interact with objects 'E'
## Gameplay Features
- day-night cycle
- different areas
- motivation controlled AI
- feature B
- ...

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/meldewesen-do-job.wav-4eda54c25a60180613f71c06c6f6b322.sample"
[deps]
source_file="res://Resources/Audio/meldewesen-do-job.wav"
dest_files=[ "res://.import/meldewesen-do-job.wav-4eda54c25a60180613f71c06c6f6b322.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/meldewesen-eat-food.wav-8b8266fa43381a11c15555fa2f7a200a.sample"
[deps]
source_file="res://Resources/Audio/meldewesen-eat-food.wav"
dest_files=[ "res://.import/meldewesen-eat-food.wav-8b8266fa43381a11c15555fa2f7a200a.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/meldewesen-go-home.wav-691e97c36e19e13c4c912a25c2b2fd35.sample"
[deps]
source_file="res://Resources/Audio/meldewesen-go-home.wav"
dest_files=[ "res://.import/meldewesen-go-home.wav-691e97c36e19e13c4c912a25c2b2fd35.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/meldewesen-go-to-work.wav-a4ff327160c2ce98e3869201a7a60ee4.sample"
[deps]
source_file="res://Resources/Audio/meldewesen-go-to-work.wav"
dest_files=[ "res://.import/meldewesen-go-to-work.wav-a4ff327160c2ce98e3869201a7a60ee4.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/meldewesen-restricted-area.wav-af0568653214f4c8f1b9fc588246bfaf.sample"
[deps]
source_file="res://Resources/Audio/meldewesen-restricted-area.wav"
dest_files=[ "res://.import/meldewesen-restricted-area.wav-af0568653214f4c8f1b9fc588246bfaf.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/meldewesen-stop.wav-47129a22f9003188cd49ed63bef4f361.sample"
[deps]
source_file="res://Resources/Audio/meldewesen-stop.wav"
dest_files=[ "res://.import/meldewesen-stop.wav-47129a22f9003188cd49ed63bef4f361.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0