From be151c53170dff763d49860f5a178327a8656da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Sun, 3 May 2026 12:14:03 +0800 Subject: [PATCH] code --- components/Characters/EnergyBlock.tscn | 13 +++ components/Characters/Rooster.tscn | 18 ++--- components/Scenes/UI.tscn | 94 ++++++++++++---------- components/UI/BossBar.tscn | 30 +++---- scripts/Contents/Characters/EnergyBlock.gd | 7 +- scripts/Statemachine/UIState.gd | 2 +- styleboxes/centerRight.tres | 2 +- 7 files changed, 92 insertions(+), 74 deletions(-) diff --git a/components/Characters/EnergyBlock.tscn b/components/Characters/EnergyBlock.tscn index 861adba..9eb9939 100644 --- a/components/Characters/EnergyBlock.tscn +++ b/components/Characters/EnergyBlock.tscn @@ -17,6 +17,11 @@ animations = [{ "speed": 5.0 }] +[sub_resource type="LabelSettings" id="LabelSettings_v78o6"] +font_size = 40 +font_color = Color(1, 0, 0, 1) +outline_size = 1 + [sub_resource type="RectangleShape2D" id="RectangleShape2D_8do1r"] size = Vector2(112, 112) @@ -34,6 +39,14 @@ position = Vector2(0, -1.0000038) scale = Vector2(0.8514976, 0.8514976) texture = ExtResource("3_v78o6") +[node name="Label" type="Label" parent="texture/staticBackground" index="0" unique_id=1072410685] +offset_left = -65.76649 +offset_top = -29.360033 +offset_right = 68.23351 +offset_bottom = 29.639967 +text = "BOSS 1" +label_settings = SubResource("LabelSettings_v78o6") + [node name="hitbox" parent="texture/hurtbox" index="0"] shape = SubResource("RectangleShape2D_8do1r") diff --git a/components/Characters/Rooster.tscn b/components/Characters/Rooster.tscn index 7e4451b..64c5a86 100644 --- a/components/Characters/Rooster.tscn +++ b/components/Characters/Rooster.tscn @@ -9,8 +9,7 @@ [ext_resource type="PackedScene" uid="uid://bbrllsqjmx0ie" path="res://components/Weapons/DaoStatue.tscn" id="5_fkh3f"] [ext_resource type="AudioStream" uid="uid://dmxh3bpk8vyy5" path="res://resources/sounds/effect/Coin.mp3" id="5_xnbhq"] [ext_resource type="AudioStream" uid="uid://4wuuf1osk0yv" path="res://resources/sounds/effect/Low Boing.wav" id="6_m5px1"] -[ext_resource type="Texture2D" uid="uid://fn8qx72clh38" path="res://resources/characters/cock/rooster-a.svg" id="8_da2ca"] -[ext_resource type="Texture2D" uid="uid://ci2ik43ce82uy" path="res://resources/characters/cock/rooster-b.svg" id="9_0omr3"] +[ext_resource type="Texture2D" uid="uid://dwwpkn4q07ja2" path="res://icon.svg" id="10_0omr3"] [sub_resource type="Curve" id="Curve_da2ca"] _data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] @@ -66,7 +65,7 @@ animations = [{ animations = [{ "frames": [{ "duration": 1.0, -"texture": ExtResource("8_da2ca") +"texture": ExtResource("10_0omr3") }], "loop": true, "name": &"idle", @@ -74,10 +73,7 @@ animations = [{ }, { "frames": [{ "duration": 1.0, -"texture": ExtResource("8_da2ca") -}, { -"duration": 1.0, -"texture": ExtResource("9_0omr3") +"texture": ExtResource("10_0omr3") }], "loop": true, "name": &"walk", @@ -128,16 +124,16 @@ sprite_frames = SubResource("SpriteFrames_4v2ol") animation = &"walk" [node name="staticAnimation" parent="texture" index="1"] -position = Vector2(0, -24) +position = Vector2(0, -17) sprite_frames = SubResource("SpriteFrames_jluqw") -animation = &"idle" +animation = &"walk" [node name="hitbox" parent="texture/hurtbox" index="0"] -position = Vector2(8, -28) +position = Vector2(-2, -18) shape = SubResource("CircleShape2D_h1v0q") [node name="normal" type="Node2D" parent="texture/weapons" index="0" unique_id=1939030218] -position = Vector2(56, -69) +position = Vector2(1, -13) [node name="statebar" parent="." index="5" node_paths=PackedStringArray("entity")] position = Vector2(0, -150) diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index 064db34..ade1e84 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -2,26 +2,29 @@ [ext_resource type="PackedScene" uid="uid://ofpg5s3j7esv" path="res://components/UI/BossBar.tscn" id="1_2pe58"] [ext_resource type="Script" uid="uid://bph6blsdbiklk" path="res://scripts/Statemachine/UIState.gd" id="1_f00a6"] -[ext_resource type="StyleBox" uid="uid://dx0udq8nv2ec0" path="res://styleboxes/topPanel.tres" id="3_kep0k"] [ext_resource type="PackedScene" uid="uid://bbm8l3hr4ihar" path="res://components/UI/ItemShow.tscn" id="3_o2oi4"] [ext_resource type="StyleBox" uid="uid://8pg3ry3y5wjv" path="res://styleboxes/centerRight.tres" id="5_3hym1"] +[ext_resource type="PackedScene" uid="uid://ufl4kek8hrmt" path="res://components/UI/SkillIcon.tscn" id="5_k2y4g"] +[ext_resource type="PackedScene" uid="uid://d1ulrvupa76ap" path="res://components/UI/ColorBar.tscn" id="6_oy0yg"] [ext_resource type="Texture2D" uid="uid://k13cte17httt" path="res://resources/items/energy.svg" id="7_2om12"] -[ext_resource type="PackedScene" uid="uid://b07gqo6df0r5y" path="res://components/UI/VerticalColorBar.tscn" id="8_f4j2b"] [ext_resource type="StyleBox" uid="uid://ddnjus87wwlm8" path="res://styleboxes/leftPanel.tres" id="11_67ghp"] -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_12otr"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kp2r0"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_k2y4g"] +content_margin_left = 10.0 +content_margin_top = 10.0 +content_margin_right = 10.0 +content_margin_bottom = 10.0 bg_color = Color(0, 0, 0, 0.5) +border_width_left = 3 +border_width_top = 3 +border_width_right = 3 +border_width_bottom = 3 +border_color = Color(0, 0, 0, 0.75) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_left = 10 -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kgnwf"] -bg_color = Color(1, 0, 0, 0.5) - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_egr4c"] -bg_color = Color(0, 1, 0, 0.5) - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1xshu"] -bg_color = Color(1, 1, 1, 1) +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_12otr"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ri8gw"] content_margin_left = 20.0 @@ -130,21 +133,21 @@ grow_vertical = 2 [node name="bossbar" parent="root" unique_id=1188147012 instance=ExtResource("1_2pe58")] unique_name_in_owner = true layout_mode = 1 -metadata/_edit_lock_ = true [node name="items" type="PanelContainer" parent="root" unique_id=889148256] z_index = 1 z_as_relative = false layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -46.0 -offset_top = -3.0 -offset_right = 46.0 -offset_bottom = 37.0 -grow_horizontal = 2 -theme_override_styles/panel = ExtResource("3_kep0k") +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -201.0 +offset_top = -44.0 +grow_horizontal = 0 +grow_vertical = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_k2y4g") metadata/_edit_lock_ = true [node name="items" type="HBoxContainer" parent="root/items" unique_id=1102895760] @@ -180,20 +183,19 @@ type = 4 z_index = 1 z_as_relative = false layout_mode = 1 -anchors_preset = -1 -anchor_left = 1.0 -anchor_top = 0.4 -anchor_right = 1.0 -anchor_bottom = 0.6 -offset_left = -33.0 -offset_top = -70.0 -offset_right = 3.0 -offset_bottom = 70.0 -grow_horizontal = 0 -grow_vertical = 2 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -23.0 +offset_top = -46.0 +offset_right = 23.0 +grow_horizontal = 2 +grow_vertical = 0 theme_override_styles/panel = ExtResource("5_3hym1") -[node name="wrapper" type="HBoxContainer" parent="root/energy" unique_id=2143098490] +[node name="wrapper" type="VBoxContainer" parent="root/energy" unique_id=1356612647] layout_mode = 2 theme_override_constants/separation = 10 @@ -201,12 +203,22 @@ theme_override_constants/separation = 10 layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxEmpty_12otr") -[node name="skillContainer" type="VBoxContainer" parent="root/energy/wrapper/skills" unique_id=939257941] +[node name="skillContainer" type="HBoxContainer" parent="root/energy/wrapper/skills" unique_id=51208875] unique_name_in_owner = true layout_mode = 2 +theme_override_constants/separation = 10 alignment = 1 -[node name="container" type="VBoxContainer" parent="root/energy/wrapper" unique_id=1760772344] +[node name="SkillIconBase" parent="root/energy/wrapper/skills/skillContainer" unique_id=1090815103 instance=ExtResource("5_k2y4g")] +layout_mode = 2 + +[node name="SkillIconBase2" parent="root/energy/wrapper/skills/skillContainer" unique_id=592440106 instance=ExtResource("5_k2y4g")] +layout_mode = 2 + +[node name="SkillIconBase3" parent="root/energy/wrapper/skills/skillContainer" unique_id=1424612490 instance=ExtResource("5_k2y4g")] +layout_mode = 2 + +[node name="container" type="HBoxContainer" parent="root/energy/wrapper" unique_id=1689009576] layout_mode = 2 theme_override_constants/separation = 10 alignment = 1 @@ -223,14 +235,10 @@ size_flags_vertical = 4 texture = ExtResource("7_2om12") expand_mode = 1 -[node name="percent" parent="root/energy/wrapper/container" unique_id=936708847 instance=ExtResource("8_f4j2b")] +[node name="percent" parent="root/energy/wrapper/container" unique_id=1940891290 instance=ExtResource("6_oy0yg")] unique_name_in_owner = true +custom_minimum_size = Vector2(200, 0) layout_mode = 2 -size_flags_vertical = 3 -backBox = SubResource("StyleBoxFlat_kp2r0") -middleBox1 = SubResource("StyleBoxFlat_kgnwf") -middleBox2 = SubResource("StyleBoxFlat_egr4c") -frontBox = SubResource("StyleBoxFlat_1xshu") [node name="fields" type="PanelContainer" parent="root" unique_id=1795021225] modulate = Color(1, 1, 1, 0) diff --git a/components/UI/BossBar.tscn b/components/UI/BossBar.tscn index c362270..198255c 100644 --- a/components/UI/BossBar.tscn +++ b/components/UI/BossBar.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=9 format=3 uid="uid://ofpg5s3j7esv"] +[gd_scene format=3 uid="uid://ofpg5s3j7esv"] -[ext_resource type="Script" path="res://scripts/Statemachine/BossBar.gd" id="1_hkj6o"] +[ext_resource type="Script" uid="uid://bxwgt7rlke3xf" path="res://scripts/Statemachine/BossBar.gd" id="1_hkj6o"] [ext_resource type="PackedScene" uid="uid://d1ulrvupa76ap" path="res://components/UI/ColorBar.tscn" id="1_uxey7"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0aktd"] @@ -43,7 +43,7 @@ font_size = 12 font_color = Color(0, 0, 0, 1) outline_size = 2 -[node name="BossBar" type="Control"] +[node name="BossBar" type="Control" unique_id=367886665] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -52,14 +52,14 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_hkj6o") -[node name="health" parent="." instance=ExtResource("1_uxey7")] +[node name="health" parent="." unique_id=1990575388 instance=ExtResource("1_uxey7")] unique_name_in_owner = true layout_mode = 1 anchors_preset = -1 anchor_left = 0.3 -anchor_top = 0.95 +anchor_top = 0.1 anchor_right = 0.7 -anchor_bottom = 0.95 +anchor_bottom = 0.1 offset_top = -30.0 offset_right = 0.0 offset_bottom = 0.0 @@ -71,7 +71,7 @@ middleBox1 = SubResource("StyleBoxFlat_gor8g") middleBox2 = SubResource("StyleBoxFlat_g3ag3") frontBox = SubResource("StyleBoxFlat_bua1u") -[node name="panel" type="PanelContainer" parent="health"] +[node name="panel" type="PanelContainer" parent="health" unique_id=1896086634] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -80,43 +80,43 @@ grow_horizontal = 2 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBoxEmpty_ar00p") -[node name="label" type="HBoxContainer" parent="health/panel"] +[node name="label" type="HBoxContainer" parent="health/panel" unique_id=2018524242] layout_mode = 2 alignment = 1 -[node name="name" type="Label" parent="health/panel/label"] +[node name="name" type="Label" parent="health/panel/label" unique_id=866259258] unique_name_in_owner = true layout_mode = 2 text = "BossName" label_settings = SubResource("LabelSettings_esyuk") -[node name="levelLabel" type="HBoxContainer" parent="health/panel/label"] +[node name="levelLabel" type="HBoxContainer" parent="health/panel/label" unique_id=1821665421] unique_name_in_owner = true layout_mode = 2 -[node name="lv" type="Label" parent="health/panel/label/levelLabel"] +[node name="lv" type="Label" parent="health/panel/label/levelLabel" unique_id=59180680] layout_mode = 2 text = "Lv." label_settings = SubResource("LabelSettings_esyuk") -[node name="level" type="Label" parent="health/panel/label/levelLabel"] +[node name="level" type="Label" parent="health/panel/label/levelLabel" unique_id=1664839059] unique_name_in_owner = true layout_mode = 2 text = "100" label_settings = SubResource("LabelSettings_esyuk") -[node name="sep" type="Label" parent="health/panel/label"] +[node name="sep" type="Label" parent="health/panel/label" unique_id=1133229167] layout_mode = 2 text = " - " label_settings = SubResource("LabelSettings_esyuk") -[node name="value" type="Label" parent="health/panel/label"] +[node name="value" type="Label" parent="health/panel/label" unique_id=1832455864] unique_name_in_owner = true layout_mode = 2 text = "percent" label_settings = SubResource("LabelSettings_esyuk") -[node name="percent" type="Label" parent="health/panel/label"] +[node name="percent" type="Label" parent="health/panel/label" unique_id=1148693228] layout_mode = 2 text = "%" label_settings = SubResource("LabelSettings_esyuk") diff --git a/scripts/Contents/Characters/EnergyBlock.gd b/scripts/Contents/Characters/EnergyBlock.gd index 26a0bdf..efab7eb 100644 --- a/scripts/Contents/Characters/EnergyBlock.gd +++ b/scripts/Contents/Characters/EnergyBlock.gd @@ -17,10 +17,11 @@ func register(): sprintMultiplier = 30 func ai(): PresetEntityAI.distanceAttack(self , currentFocusedBoss, 0, 300, 0) - for i in 6: - tryAttack(i + 1, [3, 4]) + PresetEntityAI.distanceAttack(self , currentFocusedBoss, 500, 1000, 1) + for i in 5: + tryAttack(i + 2, [3, 4]) if 1 not in attackingStates: - PresetEntityAI.follow(self , currentFocusedBoss) + PresetEntityAI.follow(self , currentFocusedBoss, 200) func attack(type: int): if type == 0: for bullet in BulletBase.generate(ComponentManager.getBullet("SwingSword"), self , getTrackingAnchor(), getTrackingAnchor().angle_to_point(currentFocusedPosition)): diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index 8b818ef..795b6df 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -10,7 +10,7 @@ static var currentPanel: FullscreenPanelBase static var panels: Control static var energyPercent: ColorBar static var itemCollect: VBoxContainer -static var skillIconContainer: VBoxContainer +static var skillIconContainer: HBoxContainer static var tips: VBoxContainer func _ready(): diff --git a/styleboxes/centerRight.tres b/styleboxes/centerRight.tres index d50b729..7f3b119 100644 --- a/styleboxes/centerRight.tres +++ b/styleboxes/centerRight.tres @@ -12,4 +12,4 @@ border_width_right = 3 border_width_bottom = 3 border_color = Color(0, 0, 0, 0.75) corner_radius_top_left = 10 -corner_radius_bottom_left = 10 +corner_radius_top_right = 10