Loot change
This commit is contained in:
@@ -65,7 +65,6 @@ attack={
|
|||||||
inventory={
|
inventory={
|
||||||
"deadzone": 0.2,
|
"deadzone": 0.2,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
escape_menu={
|
escape_menu={
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ const WORLD_TILE_SIZE := TILE_SIZE * TILE_SCALE # 32 pixels per tile in world
|
|||||||
var crafting_panel = null
|
var crafting_panel = null
|
||||||
var mob_loot_ui = null
|
var mob_loot_ui = null
|
||||||
|
|
||||||
|
# Loot popup prompt
|
||||||
|
var loot_popup: Button = null
|
||||||
|
var nearby_lootable_mob: Node = null
|
||||||
|
|
||||||
# Visual tile renderer (for V2 dungeons)
|
# Visual tile renderer (for V2 dungeons)
|
||||||
var visual_renderer: VisualTileMapRenderer = null
|
var visual_renderer: VisualTileMapRenderer = null
|
||||||
|
|
||||||
@@ -83,6 +87,9 @@ func _ready():
|
|||||||
mob_loot_ui.visible = false
|
mob_loot_ui.visible = false
|
||||||
add_child(mob_loot_ui)
|
add_child(mob_loot_ui)
|
||||||
|
|
||||||
|
# Create loot popup prompt
|
||||||
|
_create_loot_popup()
|
||||||
|
|
||||||
# Create visual tile renderer
|
# Create visual tile renderer
|
||||||
visual_renderer = VisualTileMapRenderer.new()
|
visual_renderer = VisualTileMapRenderer.new()
|
||||||
visual_renderer.name = "VisualTileRenderer"
|
visual_renderer.name = "VisualTileRenderer"
|
||||||
@@ -238,6 +245,7 @@ func _process(delta):
|
|||||||
|
|
||||||
_handle_input()
|
_handle_input()
|
||||||
_update_camera(delta)
|
_update_camera(delta)
|
||||||
|
_update_loot_popup()
|
||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
if not GameState or GameState.current_state != GameState.STATE_PLAYING:
|
if not GameState or GameState.current_state != GameState.STATE_PLAYING:
|
||||||
@@ -719,3 +727,69 @@ func _on_damage_number(data: Dictionary):
|
|||||||
color = Color(1.0, 0.5, 0.0) # Orange for weakness
|
color = Color(1.0, 0.5, 0.0) # Orange for weakness
|
||||||
|
|
||||||
dmg_number.initialize(damage, color)
|
dmg_number.initialize(damage, color)
|
||||||
|
|
||||||
|
func _create_loot_popup():
|
||||||
|
"""Create the loot popup prompt that appears when near corpses"""
|
||||||
|
# Create a button instead of label so it's clickable
|
||||||
|
var button = Button.new()
|
||||||
|
button.text = "[E]"
|
||||||
|
button.add_theme_font_size_override("font_size", 14)
|
||||||
|
button.add_theme_color_override("font_color", Color.WHITE)
|
||||||
|
button.visible = false
|
||||||
|
button.z_index = 100
|
||||||
|
button.custom_minimum_size = Vector2(30, 30)
|
||||||
|
|
||||||
|
# Make it styled
|
||||||
|
var style_normal = StyleBoxFlat.new()
|
||||||
|
style_normal.bg_color = Color(0, 0, 0, 0.8)
|
||||||
|
style_normal.set_border_width_all(2)
|
||||||
|
style_normal.border_color = Color(0.8, 0.8, 0.3)
|
||||||
|
style_normal.set_corner_radius_all(4)
|
||||||
|
button.add_theme_stylebox_override("normal", style_normal)
|
||||||
|
|
||||||
|
var style_hover = StyleBoxFlat.new()
|
||||||
|
style_hover.bg_color = Color(0.2, 0.2, 0, 0.9)
|
||||||
|
style_hover.set_border_width_all(2)
|
||||||
|
style_hover.border_color = Color(1.0, 1.0, 0.5)
|
||||||
|
style_hover.set_corner_radius_all(4)
|
||||||
|
button.add_theme_stylebox_override("hover", style_hover)
|
||||||
|
|
||||||
|
button.pressed.connect(_on_loot_popup_clicked)
|
||||||
|
add_child(button)
|
||||||
|
loot_popup = button
|
||||||
|
|
||||||
|
func _update_loot_popup():
|
||||||
|
"""Update loot popup position and visibility based on nearby corpses"""
|
||||||
|
if not loot_popup or not player_node or not mobs_container:
|
||||||
|
return
|
||||||
|
|
||||||
|
var player_pos = player_node.position
|
||||||
|
var loot_range = 50.0 # Pixels
|
||||||
|
|
||||||
|
# Find nearest dead mob within range
|
||||||
|
var nearest_mob = null
|
||||||
|
var nearest_distance = loot_range
|
||||||
|
|
||||||
|
for child in mobs_container.get_children():
|
||||||
|
if child.get_meta("is_dead", false):
|
||||||
|
var distance = player_pos.distance_to(child.position)
|
||||||
|
if distance < nearest_distance:
|
||||||
|
nearest_distance = distance
|
||||||
|
nearest_mob = child
|
||||||
|
|
||||||
|
if nearest_mob:
|
||||||
|
# Show popup above the corpse
|
||||||
|
nearby_lootable_mob = nearest_mob
|
||||||
|
loot_popup.visible = true
|
||||||
|
loot_popup.global_position = nearest_mob.global_position + Vector2(-40, -40)
|
||||||
|
else:
|
||||||
|
nearby_lootable_mob = null
|
||||||
|
loot_popup.visible = false
|
||||||
|
|
||||||
|
func _on_loot_popup_clicked():
|
||||||
|
"""Handle click on loot popup"""
|
||||||
|
if nearby_lootable_mob:
|
||||||
|
var mob_id = nearby_lootable_mob.get_meta("entity_id", -1)
|
||||||
|
if mob_id >= 0:
|
||||||
|
GameState.request_mob_loot(mob_id)
|
||||||
|
print("[DungeonManager] Loot popup clicked - requesting loot from mob ID: %d" % mob_id)
|
||||||
|
|||||||
@@ -114,17 +114,13 @@ func update_data(data: Dictionary):
|
|||||||
|
|
||||||
_initialized = true
|
_initialized = true
|
||||||
|
|
||||||
# Update visual state
|
# Update visual state (skip for dead mobs to preserve death animation)
|
||||||
#var state = data.get("state", data.get("State", "idle")).to_lower()
|
if _current_state != "dead":
|
||||||
#var rotation = data.get("rotation", data.get("Rotation", 0.0))
|
var raw_state = data.get("state", data.get("State", "idle")).to_lower()
|
||||||
#
|
var animation_state := _state_to_animation(raw_state)
|
||||||
#_update_animation_state(state, rotation)
|
var rotation = data.get("rotation", data.get("Rotation", 0.0))
|
||||||
|
|
||||||
var raw_state = data.get("state", data.get("State", "idle")).to_lower()
|
_update_animation_state(animation_state, rotation)
|
||||||
var animation_state := _state_to_animation(raw_state)
|
|
||||||
var rotation = data.get("rotation", data.get("Rotation", 0.0))
|
|
||||||
|
|
||||||
_update_animation_state(animation_state, rotation)
|
|
||||||
|
|
||||||
|
|
||||||
# Apply scale
|
# Apply scale
|
||||||
@@ -536,15 +532,13 @@ func play_death_animation():
|
|||||||
break
|
break
|
||||||
|
|
||||||
if death_anim_name != "":
|
if death_anim_name != "":
|
||||||
|
# Disable looping for death animation BEFORE playing
|
||||||
|
_animated_sprite.sprite_frames.set_animation_loop(death_anim_name, false)
|
||||||
|
|
||||||
# Play the death animation
|
# Play the death animation
|
||||||
_last_animation = death_anim_name
|
_last_animation = death_anim_name
|
||||||
_animated_sprite.play(death_anim_name)
|
_animated_sprite.play(death_anim_name)
|
||||||
|
|
||||||
# Wait for animation to finish
|
|
||||||
if _animated_sprite.sprite_frames.get_animation_loop(death_anim_name):
|
|
||||||
# If it loops, disable looping temporarily
|
|
||||||
_animated_sprite.sprite_frames.set_animation_loop(death_anim_name, false)
|
|
||||||
|
|
||||||
# Wait for animation to complete
|
# Wait for animation to complete
|
||||||
await _animated_sprite.animation_finished
|
await _animated_sprite.animation_finished
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user