Missiles limit & UI
This commit is contained in:
parent
853eb28d33
commit
632d927938
5 changed files with 55 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue