1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-06 03:37:13 +08:00

feat(武器系统): 重构武器信息显示逻辑并添加新功能

重构武器卡片的信息显示逻辑,使用ItemShow组件替代原有Label显示
添加武器升级和镶嵌前的预览功能
为武器描述添加升级前后数值对比显示
新增FREQUENCY数据类型支持
统一子弹生命周期参数为lifeTime
This commit is contained in:
2025-10-01 07:58:09 +08:00
parent 97a4fb1fc2
commit d0e3564933
18 changed files with 64 additions and 91 deletions
+1
View File
@@ -5,6 +5,7 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7cv4k"]
[node name="EffectBase" type="Node2D"]
z_index = 1
script = ExtResource("1_pt2rk")
[node name="sounds" type="Node2D" parent="."]
+8 -34
View File
@@ -1,11 +1,10 @@
[gd_scene load_steps=8 format=3 uid="uid://ckq2cq6m23hq3"]
[gd_scene load_steps=7 format=3 uid="uid://ckq2cq6m23hq3"]
[ext_resource type="Script" path="res://scripts/Structs/Weapon.gd" id="1_g802t"]
[ext_resource type="Theme" uid="uid://dhvs6urgf6jr5" path="res://themes/main.tres" id="2_fwkd3"]
[ext_resource type="PackedScene" uid="uid://ch81vd3awkmhk" path="res://components/UI/WeaponName.tscn" id="3_qv0b1"]
[ext_resource type="Texture2D" uid="uid://k13cte17httt" path="res://resources/items/energy.svg" id="4_6gohw"]
[ext_resource type="Texture2D" uid="uid://dw0g7cb4skd5s" path="res://resources/items/beachball.svg" id="5_pr18h"]
[ext_resource type="Texture2D" uid="uid://7jhhyoinptns" path="res://resources/items/soul.svg" id="6_tygah"]
[ext_resource type="PackedScene" uid="uid://bbm8l3hr4ihar" path="res://components/UI/ItemShow.tscn" id="4_k01vb"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2ewr"]
content_margin_left = 30.0
@@ -103,46 +102,21 @@ unique_name_in_owner = true
layout_mode = 2
text = "0.0"
[node name="beachballInfo" type="HBoxContainer" parent="container/info/infos"]
layout_mode = 2
alignment = 1
[node name="icon" type="TextureRect" parent="container/info/infos/beachballInfo"]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("5_pr18h")
expand_mode = 1
stretch_mode = 5
[node name="beachball" type="Label" parent="container/info/infos/beachballInfo"]
[node name="beachball" parent="container/info/infos" instance=ExtResource("4_k01vb")]
unique_name_in_owner = true
layout_mode = 2
text = "500"
[node name="soulInfo" type="HBoxContainer" parent="container/info/infos"]
layout_mode = 2
alignment = 1
[node name="icon" type="TextureRect" parent="container/info/infos/soulInfo"]
custom_minimum_size = Vector2(15, 15)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("6_tygah")
expand_mode = 1
stretch_mode = 5
type = 3
[node name="soul" type="Label" parent="container/info/infos/soulInfo"]
[node name="soul" parent="container/info/infos" instance=ExtResource("4_k01vb")]
unique_name_in_owner = true
layout_mode = 2
text = "1"
size_flags_horizontal = 4
type = 4
[node name="name" parent="container/info" instance=ExtResource("3_qv0b1")]
unique_name_in_owner = true
layout_mode = 2
displayName = "未命名饲料"
soulLevelColorMap = {
1: Color(1, 1, 1, 1),
2: Color(0.489296, 1, 0.548293, 1),
@@ -155,7 +129,7 @@ soulLevelColorMap = {
unique_name_in_owner = true
layout_mode = 2
bbcode_enabled = true
text = "[center]造成[color=cyan]10[/color]→[color=yellow]10[/color]点伤害。[/center]"
text = "[center]造成[color=cyan]10[/color]点伤害。[/center]"
fit_content = true
[node name="costs" type="GridContainer" parent="container"]
+1
View File
@@ -20,6 +20,7 @@ animations = [{
[node name="PurpleCrystal" instance=ExtResource("1_45mh7")]
script = ExtResource("2_4lnlm")
displayName = "水晶"
lifeTime = 1000.0
[node name="texture" parent="." index="0"]
sprite_frames = SubResource("SpriteFrames_r86b3")
+1 -1
View File
@@ -24,7 +24,7 @@ script = ExtResource("2_it0pa")
displayName = "微型水晶"
speed = 15.0
damage = 0.5
lifeDistance = 1400.0
lifeTime = 1000.0
[node name="texture" parent="." index="0"]
scale = Vector2(0.6, 0.6)
+16 -8
View File
@@ -1,9 +1,9 @@
[gd_scene load_steps=9 format=3 uid="uid://b4y1kq7yger4h"]
[gd_scene load_steps=11 format=3 uid="uid://b4y1kq7yger4h"]
[ext_resource type="PackedScene" uid="uid://bcvuuy2m0pke0" path="res://components/Abstracts/EffectBase.tscn" id="1_fwc1i"]
[sub_resource type="Curve" id="Curve_snh3o"]
_data = [Vector2(0.502092, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
_data = [Vector2(0.6, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_tr6r8"]
@@ -16,8 +16,15 @@ colors = PackedColorArray(1, 0.75, 0.75, 1, 1, 0.8625, 0.75, 1, 1, 0.970833, 0.7
[sub_resource type="GradientTexture1D" id="GradientTexture1D_5ra8e"]
gradient = SubResource("Gradient_v4pid")
[sub_resource type="Curve" id="Curve_bqxyt"]
_data = [Vector2(0.4, 0), 162.223, 0.0, 1, 0, Vector2(0.8, 1), 0.0, 162.223, 0, 1]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_xd1pr"]
curve = SubResource("Curve_bqxyt")
[sub_resource type="Curve" id="Curve_a27b5"]
_data = [Vector2(0.497908, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
_data = [Vector2(0.6, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_sgxbq"]
@@ -28,11 +35,12 @@ particle_flag_disable_z = true
angle_min = 1.07288e-05
angle_max = 360.0
spread = 180.0
initial_velocity_min = 80.0
initial_velocity_max = 120.0
initial_velocity_min = 150.0
initial_velocity_max = 180.0
gravity = Vector3(0, 0, 0)
damping_min = 50.0
damping_max = 50.0
damping_min = 1000.0
damping_max = 1000.0
damping_curve = SubResource("CurveTexture_xd1pr")
scale_min = 3.0
scale_max = 6.0
scale_curve = SubResource("CurveTexture_sgxbq")
@@ -43,5 +51,5 @@ alpha_curve = SubResource("CurveTexture_tr6r8")
[node name="particles" parent="." index="1"]
z_index = 1
amount = 150
amount = 100
process_material = SubResource("ParticleProcessMaterial_yytbm")
+1 -4
View File
@@ -30,13 +30,10 @@ stream = ExtResource("4_cb5nh")
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_qe8gb")
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
text = "200.0"
[node name="name" parent="container/info" index="2"]
displayName = "湮灭激光"
quality = 2
typeTopic = 1
[node name="description" parent="container" index="2"]
text = "[center]每[color=cyan]0.10[/color]→[color=yellow]0.10[/color]秒造成[color=cyan]40[/color]→[color=yellow]45[/color]点伤害。[/center]"
text = "[center]每[color=cyan]0.10[/color]秒造成[color=cyan]40[/color]点伤害。[/center]"
-4
View File
@@ -26,11 +26,7 @@ cooldown = 50.0
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_ghn43")
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
text = "1.0"
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "400"
[node name="name" parent="container/info" index="2"]
displayName = "链式机枪"
-4
View File
@@ -37,11 +37,7 @@ stream = ExtResource("4_c5xse")
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_ou6jo")
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
text = "50.0"
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "200"
[node name="name" parent="container/info" index="2"]
displayName = "彩虹旗"
-2
View File
@@ -30,8 +30,6 @@ cooldown = 200.0
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_kiocs")
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "600"
[node name="name" parent="container/info" index="2"]
displayName = "彩虹猫之刃"
-4
View File
@@ -26,11 +26,7 @@ debugRebuild = true
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_u2d30")
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
text = "2.0"
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "750"
[node name="name" parent="container/info" index="2"]
displayName = "蘑菇矿挖爪"
-4
View File
@@ -27,11 +27,7 @@ debugRebuild = true
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_5nh8i")
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
text = "120.0"
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "600"
[node name="name" parent="container/info" index="2"]
displayName = "核弹控制器"
-2
View File
@@ -21,8 +21,6 @@ stream = ExtResource("4_16daa")
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_wgtcw")
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "250"
[node name="name" parent="container/info" index="2"]
displayName = "紫水晶簇"
-2
View File
@@ -25,8 +25,6 @@ volume_db = 20.0
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("3_nq3bo")
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
text = "150.0"
[node name="name" parent="container/info" index="2"]
displayName = "bilioicik"
-4
View File
@@ -29,11 +29,7 @@ cooldown = 500.0
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("3_wfty8")
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
text = "10.0"
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "400"
[node name="name" parent="container/info" index="2"]
displayName = "矢量核心"
-2
View File
@@ -26,8 +26,6 @@ cooldown = 50.0
[node name="avatar" parent="container/info" index="0"]
texture = ExtResource("2_kcegs")
[node name="beachball" parent="container/info/infos/beachballInfo" index="1"]
text = "300"
[node name="name" parent="container/info" index="2"]
displayName = "代达罗斯风暴魂"
+1
View File
@@ -6,6 +6,7 @@ extends FullscreenPanelBase
func beforeOpen(_args: Array = []):
for weapon in UIState.player.weapons:
weapon.show()
weapon.rebuildInfo()
UIState.player.weaponStore.remove_child(weapon)
box.add_child(weapon)
func afterClose():
+33 -15
View File
@@ -23,8 +23,8 @@ class_name Weapon
@onready var avatarRect: TextureRect = $"%avatar"
@onready var nameLabel: WeaponName = $"%name"
@onready var energyLabel: Label = $"%energy"
@onready var beachballLabel: Label = $"%beachball"
@onready var soulLabel: Label = $"%soul"
@onready var beachball: ItemShow = $"%beachball"
@onready var soul: ItemShow = $"%soul"
@onready var descriptionLabel: RichTextLabel = $"%description"
@onready var updateBtn: Button = $"%updateBtn"
@onready var extractBtn: Button = $"%extractBtn"
@@ -40,6 +40,12 @@ func _ready():
cooldownTimer = CooldownTimer.new()
cooldownTimer.cooldown = cooldown
originalStore = store
updateBtn.mouse_entered.connect(func(): rebuildInfo(true))
updateBtn.mouse_exited.connect(func(): rebuildInfo())
extractBtn.mouse_entered.connect(func(): rebuildInfo(true))
extractBtn.mouse_exited.connect(func(): rebuildInfo())
inlayBtn.mouse_entered.connect(func(): rebuildInfo(true))
inlayBtn.mouse_exited.connect(func(): rebuildInfo())
updateBtn.pressed.connect(
func():
apply(UIState.player)
@@ -90,17 +96,19 @@ func _physics_process(_delta):
if debugRebuild:
rebuildInfo()
func allHad(entity: EntityBase) -> bool:
return entity.inventory[ItemStore.ItemType.BEACHBALL] >= costBeachball
func apply(entity: EntityBase):
var allHave = allHad(entity)
if allHave:
func canUpdate():
return UIState.player.hasItem({ItemStore.ItemType.BEACHBALL: costBeachball})
func canInlay():
return UIState.player.hasItem({ItemStore.ItemType.SOUL: soulLevel})
func apply(entity: EntityBase) -> bool:
if canUpdate():
level += 1
entity.inventory[ItemStore.ItemType.BEACHBALL] -= costBeachball
updateStore(level, entity)
costBeachball = floor(GameRule.weaponUpdateCost * costBeachball)
rebuildInfo()
return allHave
rebuildInfo(true)
return true
return false
func updateStore(to: int, entity: EntityBase):
store = update(to, originalStore.duplicate(), entity)
func multipiler() -> float:
@@ -108,7 +116,7 @@ func multipiler() -> float:
return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION)
else:
return 1
func rebuildInfo():
func rebuildInfo(showNext: bool = false):
avatarRect.texture = avatarTexture
nameLabel.displayName = displayName
nameLabel.quality = quality
@@ -116,9 +124,12 @@ func rebuildInfo():
nameLabel.soulLevel = soulLevel
nameLabel.level = level
energyLabel.text = "%.1f" % needEnergy
beachballLabel.text = str(costBeachball)
soulLabel.text = str(soulLevel)
descriptionLabel.text = buildDescription()
beachball.count = costBeachball
soul.count = soulLevel
if is_instance_valid(UIState.player):
beachball.enough = canUpdate()
soul.enough = canInlay()
descriptionLabel.text = buildDescription(showNext && (canUpdate() || canInlay()))
func formatValue(value: Variant, type: FieldStore.DataType) -> String:
if type == FieldStore.DataType.VALUE:
return "%.2f" % value
@@ -128,9 +139,11 @@ func formatValue(value: Variant, type: FieldStore.DataType) -> String:
return ("%d" % (value * 100)) + "%"
elif type == FieldStore.DataType.ANGLE:
return "%.1f°" % value
elif type == FieldStore.DataType.FREQUENCY:
return "%.1fHz" % value
else:
return str(value)
func buildDescription() -> String:
func buildDescription(showNext: bool = false) -> String:
var current = store
var next = update(level + 1, originalStore.duplicate(), UIState.player)
var result = descriptionTemplate
@@ -140,7 +153,12 @@ func buildDescription() -> String:
var type = storeType.get(key, FieldStore.DataType.VALUE)
data = formatValue(data, type)
nextData = formatValue(nextData, type)
result = result.replace("$" + key, "[color=cyan]%s[/color]→[color=yellow]%s[/color]" % [data, nextData])
var text
if showNext:
text = "[color=cyan]%s[/color]→[color=yellow]%s[/color]" % [data, nextData]
else:
text = "[color=cyan]%s[/color]" % data
result = result.replace("$" + key, text)
return "[center]%s[/center]" % result
func readStore(key: String, default: Variant = null):
return store.get(key, default)
+2 -1
View File
@@ -5,7 +5,8 @@ enum DataType {
VALUE,
INTEGER,
PERCENT,
ANGLE
ANGLE,
FREQUENCY
}
enum Entity {
MAX_HEALTH,