mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-31 08:21:54 +08:00
feat(饲料卡片): 添加饲料品质显示功能
实现饲料品质的枚举定义和颜色映射,修改FeedCardBase使用FeedName组件显示品质
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
@tool
|
||||
extends CenterContainer
|
||||
class_name FeedName
|
||||
|
||||
enum Quality {
|
||||
WASTE,
|
||||
COMMON,
|
||||
RARE,
|
||||
EPIC,
|
||||
LEGENDARY,
|
||||
}
|
||||
|
||||
@export var displayName: String = "未命名饲料"
|
||||
@export var quality: Quality = Quality.COMMON
|
||||
@export var qualityColorMap = {
|
||||
Quality.WASTE: Color(),
|
||||
Quality.COMMON: Color(),
|
||||
Quality.RARE: Color(),
|
||||
Quality.EPIC: Color(),
|
||||
Quality.LEGENDARY: Color()
|
||||
}
|
||||
@export var qualityNameMap = {
|
||||
Quality.WASTE: "常见",
|
||||
Quality.COMMON: "普通",
|
||||
Quality.RARE: "稀有",
|
||||
Quality.EPIC: "史诗",
|
||||
Quality.LEGENDARY: "传说"
|
||||
}
|
||||
@export var qualityRandomWeight = {
|
||||
Quality.WASTE: 5,
|
||||
Quality.COMMON: 50,
|
||||
Quality.RARE: 10,
|
||||
Quality.EPIC: 5,
|
||||
Quality.LEGENDARY: 1
|
||||
}
|
||||
|
||||
@onready var label: RichTextLabel = $"%label"
|
||||
|
||||
func _physics_process(_delta):
|
||||
label.text = "[b][color=%s]%s[/color][/b]" % ["#" + color().to_html(false), displayName]
|
||||
func color():
|
||||
return qualityColorMap[quality] as Color
|
||||
@@ -6,13 +6,14 @@ 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 fields: Array[FieldStore.Entity] = []
|
||||
@export var fieldValues: Array[float] = []
|
||||
@export var costs: Array[ItemStore.ItemType] = []
|
||||
@export var costCounts: Array[int] = []
|
||||
|
||||
@onready var avatarRect: TextureRect = $"%avatar"
|
||||
@onready var nameLabel: RichTextLabel = $"%name"
|
||||
@onready var nameLabel: FeedName = $"%name"
|
||||
@onready var fieldsBox: VBoxContainer = $"%fields"
|
||||
@onready var costsBox: GridContainer = $"%costs"
|
||||
@onready var selectButton: Button = $"%selectBtn"
|
||||
@@ -23,7 +24,8 @@ func _ready():
|
||||
apply(UIState.player)
|
||||
)
|
||||
avatarRect.texture = avatarTexture
|
||||
nameLabel.text = "[b]" + displayName + "[/b]"
|
||||
nameLabel.displayName = displayName
|
||||
nameLabel.quality = quality
|
||||
for i in fieldsBox.get_children():
|
||||
i.queue_free()
|
||||
var noField = true
|
||||
|
||||
Reference in New Issue
Block a user