WIP: merge recipies
This commit is contained in:
+17
-3
@@ -1,12 +1,17 @@
|
||||
class_name Enemy
|
||||
extends CharacterBody3D
|
||||
|
||||
const PICKUP_SCENE := preload("res://scenes/Pickup.tscn")
|
||||
const PICKUP_SCENE := preload("res://scenes/Pickup.tscn")
|
||||
const LEATHER_SCENE := preload("res://scenes/Leather.tscn")
|
||||
|
||||
signal died(points: int)
|
||||
signal merged(upgrade: bool)
|
||||
|
||||
enum State { CHASING, FLYING, STUNNED, DEAD, MERGING }
|
||||
|
||||
static var first_leather_spawned: bool = false
|
||||
|
||||
var kickable_type: String = ""
|
||||
var move_speed: float = 3.0
|
||||
var health: int = 30
|
||||
var damage_to_player: int = 8
|
||||
@@ -46,6 +51,7 @@ func _ready() -> void:
|
||||
|
||||
func setup(type: String, wave: int) -> void:
|
||||
enemy_type = type
|
||||
kickable_type = type
|
||||
wave_num = wave
|
||||
match type:
|
||||
"slime":
|
||||
@@ -107,7 +113,7 @@ const AVOID_STRENGTH := 2.2
|
||||
|
||||
func _avoid_rocks(desired: Vector3) -> Vector3:
|
||||
var push := Vector3.ZERO
|
||||
for rock in get_tree().get_nodes_in_group("rocks"):
|
||||
for rock in get_tree().get_nodes_in_group("kickable"):
|
||||
if not is_instance_valid(rock):
|
||||
continue
|
||||
var away := global_position - (rock as Node3D).global_position
|
||||
@@ -147,7 +153,7 @@ func _fly(delta: float) -> void:
|
||||
chain_dir.y = 0.0
|
||||
if chain_dir.length() > 0.01:
|
||||
col3d.call("receive_kick", chain_dir.normalized(), speed_now * chain_factor)
|
||||
elif col3d.is_in_group("rocks"):
|
||||
elif col3d.is_in_group("kickable"):
|
||||
KickSystem.resolve(self, col3d, fly_vel)
|
||||
var rock_dir := col3d.global_position - global_position
|
||||
rock_dir.y = 0.0
|
||||
@@ -251,6 +257,14 @@ func _wall_impact_effect() -> void:
|
||||
tw.tween_property(mat, "albedo_color", COLOR_STUN, 0.12)
|
||||
|
||||
func _try_drop_pickup() -> void:
|
||||
if enemy_level == 1:
|
||||
var drop_leather := not first_leather_spawned or randf() < 0.20
|
||||
if drop_leather:
|
||||
first_leather_spawned = true
|
||||
var leather := LEATHER_SCENE.instantiate() as Node3D
|
||||
get_parent().add_child(leather)
|
||||
leather.global_position = global_position
|
||||
|
||||
var roll := randf()
|
||||
var p_type := ""
|
||||
var p_heal := 0
|
||||
|
||||
Reference in New Issue
Block a user