mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-30 16:01:53 +08:00
feat: 添加新武器彩虹旗和紫水晶簇,调整饲料属性和数值
refactor: 重构子弹生成逻辑,支持分裂和折射效果 fix: 修复掉落物拾取范围和碰撞检测问题 style: 优化UI显示,添加武器品质和类型标签 docs: 更新字段描述,调整部分饲料名称和分类 perf: 优化数学工具函数,添加随机数处理工具 test: 调整波次生成逻辑,添加新敌人类型 build: 添加新资源文件和相关导入配置
This commit is contained in:
@@ -7,6 +7,7 @@ signal selected(applied: bool)
|
||||
@export var avatarTexture: Texture2D = preload("res://icon.svg")
|
||||
@export var displayName: String = "未命名饲料"
|
||||
@export var quality: FeedName.Quality = FeedName.Quality.COMMON
|
||||
@export var topic: FeedName.Topic = FeedName.Topic.SURVIVAL
|
||||
@export var fields: Array[FieldStore.Entity] = []
|
||||
@export var fieldValues: Array[float] = []
|
||||
@export var costs: Array[ItemStore.ItemType] = []
|
||||
@@ -60,6 +61,7 @@ func rebuildInfo():
|
||||
avatarRect.texture = avatarTexture
|
||||
nameLabel.displayName = displayName
|
||||
nameLabel.quality = quality
|
||||
nameLabel.topic = topic
|
||||
for i in fieldsBox.get_children():
|
||||
i.queue_free()
|
||||
var noField = true
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
@tool
|
||||
extends PanelContainer
|
||||
class_name Weapon
|
||||
|
||||
signal selected(applied: bool)
|
||||
|
||||
@export var avatarTexture: Texture2D = preload("res://icon.svg")
|
||||
@export var displayName: String = "未命名饲料"
|
||||
@export var quality: WeaponName.Quality = WeaponName.Quality.COMMON
|
||||
@export var typeTopic: WeaponName.TypeTopic = WeaponName.TypeTopic.IMPACT
|
||||
@export var costs: Array[ItemStore.ItemType] = []
|
||||
@export var costCounts: Array[int] = []
|
||||
@export var store: Dictionary = {
|
||||
"atk": 10
|
||||
}
|
||||
@export var descriptionTemplate: String = "造成$atk点伤害。"
|
||||
@export var needEnergy: float = 0
|
||||
@export var cooldown: float = 100
|
||||
|
||||
@onready var avatarRect: TextureRect = $"%avatar"
|
||||
@onready var nameLabel: WeaponName = $"%name"
|
||||
@onready var energyLabel: Label = $"%energy"
|
||||
@onready var descriptionLabel: RichTextLabel = $"%description"
|
||||
@onready var costsBox: GridContainer = $"%costs"
|
||||
@onready var selectButton: Button = $"%selectBtn"
|
||||
|
||||
func _ready():
|
||||
selectButton.pressed.connect(
|
||||
func():
|
||||
apply(UIState.player)
|
||||
)
|
||||
rebuildInfo()
|
||||
func _physics_process(_delta: float):
|
||||
descriptionLabel.text = buildDescription()
|
||||
|
||||
func allHad(entity: EntityBase) -> bool:
|
||||
var allHave = true
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i] * multipiler()
|
||||
if entity.inventory[item] < count:
|
||||
allHave = false
|
||||
break
|
||||
return allHave
|
||||
func apply(entity: EntityBase):
|
||||
var allHave = allHad(entity)
|
||||
if allHave:
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var item = costs[i]
|
||||
var count = costCounts[i] * multipiler()
|
||||
entity.inventory[item] -= count
|
||||
hide()
|
||||
selected.emit(allHave)
|
||||
return allHave
|
||||
func multipiler() -> float:
|
||||
if is_instance_valid(UIState.player):
|
||||
return 1 - UIState.player.fields.get(FieldStore.Entity.PRICE_REDUCTION)
|
||||
else:
|
||||
return 1
|
||||
func rebuildInfo():
|
||||
avatarRect.texture = avatarTexture
|
||||
nameLabel.displayName = displayName
|
||||
nameLabel.quality = quality
|
||||
nameLabel.typeTopic = typeTopic
|
||||
energyLabel.text = "%.1f" % needEnergy
|
||||
for i in costsBox.get_children():
|
||||
i.queue_free()
|
||||
for i in range(min(costs.size(), costCounts.size())):
|
||||
var cost = costs[i]
|
||||
var count = costCounts[i]
|
||||
var costShow: ItemShow = preload("res://components/UI/ItemShow.tscn").instantiate()
|
||||
costShow.type = cost
|
||||
costShow.count = int(count * multipiler())
|
||||
costsBox.add_child(costShow)
|
||||
func buildDescription():
|
||||
var result = descriptionTemplate
|
||||
for key in store.keys():
|
||||
result = result.replace("$" + key, "[color=cyan]%.1f[/color]" % readStore(key))
|
||||
return result
|
||||
func readStore(key: String, default: Variant = null):
|
||||
return store.get(key, default)
|
||||
|
||||
# 抽象
|
||||
func update(_to: int, _origin: Dictionary, _entity: EntityBase):
|
||||
pass
|
||||
func attack(_entity: EntityBase):
|
||||
pass
|
||||
Reference in New Issue
Block a user