update
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
[ext_resource type="Script" path="res://systems/enemy_ai_system.gd" id="enemy_ai_system"]
|
||||
[ext_resource type="Script" path="res://systems/respawn_system.gd" id="respawn_system"]
|
||||
[ext_resource type="Script" path="res://systems/spawn_system.gd" id="spawn_system"]
|
||||
[ext_resource type="Script" path="res://systems/buff_system.gd" id="buff_system"]
|
||||
[ext_resource type="Script" path="res://systems/effect_system.gd" id="effect_system"]
|
||||
[ext_resource type="Script" path="res://systems/element_system.gd" id="element_system"]
|
||||
|
||||
[sub_resource type="NavigationMesh" id="NavigationMesh_1"]
|
||||
vertices = PackedVector3Array(-7.0, 0.5, -7.0, -7.0, 0.5, 87.0, 7.0, 0.5, 87.0, 7.0, 0.5, -7.0)
|
||||
@@ -90,8 +91,11 @@ script = ExtResource("respawn_system")
|
||||
[node name="SpawnSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("spawn_system")
|
||||
|
||||
[node name="BuffSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("buff_system")
|
||||
[node name="EffectSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("effect_system")
|
||||
|
||||
[node name="ElementSystem" type="Node" parent="Systems"]
|
||||
script = ExtResource("element_system")
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
|
||||
navigation_mesh = SubResource("NavigationMesh_1")
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
extends Sprite3D
|
||||
|
||||
const ICON_SIZE := 10
|
||||
const ICON_MARGIN := 1
|
||||
const BORDER_W := 1
|
||||
|
||||
@onready var viewport: SubViewport = $SubViewport
|
||||
@onready var health_bar: ProgressBar = $SubViewport/HealthBar
|
||||
@onready var border: ColorRect = $SubViewport/Border
|
||||
@@ -8,19 +12,37 @@ extends Sprite3D
|
||||
var shield_bar: ProgressBar = null
|
||||
var style_normal: StyleBoxFlat
|
||||
var style_aggro: StyleBoxFlat
|
||||
var effect_container: HBoxContainer = null
|
||||
var base_viewport_height: int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
texture = viewport.get_texture()
|
||||
shield_bar = $SubViewport.get_node_or_null("ShieldBar")
|
||||
border.visible = false
|
||||
style_normal = health_bar.get_theme_stylebox("fill").duplicate()
|
||||
style_aggro = style_normal.duplicate()
|
||||
style_aggro.bg_color = Color(0.2, 0.4, 0.9, 1)
|
||||
base_viewport_height = viewport.size.y
|
||||
_create_effect_container()
|
||||
texture = viewport.get_texture()
|
||||
EventBus.target_changed.connect(_on_target_changed)
|
||||
EventBus.health_changed.connect(_on_health_changed)
|
||||
EventBus.shield_changed.connect(_on_shield_changed)
|
||||
EventBus.effect_applied.connect(_on_effect_applied)
|
||||
EventBus.effect_expired.connect(_on_effect_expired)
|
||||
_init_bars()
|
||||
|
||||
func _create_effect_container() -> void:
|
||||
effect_container = HBoxContainer.new()
|
||||
effect_container.name = "EffectContainer"
|
||||
var y_pos: float = 0.0
|
||||
if shield_bar and shield_bar.visible:
|
||||
y_pos = shield_bar.offset_bottom + 2
|
||||
else:
|
||||
y_pos = health_bar.offset_bottom + 2
|
||||
effect_container.position = Vector2(2, y_pos)
|
||||
effect_container.add_theme_constant_override("separation", ICON_MARGIN)
|
||||
viewport.add_child(effect_container)
|
||||
|
||||
func _init_bars() -> void:
|
||||
var max_health: Variant = Stats.get_stat(parent_node, "max_health")
|
||||
if max_health != null:
|
||||
@@ -33,6 +55,7 @@ func _init_bars() -> void:
|
||||
shield_bar.value = Stats.get_stat(parent_node, "shield")
|
||||
else:
|
||||
shield_bar.visible = false
|
||||
effect_container.position.y = health_bar.offset_bottom + 2
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var player: Node = get_tree().get_first_node_in_group("player")
|
||||
@@ -55,3 +78,82 @@ func _on_shield_changed(entity: Node, current: float, max_val: float) -> void:
|
||||
|
||||
func _on_target_changed(_player: Node, target: Node) -> void:
|
||||
border.visible = (target == get_parent())
|
||||
|
||||
func _on_effect_applied(target: Node, effect: Effect) -> void:
|
||||
if target != parent_node:
|
||||
return
|
||||
_add_effect_icon(effect)
|
||||
|
||||
func _on_effect_expired(target: Node, effect: Effect) -> void:
|
||||
if target != parent_node:
|
||||
return
|
||||
_remove_effect_icon(effect)
|
||||
|
||||
func _add_effect_icon(effect: Effect) -> void:
|
||||
var panel := _create_icon_panel(effect)
|
||||
var insert_idx: int = _get_sorted_index(effect.type)
|
||||
effect_container.add_child(panel)
|
||||
effect_container.move_child(panel, insert_idx)
|
||||
_resize_viewport()
|
||||
|
||||
func _remove_effect_icon(effect: Effect) -> void:
|
||||
for child in effect_container.get_children():
|
||||
if child.has_meta("effect_type") and child.has_meta("effect_name"):
|
||||
if child.get_meta("effect_type") == effect.type and child.get_meta("effect_name") == effect.effect_name:
|
||||
child.queue_free()
|
||||
_resize_viewport.call_deferred()
|
||||
return
|
||||
|
||||
func _get_sorted_index(type: int) -> int:
|
||||
var idx := 0
|
||||
for child in effect_container.get_children():
|
||||
if not child.has_meta("effect_type"):
|
||||
continue
|
||||
var child_type: int = child.get_meta("effect_type")
|
||||
if child_type <= type:
|
||||
idx += 1
|
||||
else:
|
||||
break
|
||||
return idx
|
||||
|
||||
func _create_icon_panel(effect: Effect) -> PanelContainer:
|
||||
var panel := PanelContainer.new()
|
||||
var style := StyleBoxFlat.new()
|
||||
match effect.type:
|
||||
Effect.Type.AURA:
|
||||
style.bg_color = Color(0.15, 0.15, 0.3, 1)
|
||||
style.border_color = Color(0.3, 0.5, 1.0, 1)
|
||||
Effect.Type.BUFF:
|
||||
style.bg_color = Color(0.15, 0.3, 0.15, 1)
|
||||
style.border_color = Color(0.3, 1.0, 0.3, 1)
|
||||
Effect.Type.DEBUFF:
|
||||
style.bg_color = Color(0.3, 0.15, 0.15, 1)
|
||||
style.border_color = Color(1.0, 0.3, 0.3, 1)
|
||||
style.set_border_width_all(BORDER_W)
|
||||
style.set_content_margin_all(0)
|
||||
panel.add_theme_stylebox_override("panel", style)
|
||||
var label := Label.new()
|
||||
label.text = effect.effect_name.left(1)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
label.add_theme_font_size_override("font_size", 7)
|
||||
label.add_theme_color_override("font_color", Color.WHITE)
|
||||
label.custom_minimum_size = Vector2(ICON_SIZE, ICON_SIZE)
|
||||
panel.add_child(label)
|
||||
panel.custom_minimum_size = Vector2(ICON_SIZE + 2, ICON_SIZE + 2)
|
||||
panel.set_meta("effect_type", effect.type)
|
||||
panel.set_meta("effect_name", effect.effect_name)
|
||||
return panel
|
||||
|
||||
func _resize_viewport() -> void:
|
||||
var icon_count := 0
|
||||
for child in effect_container.get_children():
|
||||
if not child.is_queued_for_deletion():
|
||||
icon_count += 1
|
||||
if icon_count > 0:
|
||||
var needed: int = int(effect_container.position.y) + ICON_SIZE + 4
|
||||
viewport.size.y = max(base_viewport_height, needed)
|
||||
border.offset_bottom = viewport.size.y
|
||||
else:
|
||||
viewport.size.y = base_viewport_height
|
||||
border.offset_bottom = base_viewport_height
|
||||
|
||||
@@ -17,9 +17,11 @@ const GCD_TIME := 0.5
|
||||
]
|
||||
|
||||
var ability_labels: Array[String] = ["1", "2", "3", "4", "P"]
|
||||
var effect_container: HBoxContainer = null
|
||||
|
||||
func _ready() -> void:
|
||||
respawn_label.visible = false
|
||||
_create_effect_container()
|
||||
EventBus.health_changed.connect(_on_health_changed)
|
||||
EventBus.shield_changed.connect(_on_shield_changed)
|
||||
EventBus.entity_died.connect(_on_entity_died)
|
||||
@@ -27,6 +29,8 @@ func _ready() -> void:
|
||||
EventBus.role_changed.connect(_on_role_changed)
|
||||
EventBus.respawn_tick.connect(_on_respawn_tick)
|
||||
EventBus.cooldown_tick.connect(_on_cooldown_tick)
|
||||
EventBus.effect_applied.connect(_on_effect_applied)
|
||||
EventBus.effect_expired.connect(_on_effect_expired)
|
||||
|
||||
func _on_health_changed(entity: Node, current: float, max_val: float) -> void:
|
||||
if entity.name == "Player":
|
||||
@@ -74,3 +78,68 @@ func _on_cooldown_tick(cooldowns: Array, max_cooldowns: Array, gcd_timer: float)
|
||||
else:
|
||||
overlay.visible = false
|
||||
label.text = ability_labels[i]
|
||||
|
||||
func _create_effect_container() -> void:
|
||||
effect_container = HBoxContainer.new()
|
||||
effect_container.name = "EffectContainer"
|
||||
effect_container.position = Vector2(10, 60)
|
||||
effect_container.add_theme_constant_override("separation", 3)
|
||||
add_child(effect_container)
|
||||
|
||||
func _on_effect_applied(target: Node, effect: Effect) -> void:
|
||||
if target.name != "Player":
|
||||
return
|
||||
var panel := _create_icon_panel(effect)
|
||||
var insert_idx: int = _get_sorted_index(effect.type)
|
||||
effect_container.add_child(panel)
|
||||
effect_container.move_child(panel, insert_idx)
|
||||
|
||||
func _on_effect_expired(target: Node, effect: Effect) -> void:
|
||||
if target.name != "Player":
|
||||
return
|
||||
for child in effect_container.get_children():
|
||||
if child.has_meta("effect_type") and child.has_meta("effect_name"):
|
||||
if child.get_meta("effect_type") == effect.type and child.get_meta("effect_name") == effect.effect_name:
|
||||
child.queue_free()
|
||||
return
|
||||
|
||||
func _get_sorted_index(type: int) -> int:
|
||||
var idx := 0
|
||||
for child in effect_container.get_children():
|
||||
if not child.has_meta("effect_type"):
|
||||
continue
|
||||
var child_type: int = child.get_meta("effect_type")
|
||||
if child_type <= type:
|
||||
idx += 1
|
||||
else:
|
||||
break
|
||||
return idx
|
||||
|
||||
func _create_icon_panel(effect: Effect) -> PanelContainer:
|
||||
var panel := PanelContainer.new()
|
||||
var style := StyleBoxFlat.new()
|
||||
match effect.type:
|
||||
Effect.Type.AURA:
|
||||
style.bg_color = Color(0.15, 0.15, 0.3, 1)
|
||||
style.border_color = Color(0.3, 0.5, 1.0, 1)
|
||||
Effect.Type.BUFF:
|
||||
style.bg_color = Color(0.15, 0.3, 0.15, 1)
|
||||
style.border_color = Color(0.3, 1.0, 0.3, 1)
|
||||
Effect.Type.DEBUFF:
|
||||
style.bg_color = Color(0.3, 0.15, 0.15, 1)
|
||||
style.border_color = Color(1.0, 0.3, 0.3, 1)
|
||||
style.set_border_width_all(2)
|
||||
style.set_content_margin_all(2)
|
||||
panel.add_theme_stylebox_override("panel", style)
|
||||
var label := Label.new()
|
||||
label.text = effect.effect_name.left(1)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
label.add_theme_font_size_override("font_size", 14)
|
||||
label.add_theme_color_override("font_color", Color.WHITE)
|
||||
label.custom_minimum_size = Vector2(20, 20)
|
||||
panel.add_child(label)
|
||||
panel.custom_minimum_size = Vector2(24, 24)
|
||||
panel.set_meta("effect_type", effect.type)
|
||||
panel.set_meta("effect_name", effect.effect_name)
|
||||
return panel
|
||||
|
||||
@@ -13,3 +13,4 @@ enum Type { SINGLE, AOE, UTILITY, ULT, PASSIVE }
|
||||
@export var icon: String = ""
|
||||
@export var is_heal: bool = false
|
||||
@export var passive_stat: String = "damage"
|
||||
@export var element: int = 0
|
||||
|
||||
@@ -10,3 +10,4 @@ damage = 20.0
|
||||
ability_range = 5.0
|
||||
cooldown = 3.0
|
||||
icon = "2"
|
||||
element = 1
|
||||
|
||||
@@ -9,3 +9,4 @@ damage = 30.0
|
||||
ability_range = 20.0
|
||||
cooldown = 2.0
|
||||
icon = "1"
|
||||
element = 1
|
||||
|
||||
@@ -11,3 +11,4 @@ ability_range = 20.0
|
||||
cooldown = 15.0
|
||||
aoe_radius = 3.0
|
||||
icon = "4"
|
||||
element = 1
|
||||
|
||||
@@ -10,6 +10,9 @@ var current_role: int = Role.DAMAGE
|
||||
|
||||
@onready var player: CharacterBody3D = get_parent()
|
||||
|
||||
func _ready() -> void:
|
||||
set_role.call_deferred(current_role)
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("class_tank"):
|
||||
set_role(Role.TANK)
|
||||
|
||||
@@ -41,4 +41,8 @@ func _spawn_portal() -> void:
|
||||
portals.append(portal)
|
||||
|
||||
func _cleanup_dead() -> void:
|
||||
portals = portals.filter(func(p: Node) -> bool: return is_instance_valid(p))
|
||||
var valid: Array[Node] = []
|
||||
for p in portals:
|
||||
if is_instance_valid(p):
|
||||
valid.append(p)
|
||||
portals = valid
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
[ext_resource type="Script" uid="uid://cyffo1g4uhmwh" path="res://systems/aggro/aggro_events.gd" id="aggro_events"]
|
||||
[ext_resource type="Script" uid="uid://cm7ehl2pexcst" path="res://systems/aggro/aggro_system.gd" id="aggro_system"]
|
||||
[ext_resource type="Script" uid="uid://c7gsu2qddsor6" path="res://systems/aggro/aggro_tracker.gd" id="aggro_tracker"]
|
||||
[ext_resource type="Script" uid="uid://da2jm0awq2lnh" path="res://systems/buff_system.gd" id="buff_system"]
|
||||
[ext_resource type="Script" uid="uid://ddos7mo8rahou" path="res://systems/cooldown_system.gd" id="cooldown_system"]
|
||||
[ext_resource type="Script" uid="uid://cbd1bryh0e2dw" path="res://systems/damage_system.gd" id="damage_system"]
|
||||
[ext_resource type="Script" uid="uid://drdlh6tq0dfwo" path="res://systems/effect_system.gd" id="effect_system"]
|
||||
[ext_resource type="Script" uid="uid://bqebxfvticxto" path="res://systems/element_system.gd" id="element_system"]
|
||||
[ext_resource type="Script" uid="uid://bwhxu5586lc1l" path="res://systems/enemy_ai_system.gd" id="enemy_ai_system"]
|
||||
[ext_resource type="Script" uid="uid://b3wkn5118dimy" path="res://systems/health_system.gd" id="health_system"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/hud/hud.tscn" id="hud"]
|
||||
@@ -92,8 +93,11 @@ script = ExtResource("respawn_system")
|
||||
[node name="SpawnSystem" type="Node" parent="Systems" unique_id=1099032666]
|
||||
script = ExtResource("spawn_system")
|
||||
|
||||
[node name="BuffSystem" type="Node" parent="Systems" unique_id=1219368182]
|
||||
script = ExtResource("buff_system")
|
||||
[node name="EffectSystem" type="Node" parent="Systems" unique_id=1219368182]
|
||||
script = ExtResource("effect_system")
|
||||
|
||||
[node name="ElementSystem" type="Node" parent="Systems" unique_id=1401212832]
|
||||
script = ExtResource("element_system")
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="." unique_id=1265843679]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0027503967, 0.014227867, 0.023231506)
|
||||
|
||||
Reference in New Issue
Block a user