Missiles limit & UI

This commit is contained in:
Felipe M 2021-05-18 20:43:07 +02:00
parent 853eb28d33
commit 632d927938
Signed by: fmartingr
GPG key ID: 716BC147715E716F
5 changed files with 55 additions and 2 deletions

View file

@ -82,7 +82,7 @@ func _physics_process(delta):
if Input.is_action_pressed("fire") and fireBulletTimer.time_left == 0:
fire_bullet()
if Input.is_action_pressed("fire_missile") and fireBulletTimer.time_left == 0:
if Input.is_action_pressed("fire_missile") and fireBulletTimer.time_left == 0 and PlayerStats.missiles > 0:
fire_missile()
func fire_bullet():
@ -99,6 +99,7 @@ func fire_missile():
motion -= missile.velocity * 0.25
missile.rotation = missile.velocity.angle()
fireBulletTimer.start()
PlayerStats.missiles -= 1
func create_dust_effect():
var dust_position = global_position

View file

@ -3,8 +3,11 @@ class_name PlayerStats
var max_health = 4
var health = max_health setget set_health
var max_missiles = 3
var missiles = max_missiles setget set_missiles
signal player_health_changed(value)
signal player_missiles_changed(value)
signal player_died
func set_health(value):
@ -16,3 +19,7 @@ func set_health(value):
if health == 0:
emit_signal("player_died")
func set_missiles(value):
missiles = clamp(value, 0, max_missiles)
emit_signal("player_missiles_changed", missiles)