作物优化
This commit is contained in:
@@ -122,7 +122,8 @@ func _create_store_button(crop_name: String, crop_quality: String) -> Button:
|
||||
button.focus_mode = Control.FOCUS_ALL
|
||||
|
||||
# 设置按钮文本,显示价格
|
||||
button.text = str(crop_quality + "-" + crop_name + "\n价格: ¥" + str(crop["花费"]))
|
||||
var display_name = crop.get("作物名称", crop_name)
|
||||
button.text = str(crop_quality + "-" + display_name + "\n价格: ¥" + str(crop["花费"]))
|
||||
|
||||
# 将成熟时间从秒转换为天时分秒格式
|
||||
var total_seconds = int(crop["生长时间"])
|
||||
@@ -154,7 +155,7 @@ func _create_store_button(crop_name: String, crop_quality: String) -> Button:
|
||||
time_str += str(seconds) + "秒"
|
||||
|
||||
button.tooltip_text = str(
|
||||
"作物: " + crop_name + "\n" +
|
||||
"作物: " + display_name + "\n" +
|
||||
"品质: " + crop_quality + "\n" +
|
||||
"价格: " + str(crop["花费"]) + "元\n" +
|
||||
"成熟时间: " + time_str + "\n" +
|
||||
|
||||
@@ -113,7 +113,7 @@ func update_crop_warehouse_ui():
|
||||
# 为仓库中的每个过滤后的成熟物创建按钮
|
||||
for crop_item in filtered_crops:
|
||||
var crop_name = crop_item["name"]
|
||||
var crop_quality = crop_item.get("quality", "普通")
|
||||
var crop_quality = crop_item["quality"]
|
||||
var crop_count = crop_item["count"]
|
||||
# 创建成熟物按钮
|
||||
var button = _create_crop_button(crop_name, crop_quality)
|
||||
@@ -132,10 +132,24 @@ func update_crop_warehouse_ui():
|
||||
effect_descriptions.append(effect_name + "+" + str(effect_value))
|
||||
|
||||
var effect_text = " ".join(effect_descriptions) if effect_descriptions.size() > 0 else "无效果"
|
||||
button.text = str(crop_quality + "-" + crop_name + "\n数量:" + str(crop_count) )
|
||||
var display_name = crop_name
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
var mature_name = main_game.can_planted_crop[crop_name].get("成熟物名称")
|
||||
if mature_name != null and mature_name != "":
|
||||
display_name = mature_name
|
||||
else:
|
||||
display_name = main_game.can_planted_crop[crop_name].get("作物名称", crop_name)
|
||||
button.text = str(crop_quality + "-" + display_name + "\n数量:" + str(crop_count) )
|
||||
button.pressed.connect(func(): _on_crop_feed_selected(crop_name, crop_count))
|
||||
else:
|
||||
button.text = str(crop_quality + "-" + crop_name + "\n数量:" + str(crop_count))
|
||||
var display_name = crop_name
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
var mature_name = main_game.can_planted_crop[crop_name].get("成熟物名称")
|
||||
if mature_name != null and mature_name != "":
|
||||
display_name = mature_name
|
||||
else:
|
||||
display_name = main_game.can_planted_crop[crop_name].get("作物名称", crop_name)
|
||||
button.text = str(crop_quality + "-" + display_name + "\n数量:" + str(crop_count))
|
||||
button.pressed.connect(func(): _on_crop_selected(crop_name, crop_count))
|
||||
|
||||
crop_warehouse_grid_container.add_child(button)
|
||||
@@ -147,8 +161,10 @@ func _get_filtered_and_sorted_crops():
|
||||
|
||||
# 收集符合条件的成熟物
|
||||
for crop_item in main_game.crop_warehouse:
|
||||
# 安全获取品质字段(兼容老数据)
|
||||
var item_quality = crop_item.get("quality", "普通")
|
||||
# 从crop_data中获取品质信息
|
||||
var item_quality = "普通"
|
||||
if main_game.can_planted_crop.has(crop_item["name"]):
|
||||
item_quality = main_game.can_planted_crop[crop_item["name"]].get("品质", "普通")
|
||||
|
||||
# 品质过滤
|
||||
if current_filter_quality != "" and item_quality != current_filter_quality:
|
||||
@@ -228,7 +244,14 @@ func _create_crop_button(crop_name: String, crop_quality: String) -> Button:
|
||||
button.focus_mode = Control.FOCUS_ALL
|
||||
|
||||
# 设置按钮文本
|
||||
button.text = str(crop_quality + "-" + crop_name)
|
||||
var display_name = crop_name
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
var mature_name = main_game.can_planted_crop[crop_name].get("成熟物名称")
|
||||
if mature_name != null and mature_name != "":
|
||||
display_name = mature_name
|
||||
else:
|
||||
display_name = main_game.can_planted_crop[crop_name].get("作物名称", crop_name)
|
||||
button.text = str(crop_quality + "-" + display_name)
|
||||
|
||||
# 添加工具提示 (tooltip)
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
@@ -264,7 +287,7 @@ func _create_crop_button(crop_name: String, crop_quality: String) -> Button:
|
||||
time_str += str(seconds) + "秒"
|
||||
|
||||
button.tooltip_text = str(
|
||||
"作物: " + crop_name + "\n" +
|
||||
"作物: " + display_name + "\n" +
|
||||
"品质: " + crop_quality + "\n" +
|
||||
"原价格: " + str(crop["花费"]) + "元\n" +
|
||||
"成熟时间: " + time_str + "\n" +
|
||||
@@ -302,6 +325,12 @@ func _on_crop_selected(crop_name, crop_count):
|
||||
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
var crop = main_game.can_planted_crop[crop_name]
|
||||
var display_name = crop_name
|
||||
var mature_name = crop.get("成熟物名称")
|
||||
if mature_name != null and mature_name != "":
|
||||
display_name = mature_name
|
||||
else:
|
||||
display_name = crop.get("作物名称", crop_name)
|
||||
var quality = crop.get("品质", "未知")
|
||||
var price = crop.get("花费", 0)
|
||||
var grow_time = crop.get("生长时间", 0)
|
||||
@@ -322,7 +351,7 @@ func _on_crop_selected(crop_name, crop_count):
|
||||
if seconds > 0:
|
||||
time_str += str(seconds) + "秒"
|
||||
|
||||
info_text = quality + "-" + crop_name + " (数量: " + str(crop_count) + ")\n"
|
||||
info_text = quality + "-" + display_name + " (数量: " + str(crop_count) + ")\n"
|
||||
info_text += "原价格: " + str(price) + "元, 原收益: " + str(profit) + "元\n"
|
||||
info_text += "成熟时间: " + time_str + ", 需求等级: " + str(level_req) + "\n"
|
||||
info_text += "这是收获的成熟品,可以用于出售或其他用途"
|
||||
@@ -338,6 +367,12 @@ func _on_visit_crop_selected(crop_name, crop_count):
|
||||
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
var crop = main_game.can_planted_crop[crop_name]
|
||||
var display_name = crop_name
|
||||
var mature_name = crop.get("成熟物名称")
|
||||
if mature_name != null and mature_name != "":
|
||||
display_name = mature_name
|
||||
else:
|
||||
display_name = crop.get("作物名称", crop_name)
|
||||
var quality = crop.get("品质", "未知")
|
||||
var price = crop.get("花费", 0)
|
||||
var grow_time = crop.get("生长时间", 0)
|
||||
@@ -358,7 +393,7 @@ func _on_visit_crop_selected(crop_name, crop_count):
|
||||
if seconds > 0:
|
||||
time_str += str(seconds) + "秒"
|
||||
|
||||
info_text = quality + "-" + crop_name + " (数量: " + str(crop_count) + ")\n"
|
||||
info_text = quality + "-" + display_name + " (数量: " + str(crop_count) + ")\n"
|
||||
info_text += "原价格: " + str(price) + "元, 原收益: " + str(profit) + "元\n"
|
||||
info_text += "成熟时间: " + time_str + ", 需求等级: " + str(level_req)
|
||||
else:
|
||||
@@ -398,12 +433,21 @@ func _on_crop_feed_selected(crop_name: String, crop_count: int):
|
||||
|
||||
var effect_text = ",".join(effect_descriptions) if effect_descriptions.size() > 0 else "无效果"
|
||||
|
||||
# 获取显示名称
|
||||
var display_name = crop_name
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
var mature_name = main_game.can_planted_crop[crop_name].get("成熟物名称")
|
||||
if mature_name != null and mature_name != "":
|
||||
display_name = mature_name
|
||||
else:
|
||||
display_name = main_game.can_planted_crop[crop_name].get("作物名称", crop_name)
|
||||
|
||||
# 显示确认对话框
|
||||
var confirm_text = str(
|
||||
"确认喂食 " + pet_name + " 吗?\n\n" +
|
||||
"作物:" + crop_name + "\n" +
|
||||
"作物:" + display_name + "\n" +
|
||||
"效果:" + effect_text + "\n\n" +
|
||||
"确认后将消耗1个" + crop_name
|
||||
"确认后将消耗1个" + display_name
|
||||
)
|
||||
|
||||
_show_feed_confirmation_dialog(confirm_text, crop_name, pet_id, feed_effects)
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
extends Panel
|
||||
class_name LuckyDrawPanel
|
||||
|
||||
## 幸运抽奖系统 - 后端对接版本
|
||||
## 功能:与服务器对接的抽奖系统,支持实时数据同步和平衡调整
|
||||
## 奖励平衡性已根据 crop_data.json 调整
|
||||
|
||||
# =============================================================================
|
||||
# 信号定义 - 用于与后端系统通信
|
||||
# =============================================================================
|
||||
signal draw_completed(rewards: Array, draw_type: String) # 抽奖完成信号
|
||||
signal reward_obtained(reward_type: String, amount: int) # 奖励获得信号
|
||||
signal draw_failed(error_message: String) # 抽奖失败信号
|
||||
|
||||
# =============================================================================
|
||||
# 节点引用
|
||||
# =============================================================================
|
||||
|
||||
#这个展示抽奖获得的奖励
|
||||
@onready var lucky_draw_reward: RichTextLabel = $LuckyDrawReward
|
||||
#这个是展示有哪些奖励选项,最多15个,奖励就在这里面随机挑选
|
||||
@@ -22,9 +14,6 @@ signal draw_failed(error_message: String) # 抽奖失败信号
|
||||
#这个是奖励模板
|
||||
@onready var reward_item: RichTextLabel = $Grid/RewardItem
|
||||
|
||||
# =============================================================================
|
||||
# 数据存储
|
||||
# =============================================================================
|
||||
var reward_templates: Array[RichTextLabel] = []
|
||||
var current_rewards: Array = []
|
||||
@onready var main_game = get_node("/root/main")
|
||||
@@ -61,9 +50,6 @@ var template_colors: Array[Color] = [
|
||||
|
||||
var anticipation_tween: Tween = null
|
||||
|
||||
# =============================================================================
|
||||
# 基础奖励配置 - 根据 crop_data.json 调整
|
||||
# =============================================================================
|
||||
var base_rewards: Dictionary = {
|
||||
"coins": {"name": "金币", "icon": "💰", "color": "#FFD700"},
|
||||
"exp": {"name": "经验", "icon": "⭐", "color": "#00BFFF"},
|
||||
@@ -79,14 +65,8 @@ var draw_costs: Dictionary = {
|
||||
"ten": 6400 # 800 * 10 * 0.8 = 6400
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# 奖励池配置 - 根据后端数据动态更新
|
||||
# =============================================================================
|
||||
var server_reward_pools: Dictionary = {}
|
||||
|
||||
# =============================================================================
|
||||
# 系统初始化
|
||||
# =============================================================================
|
||||
func _ready() -> void:
|
||||
_initialize_system()
|
||||
|
||||
@@ -148,9 +128,6 @@ func _get_rarity_color(rarity: String) -> String:
|
||||
_:
|
||||
return "#FFFFFF"
|
||||
|
||||
# =============================================================================
|
||||
# 核心功能
|
||||
# =============================================================================
|
||||
|
||||
## 生成15个奖励模板
|
||||
func _generate_reward_templates() -> void:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extends Panel
|
||||
|
||||
#种子仓库面板
|
||||
# 背包格子容器
|
||||
@onready var player_bag_grid_container : GridContainer = $ScrollContainer/Bag_Grid
|
||||
@onready var quit_button : Button = $QuitButton
|
||||
@@ -51,10 +51,10 @@ var one_click_plant_panel = null
|
||||
func _ready():
|
||||
# 连接按钮信号
|
||||
_connect_buttons()
|
||||
|
||||
# 连接可见性改变信号
|
||||
visibility_changed.connect(_on_visibility_changed)
|
||||
|
||||
|
||||
# 隐藏面板(初始默认隐藏)
|
||||
self.hide()
|
||||
|
||||
@@ -80,10 +80,6 @@ func _connect_buttons():
|
||||
|
||||
# 初始化玩家背包
|
||||
func init_player_bag():
|
||||
# 清空玩家背包格子
|
||||
for child in player_bag_grid_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
# 显示背包中的种子
|
||||
update_player_bag_ui()
|
||||
|
||||
@@ -99,14 +95,15 @@ func update_player_bag_ui():
|
||||
# 为背包中的每个过滤后的种子创建按钮
|
||||
for seed_item in filtered_seeds:
|
||||
var crop_name = seed_item["name"]
|
||||
var crop_quality = seed_item.get("quality", "普通")
|
||||
var crop_quality = seed_item["quality"]
|
||||
var crop_count = seed_item["count"]
|
||||
#print("背包物品:", crop_name, " 数量:", crop_count)
|
||||
# 创建种子按钮
|
||||
var button = _create_crop_button(crop_name, crop_quality)
|
||||
# 更新按钮文本显示数量
|
||||
button.text = str(crop_quality + "-" + crop_name + "\n数量:" + str(crop_count))
|
||||
|
||||
var display_name = crop_name
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
display_name = main_game.can_planted_crop[crop_name].get("作物名称", crop_name)
|
||||
button.text = str(crop_quality + "-" + display_name + "\n数量:" + str(crop_count))
|
||||
# 根据是否处于访问模式连接不同的事件
|
||||
if main_game.is_visiting_mode:
|
||||
# 访问模式下,点击种子只显示信息,不能种植
|
||||
@@ -123,8 +120,10 @@ func _get_filtered_and_sorted_seeds():
|
||||
|
||||
# 收集符合条件的种子
|
||||
for seed_item in main_game.player_bag:
|
||||
# 安全获取品质字段(兼容老数据)
|
||||
var item_quality = seed_item.get("quality", "普通")
|
||||
# 从crop_data中获取品质信息
|
||||
var item_quality = "普通"
|
||||
if main_game.can_planted_crop.has(seed_item["name"]):
|
||||
item_quality = main_game.can_planted_crop[seed_item["name"]].get("品质", "普通")
|
||||
|
||||
# 品质过滤
|
||||
if current_filter_quality != "" and item_quality != current_filter_quality:
|
||||
@@ -199,7 +198,10 @@ func _create_crop_button(crop_name: String, crop_quality: String) -> Button:
|
||||
button.disabled = false
|
||||
button.focus_mode = Control.FOCUS_ALL
|
||||
# 设置按钮文本
|
||||
button.text = str(crop_quality + "-" + crop_name)
|
||||
var display_name = crop_name
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
display_name = main_game.can_planted_crop[crop_name].get("作物名称", crop_name)
|
||||
button.text = str(crop_quality + "-" + display_name)
|
||||
|
||||
# 添加工具提示 (tooltip)
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
@@ -235,7 +237,7 @@ func _create_crop_button(crop_name: String, crop_quality: String) -> Button:
|
||||
time_str += str(seconds) + "秒"
|
||||
|
||||
button.tooltip_text = str(
|
||||
"作物: " + crop_name + "\n" +
|
||||
"作物: " + display_name + "\n" +
|
||||
"品质: " + crop_quality + "\n" +
|
||||
"价格: " + str(crop["花费"]) + "元\n" +
|
||||
"成熟时间: " + time_str + "\n" +
|
||||
@@ -302,39 +304,7 @@ func _on_bag_seed_selected(crop_name):
|
||||
|
||||
# 访问模式下的种子点击处理
|
||||
func _on_visit_seed_selected(crop_name, crop_count):
|
||||
# 显示种子信息
|
||||
var info_text = ""
|
||||
|
||||
if main_game.can_planted_crop.has(crop_name):
|
||||
var crop = main_game.can_planted_crop[crop_name]
|
||||
var quality = crop.get("品质", "未知")
|
||||
var price = crop.get("花费", 0)
|
||||
var grow_time = crop.get("生长时间", 0)
|
||||
var profit = crop.get("收益", 0)
|
||||
var level_req = crop.get("等级", 1)
|
||||
|
||||
# 将成熟时间转换为可读格式
|
||||
var time_str = ""
|
||||
var total_seconds = int(grow_time)
|
||||
var hours = total_seconds / 3600
|
||||
var minutes = (total_seconds % 3600) / 60
|
||||
var seconds = total_seconds % 60
|
||||
|
||||
if hours > 0:
|
||||
time_str += str(hours) + "小时"
|
||||
if minutes > 0:
|
||||
time_str += str(minutes) + "分钟"
|
||||
if seconds > 0:
|
||||
time_str += str(seconds) + "秒"
|
||||
|
||||
info_text = quality + "-" + crop_name + " (数量: " + str(crop_count) + ")\n"
|
||||
info_text += "价格: " + str(price) + "元, 收益: " + str(profit) + "元\n"
|
||||
info_text += "成熟时间: " + time_str + ", 需求等级: " + str(level_req)
|
||||
else:
|
||||
info_text = crop_name + " (数量: " + str(crop_count) + ")"
|
||||
|
||||
Toast.show(info_text, Color.CYAN, 3.0, 1.0)
|
||||
print("查看种子信息: ", info_text)
|
||||
pass
|
||||
|
||||
# 从背包种植作物
|
||||
func _plant_crop_from_bag(index, crop_name, seed_index):
|
||||
@@ -508,8 +478,6 @@ func _on_refresh_button_pressed() -> void:
|
||||
|
||||
# 关闭面板
|
||||
func _on_quit_button_pressed():
|
||||
#打开面板后暂时禁用相机功能
|
||||
GlobalVariables.isZoomDisabled = false
|
||||
# 退出种植模式(如果当前在种植模式下)
|
||||
if is_planting_mode:
|
||||
_exit_planting_mode()
|
||||
|
||||
@@ -24,8 +24,7 @@ extends Panel
|
||||
#预添加常用的面板
|
||||
@onready var main_game = get_node("/root/main")
|
||||
|
||||
@onready var lucky_draw_panel: LuckyDrawPanel = $'../LuckyDrawPanel'
|
||||
@onready var daily_check_in_panel: DailyCheckInPanel = $'../DailyCheckInPanel'
|
||||
|
||||
@onready var tcp_network_manager_panel: Panel = $'../TCPNetworkManagerPanel'
|
||||
@onready var item_store_panel: Panel = $'../ItemStorePanel'
|
||||
@onready var crop_warehouse_panel: Panel = $'../CropWarehousePanel'
|
||||
|
||||
Reference in New Issue
Block a user