try to make proper EnemiesUI
parent
833bf74dad
commit
4c55e9ce13
@ -1,27 +1,28 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://bv0yhkf3bvbxi"]
|
[gd_scene load_steps=3 format=3 uid="uid://bv0yhkf3bvbxi"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://chkly72g0pu8o" path="res://resources/images/viking-helmet.png" id="1_7x375"]
|
[ext_resource type="Script" path="res://scripts/enemy_ui.gd" id="1_kdsp7"]
|
||||||
[ext_resource type="Script" path="res://scripts/enemies_ui.gd" id="1_atxm0"]
|
[ext_resource type="Texture2D" uid="uid://vb6e6la8cj2g" path="res://resources/images/viking-helmet-small.png" id="2_qr4e4"]
|
||||||
|
|
||||||
[node name="Enemies_UI" type="Control"]
|
[node name="VBoxContainer" type="VBoxContainer"]
|
||||||
custom_minimum_size = Vector2(64, 128)
|
anchors_preset = 1
|
||||||
layout_mode = 3
|
anchor_left = 1.0
|
||||||
anchors_preset = 0
|
anchor_right = 1.0
|
||||||
size_flags_horizontal = 4
|
offset_left = -101.0
|
||||||
size_flags_vertical = 4
|
offset_bottom = 137.0
|
||||||
script = ExtResource("1_atxm0")
|
grow_horizontal = 0
|
||||||
|
script = ExtResource("1_kdsp7")
|
||||||
|
|
||||||
[node name="CanvasGroup" type="CanvasGroup" parent="."]
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
texture = ExtResource("2_qr4e4")
|
||||||
|
expand_mode = 5
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="CanvasGroup"]
|
[node name="UnitName" type="Label" parent="."]
|
||||||
position = Vector2(32, 32)
|
layout_mode = 2
|
||||||
scale = Vector2(0.125, 0.125)
|
theme_override_font_sizes/font_size = 10
|
||||||
texture = ExtResource("1_7x375")
|
text = "Unit_Name"
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="CanvasGroup"]
|
[node name="UnitPosition" type="Label" parent="."]
|
||||||
offset_top = 64.0
|
layout_mode = 2
|
||||||
offset_right = 64.0
|
theme_override_font_sizes/font_size = 10
|
||||||
offset_bottom = 113.0
|
text = "Unit_Position (0, 0, 0)"
|
||||||
text = "Godot
|
|
||||||
0, 0, 0"
|
|
||||||
horizontal_alignment = 1
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://vb6e6la8cj2g"
|
||||||
|
path="res://.godot/imported/viking-helmet-small.png-623a7d087e037bcef3c8d1b0b3c45f8e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://resources/images/viking-helmet-small.png"
|
||||||
|
dest_files=["res://.godot/imported/viking-helmet-small.png-623a7d087e037bcef3c8d1b0b3c45f8e.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
@ -1,12 +1,14 @@
|
|||||||
class_name EnemiesUI extends Control
|
extends Control
|
||||||
|
|
||||||
@export var spawn_manager: SpawnManager
|
@export var enemies_ui: PackedScene
|
||||||
|
|
||||||
@onready var sprite_2d: Sprite2D = $CanvasGroup/Sprite2D
|
|
||||||
@onready var label: Label = $CanvasGroup/Label
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
spawn_manager.update_enemies_ui.connect(update_enemy_ui)
|
SpawnManager.update_enemies_ui.connect(update_enemies_ui)
|
||||||
|
|
||||||
func update_enemy_ui(enemy: Enemy) -> void:
|
func update_enemies_ui(enemies: Array[Enemy]) -> void:
|
||||||
label.text = enemy.unit_name + "\n" + str(enemy.position)
|
print("Update Enemy UI")
|
||||||
|
for enemy in enemies:
|
||||||
|
print("Add " + enemy.unit_name + "...")
|
||||||
|
var new_enemy_ui = enemies_ui.instantiate()
|
||||||
|
new_enemy_ui.update_ui(enemy)
|
||||||
|
new_enemy_ui.add_child(self)
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
class_name enemy_ui extends VBoxContainer
|
||||||
|
|
||||||
|
@onready var texture_rect: TextureRect = $TextureRect
|
||||||
|
@onready var unit_name: Label = $UnitName
|
||||||
|
@onready var unit_position: Label = $UnitPosition
|
||||||
|
|
||||||
|
func update_ui(enemy: Enemy):
|
||||||
|
unit_name.text = enemy.unit_name
|
||||||
|
unit_position.text = str(enemy.enemy.position)
|
||||||
Loading…
Reference in New Issue