Añadidos drops, ahora cae cerveza o cafe
This commit is contained in:
1 parent
bbecc76dbe
commit
8bbf70e8cb
11 files changed
+282
-1
No files matched your search
@@ -9,6 +9,7 @@ signal died
|
||||
# actually share instead of guessing an abstraction in advance.
|
||||
|
||||
const PLAYER_HURTBOX_MASK: int = 1 << 3
|
||||
const DROP_MANAGER := preload("res://pickups/drop_manager.gd")
|
||||
|
||||
|
||||
enum AttackState {
|
||||
@@ -88,6 +89,20 @@ enum AttackState {
|
||||
# RESPAWN
|
||||
# ============================================================================
|
||||
|
||||
@export_category("Drops")
|
||||
|
||||
## Table defining what pickups can drop on death (by chance).
|
||||
@export var drop_table: PickupDropTable
|
||||
|
||||
|
||||
@export_category("Respawn")
|
||||
|
||||
@export_category("Drops")
|
||||
|
||||
## Table defining what pickups can drop on death (by chance).
|
||||
@export var drop_table: PickupDropTable
|
||||
|
||||
|
||||
@export_category("Respawn")
|
||||
|
||||
## Enough downtime to make defeating an enemy meaningful before it comes back.
|
||||
@@ -161,7 +176,21 @@ func _ready() -> void:
|
||||
attack_hitbox.collision_mask = PLAYER_HURTBOX_MASK
|
||||
attack_hitbox.monitoring = true
|
||||
|
||||
if drop_table == null:
|
||||
var default_table = load("res://enemies/walker/walker_drop.tres")
|
||||
if default_table != null:
|
||||
drop_table = default_table
|
||||
|
||||
visibility_notifier.screen_entered.connect(_wake_up)
|
||||
if default_table != null:
|
||||
drop_table = default_table
|
||||
|
||||
visibility_notifier.screen_entered.connect(_wake_up)
|
||||
|
||||
if drop_table == null:
|
||||
var default_table := load("res://enemies/walker/walker_drop.tres")
|
||||
if default_table != null:
|
||||
drop_table = default_table as PickupDropTable
|
||||
|
||||
_update_facing()
|
||||
_reset_attack_hitbox_position()
|
||||
@@ -474,6 +503,16 @@ func _die() -> void:
|
||||
is_dead = true
|
||||
died.emit()
|
||||
|
||||
if drop_table != null:
|
||||
var drops = DROP_MANAGER.roll_drop(drop_table)
|
||||
if not drops.is_empty():
|
||||
var parent := get_tree().current_scene
|
||||
if parent == null:
|
||||
parent = get_tree().root.get_child(get_tree().root.get_child_count() - 1)
|
||||
if parent == null:
|
||||
parent = get_tree().root
|
||||
DROP_MANAGER.spawn_drops(drops, parent, global_position)
|
||||
|
||||
velocity = Vector2.ZERO
|
||||
visible = false
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
[gd_resource type="Resource" script_class="PickupDropTable" load_steps=5 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://pickups/pickup_drop.gd" id="1_drop"]
|
||||
[ext_resource type="Script" path="res://pickups/pickup_drop_table.gd" id="2_table"]
|
||||
[ext_resource type="Resource" path="res://pickups/data/beer.tres" id="3_beer"]
|
||||
[ext_resource type="Resource" path="res://pickups/data/coffee.tres" id="4_coffee"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_beer"]
|
||||
script = ExtResource("1_drop")
|
||||
pickup = ExtResource("3_beer")
|
||||
weight = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_coffee"]
|
||||
script = ExtResource("1_drop")
|
||||
pickup = ExtResource("4_coffee")
|
||||
weight = 0.5
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_table")
|
||||
drops = Array[ExtResource("1_drop")]([SubResource("Resource_beer"), SubResource("Resource_coffee")])
|
||||
drop_chance = 0.5
|
||||
min_drops = 0
|
||||
max_drops = 1
|
||||
Reference in new issue
Block a user