add stones, pickups
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
const PICKUP_SCENE := preload("res://scenes/Pickup.tscn")
|
||||
|
||||
signal died(points: int)
|
||||
signal merged(upgrade: bool)
|
||||
|
||||
@@ -211,12 +213,34 @@ func _wall_impact_effect() -> void:
|
||||
tw.tween_property(mat, "albedo_color", Color.WHITE, 0.04)
|
||||
tw.tween_property(mat, "albedo_color", COLOR_STUN, 0.12)
|
||||
|
||||
func _try_drop_pickup() -> void:
|
||||
var roll := randf()
|
||||
var p_type := ""
|
||||
var p_heal := 0
|
||||
match enemy_type:
|
||||
"slime":
|
||||
if roll < 0.30: p_type = "health"; p_heal = 15
|
||||
elif roll < 0.40: p_type = "score"
|
||||
"bat":
|
||||
if roll < 0.20: p_type = "health"; p_heal = 12
|
||||
elif roll < 0.25: p_type = "score"
|
||||
"ogre":
|
||||
if roll < 0.55: p_type = "health"; p_heal = 35
|
||||
elif roll < 0.80: p_type = "score"
|
||||
if p_type == "":
|
||||
return
|
||||
var pickup := PICKUP_SCENE.instantiate()
|
||||
pickup.setup(p_type, p_heal)
|
||||
get_parent().add_child(pickup)
|
||||
pickup.global_position = global_position
|
||||
|
||||
func _die() -> void:
|
||||
if state == State.DEAD:
|
||||
return
|
||||
state = State.DEAD
|
||||
set_physics_process(false)
|
||||
emit_signal("died", score_value)
|
||||
_try_drop_pickup()
|
||||
var tw := create_tween()
|
||||
tw.tween_property(self, "scale", Vector3(2.0, 0.05, 2.0), 0.18)
|
||||
tw.tween_property(self, "scale", Vector3(0.0, 0.0, 0.0), 0.1)
|
||||
|
||||
Reference in New Issue
Block a user