mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(武器系统): 添加灵魂等级机制并重构武器升级逻辑
- 在UI中添加灵魂资源显示和操作按钮 - 修改武器升级公式加入灵魂等级系数 - 实现灵魂的提取和镶嵌功能 - 为武器卡牌添加灵魂等级颜色映射 - 初始化玩家灵魂资源为10个
This commit is contained in:
@@ -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="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://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"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n2ewr"]
|
||||
content_margin_left = 30.0
|
||||
@@ -122,10 +123,35 @@ 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
|
||||
|
||||
[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")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
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"]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -177,6 +177,11 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
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"]
|
||||
z_index = 1
|
||||
z_as_relative = false
|
||||
|
||||
@@ -3,8 +3,8 @@ extends Weapon
|
||||
class_name BigLaserWeapon
|
||||
|
||||
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||
origin["atk"] += 5 * to
|
||||
origin["time"] /= 1.05
|
||||
origin["atk"] += 5 * to * soulLevel
|
||||
origin["time"] /= 1.05 ** soulLevel * to
|
||||
return origin
|
||||
func attack(entity: EntityBase):
|
||||
var weaponPos = entity.findWeaponAnchor("normal")
|
||||
|
||||
@@ -3,11 +3,11 @@ extends Weapon
|
||||
class_name LGBTWeapon
|
||||
|
||||
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||
origin["atk"] += 5 * to
|
||||
origin["count"] += to
|
||||
origin["power"] += 0.05 * level
|
||||
origin["trace"] += 0.25 * level
|
||||
origin["angle"] /= 1.05 * level
|
||||
origin["atk"] += 5 * to * soulLevel
|
||||
origin["count"] += to * soulLevel
|
||||
origin["power"] += 0.05 * to * soulLevel
|
||||
origin["trace"] += 0.25 * to * soulLevel
|
||||
origin["angle"] /= 1.05 ** soulLevel * to
|
||||
return origin
|
||||
func attack(entity: EntityBase):
|
||||
var weaponPos = entity.findWeaponAnchor("normal")
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
extends Weapon
|
||||
|
||||
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||
origin["atk"] += 0.5 * to
|
||||
origin["rate"] += 0.02 * to
|
||||
origin["count"] += 1 * level
|
||||
origin["atk"] += 1 * to * soulLevel
|
||||
origin["rate"] += 0.04 * to * soulLevel
|
||||
origin["count"] += 1 * to * soulLevel
|
||||
return origin
|
||||
func attack(entity: EntityBase):
|
||||
var weaponPos = entity.findWeaponAnchor("normal")
|
||||
|
||||
@@ -3,7 +3,7 @@ extends Weapon
|
||||
class_name PurpleCrystalWeapon
|
||||
|
||||
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||
origin["atk"] += 5 * to
|
||||
origin["atk"] += 5 * to * soulLevel
|
||||
return origin
|
||||
func attack(entity: EntityBase):
|
||||
var weaponPos = entity.findWeaponAnchor("normal")
|
||||
|
||||
@@ -3,9 +3,9 @@ extends Weapon
|
||||
class_name VectorStarWeapon
|
||||
|
||||
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||
origin["atk"] += 5 * to
|
||||
origin["forwardtime"] /= 1.05 * to
|
||||
origin["maxcount"] += 1 * level
|
||||
origin["atk"] += 5 * to * soulLevel
|
||||
origin["forwardtime"] /= 1.05 ** soulLevel * to
|
||||
origin["maxcount"] += 1 * level * soulLevel
|
||||
return origin
|
||||
func attack(entity: EntityBase):
|
||||
var weaponPos = entity.findWeaponAnchor("normal")
|
||||
|
||||
@@ -57,7 +57,7 @@ var inventory = {
|
||||
ItemStore.ItemType.BASKETBALL: 500,
|
||||
ItemStore.ItemType.APPLE: 5,
|
||||
ItemStore.ItemType.BEACHBALL: 0,
|
||||
ItemStore.ItemType.SOUL: 0,
|
||||
ItemStore.ItemType.SOUL: 10,
|
||||
}
|
||||
var inventoryMax = {
|
||||
ItemStore.ItemType.BASEBALL: INF, # 无限
|
||||
@@ -349,6 +349,21 @@ func playSound(type: String):
|
||||
func tryKill():
|
||||
kill()
|
||||
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:
|
||||
return hurtbox.get_node("hitbox").global_position
|
||||
|
||||
@@ -16,17 +16,17 @@ enum TypeTopic {
|
||||
MAGIC,
|
||||
}
|
||||
enum SoulLevel {
|
||||
NORMALIZE,
|
||||
ADD,
|
||||
MULTIPLY,
|
||||
EXPONENT,
|
||||
INFINITY,
|
||||
NORMALIZE = 1,
|
||||
ADD = 2,
|
||||
MULTIPLY = 3,
|
||||
EXPONENT = 4,
|
||||
INFINITY = 5,
|
||||
}
|
||||
|
||||
@export var displayName: String = "未命名武器"
|
||||
@export var quality: Quality = Quality.COMMON
|
||||
@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 qualityColorMap = {
|
||||
Quality.WASTE: Color(),
|
||||
|
||||
@@ -6,7 +6,7 @@ class_name Weapon
|
||||
@export var displayName: String = "未命名饲料"
|
||||
@export var quality: WeaponName.Quality = WeaponName.Quality.COMMON
|
||||
@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 store: Dictionary = {
|
||||
"atk": 10
|
||||
@@ -24,8 +24,11 @@ class_name Weapon
|
||||
@onready var nameLabel: WeaponName = $"%name"
|
||||
@onready var energyLabel: Label = $"%energy"
|
||||
@onready var beachballLabel: Label = $"%beachball"
|
||||
@onready var soulLabel: Label = $"%soul"
|
||||
@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"
|
||||
|
||||
var cooldownTimer: CooldownTimer = null
|
||||
@@ -35,10 +38,26 @@ func _ready():
|
||||
cooldownTimer = CooldownTimer.new()
|
||||
cooldownTimer.cooldown = cooldown
|
||||
originalStore = store
|
||||
updateButton.pressed.connect(
|
||||
updateBtn.pressed.connect(
|
||||
func():
|
||||
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():
|
||||
i.process_mode = ProcessMode.PROCESS_MODE_ALWAYS
|
||||
rebuildInfo()
|
||||
@@ -73,6 +92,7 @@ func rebuildInfo():
|
||||
nameLabel.level = level
|
||||
energyLabel.text = "%.1f" % needEnergy
|
||||
beachballLabel.text = str(costBeachball)
|
||||
soulLabel.text = str(soulLevel)
|
||||
descriptionLabel.text = buildDescription()
|
||||
func buildDescription() -> String:
|
||||
var result = descriptionTemplate
|
||||
|
||||
Reference in New Issue
Block a user