1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-11 22:27:12 +08:00

feat(武器系统): 添加灵魂等级机制并重构武器升级逻辑

- 在UI中添加灵魂资源显示和操作按钮
- 修改武器升级公式加入灵魂等级系数
- 实现灵魂的提取和镶嵌功能
- 为武器卡牌添加灵魂等级颜色映射
- 初始化玩家灵魂资源为10个
This commit is contained in:
2025-09-20 07:01:17 +08:00
parent ac7183e78b
commit 06fdfd1586
10 changed files with 91 additions and 25 deletions
+27 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=3 uid="uid://ckq2cq6m23hq3"] [gd_scene load_steps=9 format=3 uid="uid://ckq2cq6m23hq3"]
[ext_resource type="Script" path="res://scripts/Structs/Weapon.gd" id="1_g802t"] [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="Theme" uid="uid://dhvs6urgf6jr5" path="res://themes/main.tres" id="2_fwkd3"]
@@ -6,6 +6,7 @@
[ext_resource type="Texture2D" uid="uid://dwwpkn4q07ja2" path="res://icon.svg" id="3_vtucy"] [ext_resource type="Texture2D" uid="uid://dwwpkn4q07ja2" path="res://icon.svg" id="3_vtucy"]
[ext_resource type="Texture2D" uid="uid://k13cte17httt" path="res://resources/items/energy.svg" id="4_6gohw"] [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://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"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2ewr"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2ewr"]
content_margin_left = 30.0 content_margin_left = 30.0
@@ -122,10 +123,35 @@ unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "500" 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
[node name="soul" type="Label" parent="container/info/infos/soulInfo"]
unique_name_in_owner = true
layout_mode = 2
text = "1"
[node name="name" parent="container/info" instance=ExtResource("3_qv0b1")] [node name="name" parent="container/info" instance=ExtResource("3_qv0b1")]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
displayName = "未命名饲料" displayName = "未命名饲料"
soulLevelColorMap = {
1: Color(1, 1, 1, 1),
2: Color(0.489296, 1, 0.548293, 1),
3: Color(0.584242, 0.651083, 1, 1),
4: Color(1, 0.325579, 0.996599, 1),
5: Color(1, 0.57713, 0.247421, 1)
}
[node name="description" type="RichTextLabel" parent="container"] [node name="description" type="RichTextLabel" parent="container"]
unique_name_in_owner = true unique_name_in_owner = true
+5
View File
@@ -177,6 +177,11 @@ unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
type = 3 type = 3
[node name="soul" parent="root/items/items" instance=ExtResource("3_o2oi4")]
unique_name_in_owner = true
layout_mode = 2
type = 4
[node name="energy" type="PanelContainer" parent="root"] [node name="energy" type="PanelContainer" parent="root"]
z_index = 1 z_index = 1
z_as_relative = false z_as_relative = false
+2 -2
View File
@@ -3,8 +3,8 @@ extends Weapon
class_name BigLaserWeapon class_name BigLaserWeapon
func update(to: int, origin: Dictionary, _entity: EntityBase): func update(to: int, origin: Dictionary, _entity: EntityBase):
origin["atk"] += 5 * to origin["atk"] += 5 * to * soulLevel
origin["time"] /= 1.05 origin["time"] /= 1.05 ** soulLevel * to
return origin return origin
func attack(entity: EntityBase): func attack(entity: EntityBase):
var weaponPos = entity.findWeaponAnchor("normal") var weaponPos = entity.findWeaponAnchor("normal")
+5 -5
View File
@@ -3,11 +3,11 @@ extends Weapon
class_name LGBTWeapon class_name LGBTWeapon
func update(to: int, origin: Dictionary, _entity: EntityBase): func update(to: int, origin: Dictionary, _entity: EntityBase):
origin["atk"] += 5 * to origin["atk"] += 5 * to * soulLevel
origin["count"] += to origin["count"] += to * soulLevel
origin["power"] += 0.05 * level origin["power"] += 0.05 * to * soulLevel
origin["trace"] += 0.25 * level origin["trace"] += 0.25 * to * soulLevel
origin["angle"] /= 1.05 * level origin["angle"] /= 1.05 ** soulLevel * to
return origin return origin
func attack(entity: EntityBase): func attack(entity: EntityBase):
var weaponPos = entity.findWeaponAnchor("normal") var weaponPos = entity.findWeaponAnchor("normal")
+3 -3
View File
@@ -2,9 +2,9 @@
extends Weapon extends Weapon
func update(to: int, origin: Dictionary, _entity: EntityBase): func update(to: int, origin: Dictionary, _entity: EntityBase):
origin["atk"] += 0.5 * to origin["atk"] += 1 * to * soulLevel
origin["rate"] += 0.02 * to origin["rate"] += 0.04 * to * soulLevel
origin["count"] += 1 * level origin["count"] += 1 * to * soulLevel
return origin return origin
func attack(entity: EntityBase): func attack(entity: EntityBase):
var weaponPos = entity.findWeaponAnchor("normal") var weaponPos = entity.findWeaponAnchor("normal")
+1 -1
View File
@@ -3,7 +3,7 @@ extends Weapon
class_name PurpleCrystalWeapon class_name PurpleCrystalWeapon
func update(to: int, origin: Dictionary, _entity: EntityBase): func update(to: int, origin: Dictionary, _entity: EntityBase):
origin["atk"] += 5 * to origin["atk"] += 5 * to * soulLevel
return origin return origin
func attack(entity: EntityBase): func attack(entity: EntityBase):
var weaponPos = entity.findWeaponAnchor("normal") var weaponPos = entity.findWeaponAnchor("normal")
+3 -3
View File
@@ -3,9 +3,9 @@ extends Weapon
class_name VectorStarWeapon class_name VectorStarWeapon
func update(to: int, origin: Dictionary, _entity: EntityBase): func update(to: int, origin: Dictionary, _entity: EntityBase):
origin["atk"] += 5 * to origin["atk"] += 5 * to * soulLevel
origin["forwardtime"] /= 1.05 * to origin["forwardtime"] /= 1.05 ** soulLevel * to
origin["maxcount"] += 1 * level origin["maxcount"] += 1 * level * soulLevel
return origin return origin
func attack(entity: EntityBase): func attack(entity: EntityBase):
var weaponPos = entity.findWeaponAnchor("normal") var weaponPos = entity.findWeaponAnchor("normal")
+16 -1
View File
@@ -57,7 +57,7 @@ var inventory = {
ItemStore.ItemType.BASKETBALL: 500, ItemStore.ItemType.BASKETBALL: 500,
ItemStore.ItemType.APPLE: 5, ItemStore.ItemType.APPLE: 5,
ItemStore.ItemType.BEACHBALL: 0, ItemStore.ItemType.BEACHBALL: 0,
ItemStore.ItemType.SOUL: 0, ItemStore.ItemType.SOUL: 10,
} }
var inventoryMax = { var inventoryMax = {
ItemStore.ItemType.BASEBALL: INF, # 无限 ItemStore.ItemType.BASEBALL: INF, # 无限
@@ -349,6 +349,21 @@ func playSound(type: String):
func tryKill(): func tryKill():
kill() kill()
await tryDie() await tryDie()
func hasItem(items: Dictionary):
for item in items:
if inventory[item] < items[item]:
return false
return true
func useItem(items: Dictionary):
print(items)
var state = hasItem(items)
if state:
for item in items:
inventory[item] -= items[item]
return state
func getItem(items: Dictionary):
for item in items:
inventory[item] += items[item]
func getTrackingAnchor() -> Vector2: func getTrackingAnchor() -> Vector2:
return hurtbox.get_node("hitbox").global_position return hurtbox.get_node("hitbox").global_position
+6 -6
View File
@@ -16,17 +16,17 @@ enum TypeTopic {
MAGIC, MAGIC,
} }
enum SoulLevel { enum SoulLevel {
NORMALIZE, NORMALIZE = 1,
ADD, ADD = 2,
MULTIPLY, MULTIPLY = 3,
EXPONENT, EXPONENT = 4,
INFINITY, INFINITY = 5,
} }
@export var displayName: String = "未命名武器" @export var displayName: String = "未命名武器"
@export var quality: Quality = Quality.COMMON @export var quality: Quality = Quality.COMMON
@export var typeTopic: TypeTopic = TypeTopic.IMPACT @export var typeTopic: TypeTopic = TypeTopic.IMPACT
@export var soulLevel: SoulLevel = SoulLevel.NORMALIZE @export var soulLevel: int = SoulLevel.NORMALIZE
@export var level: int = 0 @export var level: int = 0
@export var qualityColorMap = { @export var qualityColorMap = {
Quality.WASTE: Color(), Quality.WASTE: Color(),
+23 -3
View File
@@ -6,7 +6,7 @@ class_name Weapon
@export var displayName: String = "未命名饲料" @export var displayName: String = "未命名饲料"
@export var quality: WeaponName.Quality = WeaponName.Quality.COMMON @export var quality: WeaponName.Quality = WeaponName.Quality.COMMON
@export var typeTopic: WeaponName.TypeTopic = WeaponName.TypeTopic.IMPACT @export var typeTopic: WeaponName.TypeTopic = WeaponName.TypeTopic.IMPACT
@export var soulLevel: WeaponName.SoulLevel = WeaponName.SoulLevel.NORMALIZE @export var soulLevel: int = 1
@export var costBeachball: int = 500 @export var costBeachball: int = 500
@export var store: Dictionary = { @export var store: Dictionary = {
"atk": 10 "atk": 10
@@ -24,8 +24,11 @@ class_name Weapon
@onready var nameLabel: WeaponName = $"%name" @onready var nameLabel: WeaponName = $"%name"
@onready var energyLabel: Label = $"%energy" @onready var energyLabel: Label = $"%energy"
@onready var beachballLabel: Label = $"%beachball" @onready var beachballLabel: Label = $"%beachball"
@onready var soulLabel: Label = $"%soul"
@onready var descriptionLabel: RichTextLabel = $"%description" @onready var descriptionLabel: RichTextLabel = $"%description"
@onready var updateButton: Button = $"%updateBtn" @onready var updateBtn: Button = $"%updateBtn"
@onready var extractBtn: Button = $"%extractBtn"
@onready var inlayBtn: Button = $"%inlayBtn"
@onready var sounds: Node2D = $"%sounds" @onready var sounds: Node2D = $"%sounds"
var cooldownTimer: CooldownTimer = null var cooldownTimer: CooldownTimer = null
@@ -35,10 +38,26 @@ func _ready():
cooldownTimer = CooldownTimer.new() cooldownTimer = CooldownTimer.new()
cooldownTimer.cooldown = cooldown cooldownTimer.cooldown = cooldown
originalStore = store originalStore = store
updateButton.pressed.connect( updateBtn.pressed.connect(
func(): func():
apply(UIState.player) apply(UIState.player)
) )
extractBtn.pressed.connect(
func():
UIState.player.getItem({
ItemStore.ItemType.SOUL: ceil((1 + soulLevel) * soulLevel / 2.0)
})
soulLevel = 1
)
inlayBtn.pressed.connect(
func():
if soulLevel < WeaponName.SoulLevel.INFINITY - 1:
if UIState.player.useItem({
ItemStore.ItemType.SOUL: soulLevel
}):
soulLevel += 1
rebuildInfo()
)
for i in sounds.get_children(): for i in sounds.get_children():
i.process_mode = ProcessMode.PROCESS_MODE_ALWAYS i.process_mode = ProcessMode.PROCESS_MODE_ALWAYS
rebuildInfo() rebuildInfo()
@@ -73,6 +92,7 @@ func rebuildInfo():
nameLabel.level = level nameLabel.level = level
energyLabel.text = "%.1f" % needEnergy energyLabel.text = "%.1f" % needEnergy
beachballLabel.text = str(costBeachball) beachballLabel.text = str(costBeachball)
soulLabel.text = str(soulLevel)
descriptionLabel.text = buildDescription() descriptionLabel.text = buildDescription()
func buildDescription() -> String: func buildDescription() -> String:
var result = descriptionTemplate var result = descriptionTemplate