Added hunger tick damage
This commit is contained in:
1 parent
3fb9fce92f
commit
c6da4e0aa2
6 files changed
+138
-25
No files matched your search
+14
-9
@@ -1,19 +1,26 @@
|
||||
extends KinematicBody
|
||||
|
||||
signal starved_to_death
|
||||
|
||||
const EPSILON = 0.0001
|
||||
const SPEED = 10.0
|
||||
|
||||
export var inventory = { "ore" : 0 }
|
||||
var health: int = 4 setget set_health
|
||||
export var hunger_tick_time = 30.0
|
||||
export var inventory = {}
|
||||
|
||||
var health: int = 4 setget set_health
|
||||
var item_in_hand
|
||||
var move_enabled: bool = true
|
||||
|
||||
onready var move_playback = $DungMan/AnimationTree["parameters/Move/playback"]
|
||||
onready var hunger_timer = $"%hunger_timer"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$hitbox.set_meta("owner", self)
|
||||
move_playback.travel("idle")
|
||||
hunger_timer.wait_time = hunger_tick_time
|
||||
hunger_timer.start()
|
||||
|
||||
func _physics_process(delta):
|
||||
if not move_enabled:
|
||||
@@ -27,18 +34,16 @@ func _physics_process(delta):
|
||||
move_playback.travel("idle")
|
||||
move_and_slide(motion)
|
||||
|
||||
func _on_hunger_timer_timeout():
|
||||
set_health(health - 1)
|
||||
print("player: lost health to hunger tick")
|
||||
|
||||
func set_health(new_value):
|
||||
health = min(new_value, 4)
|
||||
for child in $"%stomachs".get_children():
|
||||
child.visible = child.get_index() < health
|
||||
if health <= 0:
|
||||
var node = Dialogic.start("starve")
|
||||
node.pause_mode = PAUSE_MODE_PROCESS
|
||||
add_child(node)
|
||||
get_tree().paused = true
|
||||
yield(node, "timeline_end")
|
||||
get_tree().paused = false
|
||||
get_tree().quit() # go back to main menu when such a thing exists
|
||||
emit_signal("starved_to_death")
|
||||
|
||||
func can_afford(item_name, item_amount):
|
||||
assert(item_amount > 0)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
extends Node
|
||||
|
||||
onready var player = get_tree().get_nodes_in_group("player")[0]
|
||||
|
||||
func _ready():
|
||||
player.connect("starved_to_death", self, "_on_player_starved_to_death")
|
||||
|
||||
func _on_player_starved_to_death():
|
||||
var node = Dialogic.start("starve")
|
||||
node.pause_mode = PAUSE_MODE_PROCESS
|
||||
add_child(node)
|
||||
get_tree().paused = true
|
||||
yield(node, "timeline_end")
|
||||
get_tree().paused = false
|
||||
get_tree().quit() # go back to main menu when such a thing exists
|
||||
Reference in new issue
Block a user