继续开始

This commit is contained in:
2025-06-28 14:39:37 +08:00
parent 12fbe9debf
commit 3ccd7e93ed
923 changed files with 28424 additions and 2362 deletions

3
.gitignore vendored
View File

@@ -4,6 +4,7 @@
.mono/
export.cfg
export_presets.cfg
android
# System-specific files
.DS_Store
@@ -12,5 +13,3 @@ Thumbs.db
# IDE-specific files
.vscode/
.idea/
server/node_modules/

View File

@@ -1,12 +1,19 @@
[gd_scene load_steps=7 format=3 uid="uid://bkivlkirrx6u8"]
[ext_resource type="Texture2D" uid="uid://fibjlynv0vi2" path="res://assets/地块/土块1.png" id="1_bns1c"]
[ext_resource type="Texture2D" uid="uid://bt1i2yhhlor5e" path="res://assets/地块/土块1.webp" id="1_bns1c"]
[ext_resource type="Script" uid="uid://xh5tr5co5kfu" path="res://GUI/SMY_ProgressBar.gd" id="2_1n4xp"]
[ext_resource type="Texture2D" uid="uid://cil2qobuc0chj" path="res://assets/作物/默认/0.webp" id="2_bns1c"]
[ext_resource type="Shader" path="res://Shader/PlantSwayShader.gdshader" id="2_s5pb0"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_v46ok"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_s5pb0"]
shader = ExtResource("2_s5pb0")
shader_parameter/sway_strength = 0.05
shader_parameter/sway_speed = 1.5
shader_parameter/wind_direction = 0.0
shader_parameter/sway_variation = 0.5
shader_parameter/sway_start_height = 0.5
shader_parameter/height_curve = 2.0
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cyybs"]
@@ -17,19 +24,24 @@ offset_right = 40.0
offset_bottom = 40.0
[node name="ground_sprite" type="Sprite2D" parent="."]
modulate = Color(0.8, 0.8, 0.8, 1)
material = SubResource("ShaderMaterial_v46ok")
position = Vector2(50, 63)
scale = Vector2(0.135, 0.135)
texture = ExtResource("1_bns1c")
[node name="crop_sprite" type="Sprite2D" parent="."]
visible = false
material = SubResource("ShaderMaterial_s5pb0")
position = Vector2(50, 34)
position = Vector2(51, 39)
scale = Vector2(0.06, 0.06)
[node name="old_crop_sprite" type="Sprite2D" parent="."]
material = SubResource("ShaderMaterial_s5pb0")
position = Vector2(51, 39)
scale = Vector2(0.06, 0.06)
texture = ExtResource("2_bns1c")
[node name="ProgressBar" type="ProgressBar" parent="."]
modulate = Color(0.1, 0.1, 0.1, 1)
material = SubResource("ShaderMaterial_cyybs")
layout_mode = 2
offset_left = 23.0
@@ -37,6 +49,9 @@ offset_top = 78.0
offset_right = 328.0
offset_bottom = 151.0
scale = Vector2(0.2, 0.2)
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 10
theme_override_font_sizes/font_size = 50
script = ExtResource("2_1n4xp")

View File

@@ -0,0 +1,23 @@
[gd_scene load_steps=2 format=3 uid="uid://ibl5wbbw3pwc"]
[ext_resource type="Script" uid="uid://c6ylh1o2kgqth" path="res://CopyItems/item_crop.gd" id="1_e25nh"]
[node name="item_button" type="Button"]
custom_minimum_size = Vector2(400, 400)
offset_right = 400.0
offset_bottom = 400.0
theme_override_font_sizes/font_size = 1
icon_alignment = 1
script = ExtResource("1_e25nh")
[node name="CropImage" type="Sprite2D" parent="."]
position = Vector2(199.569, 201.043)
scale = Vector2(0.260977, 0.259058)
[node name="Title" type="Label" parent="."]
layout_mode = 0
offset_right = 400.0
offset_bottom = 55.0
theme_override_font_sizes/font_size = 50
text = "普通"
horizontal_alignment = 1

View File

@@ -1,78 +1,29 @@
{
"测试作物": {"花费": 1, "生长时间": 5, "收益": 10000, "品质": "普通", "描述": "仅供测试使用的特殊作物", "耐候性": 10, "等级": 1, "经验": 999, "能否购买": false},
"小麦": {"花费": 120, "生长时间": 120, "收益": 100, "品质": "普通", "描述": "基础作物,品质较低,适合新手种植", "耐候性": 10, "等级": 1, "经验": 10},
"稻谷": {"花费": 100, "生长时间": 240, "收益": 120, "品质": "普通", "描述": "适合大规模种植的基础作物", "耐候性": 10, "等级": 1, "经验": 10},
"玉米": {"花费": 70, "生长时间": 600, "收益": 90, "品质": "普通", "描述": "营养丰富的优良作物,适合稍有经验的玩家", "耐候性": 15, "等级": 2, "经验": 15},
"土豆": {"花费": 75, "生长时间": 360, "收益": 90, "品质": "普通", "描述": "容易种植的耐寒作物", "耐候性": 12, "等级": 1, "经验": 10},
"胡萝卜": {"花费": 60, "生长时间": 480, "收益": 80, "品质": "普通", "描述": "适合新手的健康作物", "耐候性": 12, "等级": 1, "经验": 10},
"草莓": {"花费": 120, "生长时间": 960, "收益": 150, "品质": "优良", "描述": "营养丰富的果实,收益不错", "耐候性": 14, "等级": 2, "经验": 20},
"番茄": {"花费": 100, "生长时间": 720, "收益": 130, "品质": "优良", "描述": "常见作物,适合小规模种植", "耐候性": 12, "等级": 2, "经验": 15},
"大豆": {"花费": 90, "生长时间": 840, "收益": 110, "品质": "优良", "描述": "富含蛋白质的基础作物", "耐候性": 11, "等级": 2, "经验": 12},
"小麦": {"花费": 50, "生长时间": 300, "收益": 75, "品质": "普通", "描述": "最基础的粮食作物,生长快速,适合新手练习", "耐候性": 8, "等级": 1, "经验": 8, "能否购买": true},
"胡萝卜": {"花费": 40, "生长时间": 240, "收益": 65, "品质": "普通", "描述": "营养丰富的根茎类蔬菜,容易种植", "耐候性": 9, "等级": 1, "经验": 7, "能否购买": true},
"土豆": {"花费": 60, "生长时间": 480, "收益": 95, "品质": "普通", "描述": "耐寒的块茎作物,产量稳定", "耐候性": 12, "等级": 1, "经验": 10, "能否购买": true},
"稻谷": {"花费": 70, "生长时间": 600, "收益": 110, "品质": "普通", "描述": "重要的主粮作物,需要充足水分", "耐候性": 7, "等级": 1, "经验": 12, "能否购买": true},
"蓝莓": {"花费": 150, "生长时间": 1200, "收益": 200, "品质": "稀有", "描述": "较为稀有的作物,市场价值较高", "耐候性": 18, "等级": 3, "经验": 25},
"洋葱": {"花费": 85, "生长时间": 600, "收益": 105, "品质": "稀有", "描述": "烹饪常用的作物,适合中级种植", "耐候性": 10, "等级": 2, "经验": 10},
"南瓜": {"花费": 180, "生长时间": 1440, "收益": 250, "品质": "稀有", "描述": "秋季收获的高收益作物", "耐候性": 20, "等级": 4, "经验": 30},
"葡萄": {"花费": 200, "生长时间": 1200, "收益": 300, "品质": "稀有", "描述": "需要特殊管理的高收益作物", "耐候性": 15, "等级": 4, "经验": 35},
"柿子": {"花费": 160, "生长时间": 1080, "收益": 240, "品质": "稀有", "描述": "富含营养的秋季作物", "耐候性": 18, "等级": 3, "经验": 28},
"花椰菜": {"花费": 130, "生长时间": 960, "收益": 170, "品质": "稀有", "描述": "耐寒的高品质作物,适合经验丰富的玩家", "耐候性": 17, "等级": 3, "经验": 22},
"芦笋": {"花费": 200, "生长时间": 1560, "收益": 280, "品质": "稀有", "描述": "市场需求量高的稀有作物", "耐候性": 15, "等级": 4, "经验": 30},
"香草": {"花费": 250, "生长时间": 1800, "收益": 400, "品质": "史诗", "描述": "非常稀有且收益极高的作物", "耐候性": 22, "等级": 5, "经验": 40},
"西瓜": {"花费": 240, "生长时间": 2400, "收益": 420, "品质": "史诗", "描述": "夏季丰产的高价值作物", "耐候性": 21, "等级": 5, "经验": 45},
"甜菜": {"花费": 220, "生长时间": 2160, "收益": 350, "品质": "史诗", "描述": "营养丰富的根茎作物,收益较高", "耐候性": 20, "等级": 5, "经验": 38},
"甘蔗": {"花费": 260, "生长时间": 3000, "收益": 450, "品质": "史诗", "描述": "需要充足水源的高价值作物", "耐候性": 18, "等级": 5, "经验": 50},
"玉米": {"花费": 80, "生长时间": 900, "收益": 130, "品质": "优良", "描述": "高产的谷物作物,营养价值高", "耐候性": 10, "等级": 2, "经验": 15, "能否购买": true},
"番茄": {"花费": 90, "生长时间": 720, "收益": 140, "品质": "优良", "描述": "多汁的果实,市场需求大", "耐候性": 8, "等级": 2, "经验": 16, "能否购买": true},
"洋葱": {"花费": 75, "生长时间": 840, "收益": 125, "品质": "优良", "描述": "调味蔬菜,储存时间长", "耐候性": 11, "等级": 2, "经验": 14, "能否购买": true},
"大豆": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"草莓": {"花费": 120, "生长时间": 1440, "收益": 200, "品质": "稀有", "描述": "甜美的浆果,深受喜爱", "耐候性": 6, "等级": 3, "经验": 22, "能否购买": true},
"花椰菜": {"花费": 110, "生长时间": 1320, "收益": 185, "品质": "稀有", "描述": "营养丰富的十字花科蔬菜", "耐候性": 8, "等级": 3, "经验": 20, "能否购买": true},
"柿子": {"花费": 140, "生长时间": 1800, "收益": 230, "品质": "稀有", "描述": "秋季成熟的甜美果实", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"蓝莓": {"花费": 160, "生长时间": 2100, "收益": 260, "品质": "稀有", "描述": "抗氧化的超级食物", "耐候性": 7, "等级": 3, "经验": 28, "能否购买": true},
"栀子花": {"花费": 180, "生长时间": 2400, "收益": 300, "品质": "稀有", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"玫瑰花": {"花费": 190, "生长时间": 2520, "收益": 310, "品质": "稀有", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"菠萝": {"花费": 200, "生长时间": 2700, "收益": 340, "品质": "稀有", "描述": "热带水果之王", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"梨树": {"花费": 210, "生长时间": 2820, "收益": 350, "品质": "稀有", "描述": "春季开花的落叶果树", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"桃树": {"花费": 220, "生长时间": 2940, "收益": 360, "品质": "稀有", "描述": "粉色花海中的果实树种", "耐候性": 9, "等级": 3, "经验": 25, "能否购买": true},
"荔枝": {"花费": 230, "生长时间": 3060, "收益": 380, "品质": "稀有", "描述": "亚热带珍稀水果,果肉如凝脂", "耐候性": 8, "等级": 3, "经验": 26, "能否购买": true},
"芒果树": {"花费": 240, "生长时间": 3180, "收益": 400, "品质": "稀有", "描述": "热带阳光孕育的香甜果实", "耐候性": 10, "等级": 3, "经验": 27, "能否购买": true},
"糖果树": {"花费": 250, "生长时间": 3300, "收益": 420, "品质": "稀有", "描述": "传说中结出彩色糖果的魔法树", "耐候性": 7, "等级": 3, "经验": 25, "能否购买": true},
"面包树": {"花费": 260, "生长时间": 3420, "收益": 440, "品质": "稀有", "描述": "热带地区的淀粉质主食树种", "耐候性": 9, "等级": 3, "经验": 25, "能否购买": true},
"幸运草": {"花费": 150, "生长时间": 1560, "收益": 220, "品质": "稀有", "描述": "四片叶子的幸运象征植物", "耐候性": 6, "等级": 3, "经验": 20, "能否购买": true},
"幸运花": {"花费": 170, "生长时间": 1680, "收益": 240, "品质": "稀有", "描述": "绽放时带来好运的神秘花卉", "耐候性": 7, "等级": 3, "经验": 22, "能否购买": true},
"摇钱树": {"花费": 300, "生长时间": 3600, "收益": 500, "品质": "稀有", "描述": "传说中能结出金币的神树", "耐候性": 10, "等级": 3, "经验": 30, "能否购买": true},
"葡萄": {"花费": 200, "生长时间": 2700, "收益": 340, "品质": "史诗", "描述": "用于酿酒的珍贵果实", "耐候性": 9, "等级": 4, "经验": 35, "能否购买": true},
"南瓜": {"花费": 180, "生长时间": 3600, "收益": 320, "品质": "史诗", "描述": "大型瓜果,节庆装饰的首选", "耐候性": 12, "等级": 4, "经验": 38, "能否购买": true},
"芦笋": {"花费": 220, "生长时间": 3000, "收益": 370, "品质": "史诗", "描述": "高档蔬菜,营养价值极高", "耐候性": 8, "等级": 4, "经验": 40, "能否购买": true},
"茄子": {"花费": 190, "生长时间": 2400, "收益": 310, "品质": "史诗", "描述": "紫色的营养蔬菜", "耐候性": 10, "等级": 4, "经验": 32, "能否购买": true},
"西瓜": {"花费": 250, "生长时间": 4800, "收益": 450, "品质": "优良", "描述": "夏日消暑的大型水果", "耐候性": 6, "等级": 5, "经验": 50, "能否购买": true},
"甘蔗": {"花费": 280, "生长时间": 5400, "收益": 500, "品质": "优良", "描述": "制糖的重要原料", "耐候性": 5, "等级": 5, "经验": 55, "能否购买": true},
"香草": {"花费": 300, "生长时间": 6000, "收益": 550, "品质": "优良", "描述": "珍贵的调料植物", "耐候性": 7, "等级": 5, "经验": 60, "能否购买": true},
"甜菜": {"花费": 240, "生长时间": 4200, "收益": 420, "品质": "优良", "描述": "制糖的另一种选择", "耐候性": 11, "等级": 5, "经验": 45, "能否购买": true},
"百合花": {"花费": 260, "生长时间": 4800, "收益": 480, "品质": "优良", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 5, "经验": 50, "能否购买": true},
"康乃馨": {"花费": 270, "生长时间": 5100, "收益": 510, "品质": "优良", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 5, "经验": 50, "能否购买": true},
"郁金香": {"花费": 280, "生长时间": 5100, "收益": 510, "品质": "优良", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 5, "经验": 50, "能否购买": true},
"人参": {"花费": 400, "生长时间": 7200, "收益": 720, "品质": "传奇", "描述": "珍贵的药用植物,需要耐心培养", "耐候性": 15, "等级": 6, "经验": 80, "能否购买": true},
"富贵竹": {"花费": 350, "生长时间": 6600, "收益": 650, "品质": "传奇", "描述": "寓意吉祥的观赏植物", "耐候性": 12, "等级": 6, "经验": 75, "能否购买": true},
"芦荟": {"花费": 320, "生长时间": 6000, "收益": 600, "品质": "传奇", "描述": "具有药用价值的多肉植物", "耐候性": 18, "等级": 6, "经验": 70, "能否购买": true},
"哈密瓜": {"花费": 380, "生长时间": 7800, "收益": 700, "品质": "传奇", "描述": "甘甜的高级水果", "耐候性": 8, "等级": 6, "经验": 85, "能否购买": true},
"金橘": {"花费": 500, "生长时间": 10800, "收益": 900, "品质": "传奇", "描述": "金黄色的珍贵柑橘", "耐候性": 10, "等级": 7, "经验": 120, "能否购买": true},
"苹果树": {"花费": 450, "生长时间": 9600, "收益": 820, "品质": "传奇", "描述": "结果丰富的果树", "耐候性": 14, "等级": 7, "经验": 110, "能否购买": true},
"橘子树": {"花费": 480, "生长时间": 10200, "收益": 850, "品质": "传奇", "描述": "维生素C丰富的果树", "耐候性": 12, "等级": 7, "经验": 115, "能否购买": true},
"香蕉树": {"花费": 420, "生长时间": 8400, "收益": 780, "品质": "传奇", "描述": "热带水果之王", "耐候性": 5, "等级": 7, "经验": 100, "能否购买": true},
"向日葵": {"花费": 160, "生长时间": 3600, "收益": 280, "品质": "史诗", "描述": "向阳而生的美丽花朵", "耐候性": 13, "等级": 4, "经验": 35, "能否购买": true},
"树莓": {"花费": 140, "生长时间": 2700, "收益": 240, "品质": "稀有", "描述": "小巧精致的浆果", "耐候性": 9, "等级": 3, "经验": 30, "能否购买": true},
"豌豆": {"花费": 65, "生长时间": 720, "收益": 110, "品质": "优良", "描述": "嫩绿的豆荚蔬菜", "耐候性": 10, "等级": 2, "经验": 15, "能否购买": true},
"黄瓜": {"花费": 85, "生长时间": 1200, "收益": 150, "品质": "优良", "描述": "清脆爽口的瓜类", "耐候性": 8, "等级": 2, "经验": 18, "能否购买": true},
"大白菜": {"花费": 70, "生长时间": 900, "收益": 120, "品质": "优良", "描述": "北方冬季的主要蔬菜", "耐候性": 15, "等级": 2, "经验": 16, "能否购买": true},
"蕨菜": {"花费": 180, "生长时间": 2400, "收益": 300, "品质": "史诗", "描述": "野生山菜,口感独特", "耐候性": 16, "等级": 4, "经验": 35, "能否购买": true},
"龙果": {"花费": 800, "生长时间": 14400, "收益": 1500, "品质": "传奇", "描述": "传说中的神秘果实,蕴含强大能量", "耐候性": 25, "等级": 8, "经验": 200, "能否购买": true},
"松露": {"花费": 1000, "生长时间": 18000, "收益": 2000, "品质": "传奇", "描述": "地下的黑金,顶级料理的灵魂", "耐候性": 20, "等级": 8, "经验": 250, "能否购买": true},
"冬虫夏草": {"花费": 600, "生长时间": 12000, "收益": 1200, "品质": "传奇", "描述": "稀世珍宝,药王之称", "耐候性": 30, "等级": 7, "经验": 180, "能否购买": true},
"山葵": {"花费": 500, "生长时间": 10800, "收益": 1000, "品质": "优良", "描述": "日式料理的珍贵调料", "耐候性": 22, "等级": 7, "经验": 150, "能否购买": true},
"鱼腥草": {"花费": 300, "生长时间": 7200, "收益": 600, "品质": "稀有", "描述": "具有特殊药用价值的野菜", "耐候性": 18, "等级": 6, "经验": 90, "能否购买": true},
"杂交树1": {"花费": 1200, "生长时间": 21600, "收益": 2500, "品质": "传奇", "描述": "初中生物书最后的想象", "耐候性": 35, "等级": 9, "经验": 300, "能否购买": true},
"杂交树2": {"花费": 1500, "生长时间": 25200, "收益": 3000, "品质": "传奇", "描述": "初中生物书最后的想象", "耐候性": 40, "等级": 10, "经验": 400, "能否购买": true}
"龙果": {"花费": 400, "生长时间": 4800, "收益": 600, "品质": "传奇", "描述": "极为稀有的热带作物,产量和价值都极高", "耐候性": 25, "等级": 6, "经验": 60},
"松露": {"花费": 500, "生长时间": 7200, "收益": 700, "品质": "传奇", "描述": "极其珍贵的地下作物,市场价格极高", "耐候性": 23, "等级": 7, "经验": 80},
"人参": {"花费": 450, "生长时间": 6600, "收益": 650, "品质": "传奇", "描述": "需要耐心等待的珍贵药材", "耐候性": 22, "等级": 6, "经验": 75},
"金橘": {"花费": 420, "生长时间": 4800, "收益": 620, "品质": "传奇", "描述": "少见的耐寒果树,市场需求量极大", "耐候性": 26, "等级": 7, "经验": 70}
}

View File

@@ -65,9 +65,9 @@ func _customize_button(button: Button) -> void:
func _apply_custom_theme() -> void:
# 设置面板背景颜色
var panel_style := StyleBoxFlat.new()
panel_style.bg_color = Color("f8fafc") # very light gray
#panel_style.bg_color = Color.AQUA # very light gray
panel_style.set_border_width_all(2)
panel_style.border_color = Color("cbd5e1")
#panel_style.border_color = Color("cbd5e1")
self.add_theme_stylebox_override("panel", panel_style) # ✅ 修正方法名

237
GUI/AccountSettingPanel.gd Normal file
View File

@@ -0,0 +1,237 @@
extends Panel
@onready var user_name_input: Label = $VBox1/Grid/User_Name_Input #用户名/账号名
@onready var user_password_input: LineEdit = $VBox1/Grid/User_Password_Input#账号密码
@onready var player_name_input: LineEdit = $VBox1/Grid/Player_Name_Input #玩家昵称
@onready var farm_name_input: LineEdit = $VBox1/Grid/Farm_Name_Input #农场名称
@onready var personal_profile_input: LineEdit = $VBox1/Grid/Personal_Profile_Input#个人简介
@onready var remove_account_btn: Button = $VBox1/HBox2/Remove_Account_Btn #删除账号按钮
@onready var confirm_btn: Button = $VBox1/HBox2/Confirm_Btn #修改账号信息按钮
@onready var quit_button: Button = $QuitButton #关闭玩家信息面板按钮
@onready var refresh_button: Button = $RefreshButton#刷新玩家信息按钮
#预添加常用的面板和组件
@onready var main_game = get_node("/root/main")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
@onready var accept_dialog = get_node("/root/main/UI/AcceptDialog")
# 存储待执行的操作类型
var pending_action = ""
func _ready() -> void:
# 连接按钮信号
quit_button.pressed.connect(_on_quit_button_pressed)
refresh_button.pressed.connect(_on_refresh_button_pressed)
confirm_btn.pressed.connect(_on_confirm_btn_pressed)
remove_account_btn.pressed.connect(_on_remove_account_btn_pressed)
# 初始显示界面数据
_refresh_player_info()
# 如果有网络连接,自动请求最新数据(延迟一秒等待初始化完成)
if network_manager and network_manager.has_method("is_connected_to_server") and network_manager.is_connected_to_server():
await get_tree().create_timer(1.0).timeout
_request_player_info_from_server()
#关闭玩家信息面板按钮点击
func _on_quit_button_pressed() -> void:
self.hide()
GlobalVariables.isZoomDisabled = false
#刷新玩家信息按钮点击
func _on_refresh_button_pressed() -> void:
# 向服务器请求最新的玩家数据
_request_player_info_from_server()
#向服务器请求玩家信息
func _request_player_info_from_server():
if not network_manager:
_show_message("网络管理器不可用", Color.RED)
return
if not network_manager.is_connected_to_server():
_show_message("未连接到服务器", Color.RED)
return
# 发送刷新请求到服务器
var message = {
"type": "refresh_player_info"
}
var success = network_manager.send_message(message)
if success:
_show_message("正在刷新玩家信息...", Color.YELLOW)
else:
_show_message("发送刷新请求失败", Color.RED)
#确认修改按钮点击
func _on_confirm_btn_pressed() -> void:
# 显示二次确认对话框
pending_action = "modify_account"
if accept_dialog:
accept_dialog.dialog_text = "确认要修改账号信息吗?这些更改将立即生效。"
accept_dialog.title = "确认修改"
accept_dialog.show()
# 连接确认信号
if not accept_dialog.confirmed.is_connected(_on_accept_dialog_confirmed):
accept_dialog.confirmed.connect(_on_accept_dialog_confirmed)
#删除账号按钮点击
func _on_remove_account_btn_pressed() -> void:
# 显示二次确认对话框
pending_action = "delete_account"
if accept_dialog:
accept_dialog.dialog_text = "警告:删除账号将永久移除您的所有数据,包括农场、作物、背包等所有内容。\n此操作无法撤销,确认要删除账号吗?"
accept_dialog.title = "删除账号确认"
accept_dialog.show()
# 连接确认信号
if not accept_dialog.confirmed.is_connected(_on_accept_dialog_confirmed):
accept_dialog.confirmed.connect(_on_accept_dialog_confirmed)
#确认对话框的确认按钮被点击
func _on_accept_dialog_confirmed() -> void:
match pending_action:
"modify_account":
_modify_account_info()
"delete_account":
_delete_account()
# 重置待执行操作
pending_action = ""
# 断开信号连接
if accept_dialog and accept_dialog.confirmed.is_connected(_on_accept_dialog_confirmed):
accept_dialog.confirmed.disconnect(_on_accept_dialog_confirmed)
#修改账号信息
func _modify_account_info():
if not network_manager:
_show_message("网络管理器不可用", Color.RED)
return
if not network_manager.is_connected_to_server():
_show_message("未连接到服务器", Color.RED)
return
# 获取输入的信息
var new_password = user_password_input.text.strip_edges()
var new_player_name = player_name_input.text.strip_edges()
var new_farm_name = farm_name_input.text.strip_edges()
var new_personal_profile = personal_profile_input.text.strip_edges()
# 验证输入
if new_password == "":
_show_message("密码不能为空", Color.RED)
return
if new_player_name == "":
_show_message("玩家昵称不能为空", Color.RED)
return
if new_farm_name == "":
_show_message("农场名称不能为空", Color.RED)
return
# 发送修改请求到服务器
var message = {
"type": "modify_account_info",
"new_password": new_password,
"new_player_name": new_player_name,
"new_farm_name": new_farm_name,
"new_personal_profile": new_personal_profile
}
var success = network_manager.send_message(message)
if success:
_show_message("正在更新账号信息...", Color.YELLOW)
else:
_show_message("发送修改请求失败", Color.RED)
#删除账号
func _delete_account():
if not network_manager:
_show_message("网络管理器不可用", Color.RED)
return
if not network_manager.is_connected_to_server():
_show_message("未连接到服务器", Color.RED)
return
# 发送删除账号请求到服务器
var message = {
"type": "delete_account"
}
var success = network_manager.send_message(message)
if success:
_show_message("正在删除账号...", Color.YELLOW)
else:
_show_message("发送删除请求失败", Color.RED)
#刷新玩家信息显示(从本地数据)
func _refresh_player_info():
# 从主游戏获取当前玩家信息
user_name_input.text = main_game.user_name if main_game.user_name != "" else "未知"
user_password_input.text = main_game.user_password if main_game.user_password != "" else ""
# 优先从 login_data 获取数据,如果没有则从 data 获取
var player_data = main_game.login_data if main_game.login_data.size() > 0 else main_game.data
player_name_input.text = player_data.get("player_name", "")
farm_name_input.text = player_data.get("farm_name", "")
personal_profile_input.text = player_data.get("个人简介", "")
#显示消息提示
func _show_message(message: String, color: Color):
if main_game and main_game.has_method("show_message"):
main_game.show_message(message, color)
else:
pass
#处理服务器响应
func handle_account_response(response_data: Dictionary):
var message_type = response_data.get("type", "")
var success = response_data.get("success", false)
var message = response_data.get("message", "")
match message_type:
"modify_account_info_response":
if success:
_show_message(message, Color.GREEN)
# 更新本地数据
if response_data.has("updated_data"):
var updated_data = response_data["updated_data"]
if main_game:
if updated_data.has("player_name"):
main_game.data["player_name"] = updated_data["player_name"]
if updated_data.has("farm_name"):
main_game.data["farm_name"] = updated_data["farm_name"]
if updated_data.has("个人简介"):
main_game.data["个人简介"] = updated_data["个人简介"]
if updated_data.has("user_password"):
main_game.user_password = updated_data["user_password"]
# 刷新显示
_refresh_player_info()
else:
_show_message(message, Color.RED)
"delete_account_response":
if success:
_show_message(message, Color.GREEN)
# 等待2秒后返回主菜单
await get_tree().create_timer(2.0).timeout
get_tree().change_scene_to_file("res://GUI/MainMenuPanel.tscn")
else:
_show_message(message, Color.RED)
"refresh_player_info_response":
if success:
# 主游戏已经更新了数据,直接刷新显示即可
_refresh_player_info()
_show_message("玩家信息已刷新", Color.GREEN)
else:
_show_message(message if message != "" else "刷新失败", Color.RED)

View File

@@ -0,0 +1 @@
uid://dinrduqwsf5k5

500
GUI/CropStorePanel.gd Normal file
View File

@@ -0,0 +1,500 @@
extends Panel
#种子商店面板
#种子商店格子
@onready var crop_grid_container : GridContainer = $ScrollContainer/Crop_Grid
@onready var quit_button : Button = $QuitButton
#各种排序过滤按钮
@onready var sort_all_button : Button = $SortContainer/Sort_All#全部
@onready var sort_common_button : Button = $SortContainer/Sort_Common#普通
@onready var sort_superior_button : Button = $SortContainer/Sort_Superior#优良
@onready var sort_rare_button : Button = $SortContainer/Sort_Rare#稀有
@onready var sort_epic_button : Button = $SortContainer/Sort_Epic#史诗
@onready var sort_legendary_button : Button = $SortContainer/Sort_Legendary#传奇
@onready var sort_price_button : Button = $SortContainer/Sort_Price#价格
@onready var sort_growtime_button : Button = $SortContainer/Sort_GrowTime#生长时间
@onready var sort_profit_button : Button = $SortContainer/Sort_Profit#收益
@onready var sort_level_button : Button = $SortContainer/Sort_Level#等级
#预添加常用的面板
@onready var main_game = get_node("/root/main")
@onready var land_panel = get_node("/root/main/UI/LandPanel")
@onready var crop_store_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var player_ranking_panel = get_node("/root/main/UI/PlayerRankingPanel")
@onready var player_bag_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 作物图片缓存(复用主游戏的缓存系统)
var crop_textures_cache : Dictionary = {}
var crop_frame_counts : Dictionary = {}
# 当前过滤和排序设置
var current_filter_quality = ""
var current_sort_key = ""
var current_sort_ascending = true
# 准备函数
func _ready():
# 连接按钮信号
_connect_buttons()
# 隐藏面板(初始默认隐藏)
self.hide()
# 连接所有按钮信号
func _connect_buttons():
# 关闭按钮
quit_button.pressed.connect(self._on_quit_button_pressed)
# 过滤按钮
sort_all_button.pressed.connect(func(): _filter_by_quality(""))
sort_common_button.pressed.connect(func(): _filter_by_quality("普通"))
sort_superior_button.pressed.connect(func(): _filter_by_quality("优良"))
sort_rare_button.pressed.connect(func(): _filter_by_quality("稀有"))
sort_epic_button.pressed.connect(func(): _filter_by_quality("史诗"))
sort_legendary_button.pressed.connect(func(): _filter_by_quality("传奇"))
# 排序按钮
sort_price_button.pressed.connect(func(): _sort_by("花费"))
sort_growtime_button.pressed.connect(func(): _sort_by("生长时间"))
sort_profit_button.pressed.connect(func(): _sort_by("收益"))
sort_level_button.pressed.connect(func(): _sort_by("等级"))
# 初始化商店
func init_store():
# 清空已有的作物按钮
for child in crop_grid_container.get_children():
child.queue_free()
# 遍历可种植的作物数据并添加到商店
for crop_name in main_game.can_planted_crop:
var crop = main_game.can_planted_crop[crop_name]
# 检查是否可以购买
if not crop.get("能否购买", true):
continue
# 只显示当前等级可以种植的作物
if crop["等级"] <= main_game.level:
var store_btn = _create_store_button(crop_name, crop["品质"])
crop_grid_container.add_child(store_btn)
#print("添加商店按钮: " + crop_name)
print("商店初始化完成,共添加按钮: " + str(crop_grid_container.get_child_count()) + "")
# 更新金钱显示
_update_money_display()
# 创建商店按钮
func _create_store_button(crop_name: String, crop_quality: String) -> Button:
# 根据品质选择相应的按钮
var button = main_game.item_button.duplicate()
var crop = main_game.can_planted_crop[crop_name]
# 确保按钮可见并可点击
button.visible = true
button.disabled = false
button.focus_mode = Control.FOCUS_ALL
# 设置按钮文本,显示价格
button.text = str(crop_quality + "-" + crop_name + "\n价格: ¥" + str(crop["花费"]))
# 将成熟时间从秒转换为天时分秒格式
var total_seconds = int(crop["生长时间"])
# 定义时间单位换算
var SECONDS_PER_MINUTE = 60
var SECONDS_PER_HOUR = 3600
var SECONDS_PER_DAY = 86400
# 计算各时间单位
var days = total_seconds / SECONDS_PER_DAY
total_seconds %= SECONDS_PER_DAY
var hours = total_seconds / SECONDS_PER_HOUR
total_seconds %= SECONDS_PER_HOUR
var minutes = total_seconds / SECONDS_PER_MINUTE
var seconds = total_seconds % SECONDS_PER_MINUTE
# 构建时间字符串(只显示有值的单位)
var time_str = ""
if days > 0:
time_str += str(days) + ""
if hours > 0:
time_str += str(hours) + "小时"
if minutes > 0:
time_str += str(minutes) + "分钟"
if seconds > 0:
time_str += str(seconds) + ""
button.tooltip_text = str(
"作物: " + crop_name + "\n" +
"品质: " + crop_quality + "\n" +
"价格: " + str(crop["花费"]) + "\n" +
"成熟时间: " + time_str + "\n" +
"收获收益: " + str(crop["收益"]) + "\n" +
"需求等级: " + str(crop["等级"]) + "\n" +
"耐候性: " + str(crop["耐候性"]) + "\n" +
"经验: " + str(crop["经验"]) + "\n" +
"描述: " + str(crop["描述"])
)
# 添加按钮事件
button.pressed.connect(func(): _on_store_buy_pressed(crop_name))
# 更新按钮的作物图片
_update_button_crop_image(button, crop_name)
# 如果按钮有标题标签,设置标题
if button.has_node("Title"):
match crop_quality:
"普通":
button.get_node("Title").modulate = Color.HONEYDEW#白色
"优良":
button.get_node("Title").modulate =Color.DODGER_BLUE#深蓝色
"稀有":
button.get_node("Title").modulate =Color.HOT_PINK#品红色
"史诗":
button.get_node("Title").modulate =Color.YELLOW#黄色
"传奇":
button.get_node("Title").modulate =Color.ORANGE_RED#红色
return button
# 购买种子事件处理
func _on_store_buy_pressed(crop_name: String):
var crop = main_game.can_planted_crop[crop_name]
# 检查等级要求
if main_game.level < crop["等级"]:
Toast.show("等级不足,无法购买此种子", Color.RED)
return
# 检查金钱是否足够
if main_game.money < crop["花费"]:
Toast.show("金钱不足,无法购买种子", Color.RED)
return
# 发送购买请求到服务器
if network_manager and network_manager.sendBuySeed(crop_name):
# 将种子添加到背包
var found = false
for seed_item in main_game.player_bag:
if seed_item["name"] == crop_name:
seed_item["count"] += 1
found = true
break
if not found:
main_game.player_bag.append({
"name": crop_name,
"quality": crop["品质"],
"count": 1
})
# 更新背包UI
crop_store_panel.update_player_bag_ui()
# 更新金钱显示
_update_money_display()
# 按品质过滤作物
func _filter_by_quality(quality: String):
current_filter_quality = quality
_apply_filter_and_sort()
# 按指定键排序
func _sort_by(sort_key: String):
# 切换排序方向或设置新排序键
if current_sort_key == sort_key:
current_sort_ascending = !current_sort_ascending
else:
current_sort_key = sort_key
current_sort_ascending = true
_apply_filter_and_sort()
# 应用过滤和排序
func _apply_filter_and_sort():
# 清空现有按钮
for child in crop_grid_container.get_children():
child.queue_free()
# 收集符合条件的作物
var filtered_crops = []
for crop_name in main_game.can_planted_crop:
var crop = main_game.can_planted_crop[crop_name]
# 检查是否可以购买
if not crop.get("能否购买", true):
continue
# 检查等级和品质过滤
if crop["等级"] > main_game.level:
continue
if current_filter_quality != "" and crop["品质"] != current_filter_quality:
continue
# 添加到过滤后的列表
filtered_crops.append({
"name": crop_name,
"data": crop
})
# 如果有排序条件,进行排序
if current_sort_key != "":
filtered_crops.sort_custom(Callable(self, "_sort_crop_items"))
# 添加所有过滤和排序后的作物
for crop in filtered_crops:
var store_btn = _create_store_button(crop["name"], crop["data"]["品质"])
crop_grid_container.add_child(store_btn)
# 更新金钱显示
_update_money_display()
# 自定义排序函数
func _sort_crop_items(a, b):
if current_sort_ascending:
return a["data"][current_sort_key] < b["data"][current_sort_key]
else:
return a["data"][current_sort_key] > b["data"][current_sort_key]
# 更新金钱显示
func _update_money_display():
var money_label = get_node_or_null("MoneyLabel")
if money_label == null:
# 创建金钱显示标签
money_label = Label.new()
money_label.name = "MoneyLabel"
money_label.position = Vector2(10, 10)
money_label.size = Vector2(300, 45)
# 设置标签样式
money_label.add_theme_color_override("font_color", Color(1, 0.647, 0, 1)) # 橙色
money_label.add_theme_font_size_override("font_size", 24)
add_child(money_label)
# 更新金钱显示
money_label.text = "当前金钱:" + str(main_game.money) + ""
# 刷新商店内容,可以在金钱变化或等级提升后调用
func refresh_store():
# 清空并重新创建商店按钮
init_store()
# 尝试创建过滤按钮(如果商店面板中没有这些按钮)
_create_filter_buttons_if_needed()
# 如果需要,动态创建过滤按钮
func _create_filter_buttons_if_needed():
# 检查是否已存在过滤器容器
var filter_container = get_node_or_null("FilterContainer")
if filter_container == null:
# 创建过滤器容器
filter_container = HBoxContainer.new()
filter_container.name = "FilterContainer"
# 设置容器位置和大小
filter_container.position = Vector2(320, 10)
filter_container.size = Vector2(770, 45)
add_child(filter_container)
# 添加过滤按钮
_add_filter_button(filter_container, "全部", func(): _filter_by_quality(""))
_add_filter_button(filter_container, "普通", func(): _filter_by_quality("普通"))
_add_filter_button(filter_container, "优良", func(): _filter_by_quality("优良"))
_add_filter_button(filter_container, "稀有", func(): _filter_by_quality("稀有"))
_add_filter_button(filter_container, "史诗", func(): _filter_by_quality("史诗"))
_add_filter_button(filter_container, "传奇", func(): _filter_by_quality("传奇"))
# 检查是否已存在排序容器
var sort_container = get_node_or_null("SortContainer")
if sort_container == null:
# 创建排序容器
sort_container = HBoxContainer.new()
sort_container.name = "SortContainer"
# 设置容器位置和大小
sort_container.position = Vector2(320, 55)
sort_container.size = Vector2(770, 30)
add_child(sort_container)
# 添加排序按钮
_add_filter_button(sort_container, "按价格", func(): _sort_by("花费"))
_add_filter_button(sort_container, "按生长时间", func(): _sort_by("生长时间"))
_add_filter_button(sort_container, "按收益", func(): _sort_by("收益"))
_add_filter_button(sort_container, "按等级", func(): _sort_by("等级"))
# 添加过滤按钮
func _add_filter_button(container, text, callback):
var button = Button.new()
button.text = text
button.custom_minimum_size = Vector2(100, 0)
button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
container.add_child(button)
button.pressed.connect(callback)
# 获取作物的成熟图片(用于商店显示)
func _get_crop_final_texture(crop_name: String) -> Texture2D:
# 优先从主游戏的缓存中获取成熟图片
if main_game and main_game.crop_mature_textures_cache.has(crop_name):
return main_game.crop_mature_textures_cache[crop_name]
# 如果缓存中没有,再尝试加载"成熟.webp"图片
var crop_path = "res://assets/作物/" + crop_name + "/"
var mature_texture_path = crop_path + "成熟.webp"
if ResourceLoader.exists(mature_texture_path):
var texture = load(mature_texture_path)
if texture:
print("商店加载作物成熟图片:", crop_name)
# 如果主游戏存在,也缓存到主游戏中
if main_game:
main_game.crop_mature_textures_cache[crop_name] = texture
return texture
# 如果没有找到作物的成熟图片,使用默认的成熟图片
if main_game and main_game.crop_mature_textures_cache.has("默认"):
var default_texture = main_game.crop_mature_textures_cache["默认"]
# 缓存给这个作物
main_game.crop_mature_textures_cache[crop_name] = default_texture
return default_texture
# 最后尝试直接加载默认成熟图片
var default_mature_path = "res://assets/作物/默认/成熟.webp"
if ResourceLoader.exists(default_mature_path):
var texture = load(default_mature_path)
if texture:
print("商店使用默认成熟图片:", crop_name)
# 缓存到主游戏
if main_game:
main_game.crop_mature_textures_cache["默认"] = texture
main_game.crop_mature_textures_cache[crop_name] = texture
return texture
return null
# 加载作物图片序列帧(复用主游戏的逻辑)
func _load_crop_textures(crop_name: String) -> Array:
if crop_textures_cache.has(crop_name):
return crop_textures_cache[crop_name]
var textures = []
var crop_path = "res://assets/作物/" + crop_name + "/"
var default_path = "res://assets/作物/默认/"
# 检查作物文件夹是否存在
if DirAccess.dir_exists_absolute(crop_path):
# 尝试加载作物的序列帧从0开始
var frame_index = 0
while true:
var texture_path = crop_path + str(frame_index) + ".webp"
if ResourceLoader.exists(texture_path):
var texture = load(texture_path)
if texture:
textures.append(texture)
frame_index += 1
else:
break
else:
break
if textures.size() > 0:
pass
else:
textures = _load_default_textures()
else:
print("商店:作物 ", crop_name, " 的文件夹不存在,使用默认图片")
textures = _load_default_textures()
# 缓存结果
crop_textures_cache[crop_name] = textures
crop_frame_counts[crop_name] = textures.size()
return textures
# 加载默认图片
func _load_default_textures() -> Array:
if crop_textures_cache.has("默认"):
return crop_textures_cache["默认"]
var textures = []
var default_path = "res://assets/作物/默认/"
# 尝试加载默认图片序列帧
var frame_index = 0
while true:
var texture_path = default_path + str(frame_index) + ".webp"
if ResourceLoader.exists(texture_path):
var texture = load(texture_path)
if texture:
textures.append(texture)
frame_index += 1
else:
break
else:
break
# 如果没有找到序列帧,尝试加载单个默认图片
if textures.size() == 0:
var single_texture_path = default_path + "0.webp"
if ResourceLoader.exists(single_texture_path):
var texture = load(single_texture_path)
if texture:
textures.append(texture)
# 缓存默认图片
crop_textures_cache["默认"] = textures
crop_frame_counts["默认"] = textures.size()
return textures
# 更新按钮的作物图片
func _update_button_crop_image(button: Button, crop_name: String):
# 检查按钮是否有CropImage节点
var crop_image = button.get_node_or_null("CropImage")
if not crop_image:
print("商店按钮没有找到CropImage节点", button.name)
return
# 获取作物的最后一帧图片
var texture = _get_crop_final_texture(crop_name)
if texture:
# CropImage是Sprite2D直接设置texture属性
crop_image.texture = texture
crop_image.visible = true
print("商店更新作物图片:", crop_name)
else:
crop_image.visible = false
print("商店无法获取作物图片:", crop_name)
# 兼容MainGame.gd中的调用转发到_on_store_buy_pressed
func _on_crop_selected(crop_name: String):
_on_store_buy_pressed(crop_name)
#=========================面板通用处理=========================
#手动刷新种子商店面板
func _on_refresh_button_pressed() -> void:
# 重新初始化种子商店
init_store()
Toast.show("种子商店已刷新", Color.GREEN, 2.0, 1.0)
#关闭种子商店面板
func _on_quit_button_pressed():
#打开面板后暂时禁用相机功能
GlobalVariables.isZoomDisabled = false
self.hide()
#=========================面板通用处理=========================

View File

@@ -0,0 +1 @@
uid://mtfp0ct42nrx

408
GUI/CropWarehousePanel.gd Normal file
View File

@@ -0,0 +1,408 @@
extends Panel
#这是作物仓库面板 用来显示玩家收获的作物的成熟品 比如各种果实和花朵
# 作物仓库格子容器
@onready var crop_warehouse_grid_container : GridContainer = $ScrollContainer/Warehouse_Grid
@onready var quit_button : Button = $QuitButton
#各种排序过滤按钮
@onready var sort_all_button : Button = $SortContainer/Sort_All#全部
@onready var sort_common_button : Button = $SortContainer/Sort_Common#普通
@onready var sort_superior_button : Button = $SortContainer/Sort_Superior#优良
@onready var sort_rare_button : Button = $SortContainer/Sort_Rare#稀有
@onready var sort_epic_button : Button = $SortContainer/Sort_Epic#史诗
@onready var sort_legendary_button : Button = $SortContainer/Sort_Legendary#传奇
@onready var sort_price_button : Button = $SortContainer/Sort_Price#价格
@onready var sort_growtime_button : Button = $SortContainer/Sort_GrowTime#生长时间
@onready var sort_profit_button : Button = $SortContainer/Sort_Profit#收益
@onready var sort_level_button : Button = $SortContainer/Sort_Level#等级
#预添加常用的面板
@onready var main_game = get_node("/root/main")
@onready var land_panel = get_node("/root/main/UI/LandPanel")
@onready var crop_store_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var player_ranking_panel = get_node("/root/main/UI/PlayerRankingPanel")
@onready var player_bag_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 作物图片缓存(复用主游戏的缓存系统)
var crop_textures_cache : Dictionary = {}
var crop_frame_counts : Dictionary = {}
# 当前过滤和排序设置
var current_filter_quality = ""
var current_sort_key = ""
var current_sort_ascending = true
# 准备函数
func _ready():
# 连接按钮信号
_connect_buttons()
# 隐藏面板(初始默认隐藏)
self.hide()
# 连接所有按钮信号
func _connect_buttons():
# 关闭按钮
quit_button.pressed.connect(self._on_quit_button_pressed)
# 过滤按钮
sort_all_button.pressed.connect(func(): _filter_by_quality(""))
sort_common_button.pressed.connect(func(): _filter_by_quality("普通"))
sort_superior_button.pressed.connect(func(): _filter_by_quality("优良"))
sort_rare_button.pressed.connect(func(): _filter_by_quality("稀有"))
sort_epic_button.pressed.connect(func(): _filter_by_quality("史诗"))
sort_legendary_button.pressed.connect(func(): _filter_by_quality("传奇"))
# 排序按钮
sort_price_button.pressed.connect(func(): _sort_by("花费"))
sort_growtime_button.pressed.connect(func(): _sort_by("生长时间"))
sort_profit_button.pressed.connect(func(): _sort_by("收益"))
sort_level_button.pressed.connect(func(): _sort_by("等级"))
# 初始化作物仓库
func init_crop_warehouse():
# 清空作物仓库格子
for child in crop_warehouse_grid_container.get_children():
child.queue_free()
# 显示仓库中的成熟物
update_crop_warehouse_ui()
# 更新作物仓库UI
func update_crop_warehouse_ui():
# 清空作物仓库格子
for child in crop_warehouse_grid_container.get_children():
child.queue_free()
#print("更新作物仓库UI仓库中物品数量", main_game.crop_warehouse.size())
# 应用过滤和排序
var filtered_crops = _get_filtered_and_sorted_crops()
# 为仓库中的每个过滤后的成熟物创建按钮
for crop_item in filtered_crops:
var crop_name = crop_item["name"]
var crop_quality = crop_item.get("quality", "普通")
var crop_count = crop_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))
# 根据是否处于访问模式连接不同的事件
if main_game.is_visiting_mode:
# 访问模式下,点击成熟物只显示信息,不能操作
button.pressed.connect(func(): _on_visit_crop_selected(crop_name, crop_count))
else:
# 正常模式下,连接成熟物信息显示事件
button.pressed.connect(func(): _on_crop_selected(crop_name, crop_count))
crop_warehouse_grid_container.add_child(button)
# 获取过滤和排序后的成熟物列表
func _get_filtered_and_sorted_crops():
var filtered_crops = []
# 收集符合条件的成熟物
for crop_item in main_game.crop_warehouse:
# 安全获取品质字段(兼容老数据)
var item_quality = crop_item.get("quality", "普通")
# 品质过滤
if current_filter_quality != "" and item_quality != current_filter_quality:
continue
# 获取成熟物对应的作物数据
var crop_data = null
if main_game.can_planted_crop.has(crop_item["name"]):
crop_data = main_game.can_planted_crop[crop_item["name"]]
# 添加到过滤后的列表
filtered_crops.append({
"name": crop_item["name"],
"quality": item_quality,
"count": crop_item["count"],
"data": crop_data
})
# 如果有排序条件且数据可用,进行排序
if current_sort_key != "":
filtered_crops.sort_custom(Callable(self, "_sort_crop_items"))
return filtered_crops
# 自定义排序函数
func _sort_crop_items(a, b):
# 检查是否有有效数据用于排序
if a["data"] == null or b["data"] == null:
# 如果某一项没有数据,将其排在后面
if a["data"] == null and b["data"] != null:
return false
if a["data"] != null and b["data"] == null:
return true
# 如果都没有数据,按名称排序
return a["name"] < b["name"]
# 确保排序键存在于数据中
if !a["data"].has(current_sort_key) or !b["data"].has(current_sort_key):
print("警告: 排序键 ", current_sort_key, " 在某些成熟物数据中不存在")
return false
# 执行排序
if current_sort_ascending:
return a["data"][current_sort_key] < b["data"][current_sort_key]
else:
return a["data"][current_sort_key] > b["data"][current_sort_key]
# 按品质过滤成熟物
func _filter_by_quality(quality: String):
current_filter_quality = quality
print("过滤成熟物,品质: " + (quality if quality != "" else "全部"))
update_crop_warehouse_ui()
# 按指定键排序
func _sort_by(sort_key: String):
# 切换排序方向或设置新排序键
if current_sort_key == sort_key:
current_sort_ascending = !current_sort_ascending
else:
current_sort_key = sort_key
current_sort_ascending = true
print("排序成熟物,键: " + sort_key + ",升序: " + str(current_sort_ascending))
update_crop_warehouse_ui()
# 创建作物按钮
func _create_crop_button(crop_name: String, crop_quality: String) -> Button:
# 根据品质选择相应的进度条
var button = main_game.item_button.duplicate()
#普通 Color.HONEYDEW#白色
#优良 Color.DODGER_BLUE#深蓝色
#稀有 Color.HOT_PINK#品红色
#史诗 Color.YELLOW#黄色
#传奇 Color.ORANGE_RED#红色
#空地 Color.GREEN#绿色
#未开垦 Color.WEB_GRAY#深褐色
# 确保按钮可见并可点击
button.visible = true
button.disabled = false
button.focus_mode = Control.FOCUS_ALL
# 设置按钮文本
button.text = str(crop_quality + "-" + crop_name)
# 添加工具提示 (tooltip)
if main_game.can_planted_crop.has(crop_name):
var crop = main_game.can_planted_crop[crop_name]
# 将成熟时间从秒转换为天时分秒格式
var total_seconds = int(crop["生长时间"])
# 定义时间单位换算
var SECONDS_PER_MINUTE = 60
var SECONDS_PER_HOUR = 3600
var SECONDS_PER_DAY = 86400
# 计算各时间单位
var days = total_seconds / SECONDS_PER_DAY
total_seconds %= SECONDS_PER_DAY
var hours = total_seconds / SECONDS_PER_HOUR
total_seconds %= SECONDS_PER_HOUR
var minutes = total_seconds / SECONDS_PER_MINUTE
var seconds = total_seconds % SECONDS_PER_MINUTE
# 构建时间字符串(只显示有值的单位)
var time_str = ""
if days > 0:
time_str += str(days) + ""
if hours > 0:
time_str += str(hours) + "小时"
if minutes > 0:
time_str += str(minutes) + "分钟"
if seconds > 0:
time_str += str(seconds) + ""
button.tooltip_text = str(
"作物: " + crop_name + "\n" +
"品质: " + crop_quality + "\n" +
"原价格: " + str(crop["花费"]) + "\n" +
"成熟时间: " + time_str + "\n" +
"原收益: " + str(crop["收益"]) + "\n" +
"需求等级: " + str(crop["等级"]) + "\n" +
"耐候性: " + str(crop["耐候性"]) + "\n" +
"经验: " + str(crop["经验"]) + "\n" +
"描述: " + str(crop["描述"])
)
# 如果按钮有标题标签,设置标题
if button.has_node("Title"):
button.get_node("Title").text = crop_quality
match crop_quality:
"普通":
button.get_node("Title").modulate = Color.HONEYDEW#白色
"优良":
button.get_node("Title").modulate =Color.DODGER_BLUE#深蓝色
"稀有":
button.get_node("Title").modulate =Color.HOT_PINK#品红色
"史诗":
button.get_node("Title").modulate =Color.YELLOW#黄色
"传奇":
button.get_node("Title").modulate =Color.ORANGE_RED#红色
# 更新按钮的作物图片(使用收获物.webp
_update_button_crop_image(button, crop_name)
return button
# 正常模式下的成熟物点击处理
func _on_crop_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) + "\n"
info_text += "这是收获的成熟品,可以用于出售或其他用途"
else:
info_text = crop_name + " (数量: " + str(crop_count) + ")"
Toast.show(info_text, Color.GOLD, 3.0, 1.0)
print("查看成熟物信息: ", info_text)
# 访问模式下的成熟物点击处理
func _on_visit_crop_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)
# 获取作物的收获物图片(用于仓库显示)
func _get_crop_harvest_texture(crop_name: String) -> Texture2D:
# 尝试加载"收获物.webp"图片
var crop_path = "res://assets/作物/" + crop_name + "/"
var harvest_texture_path = crop_path + "收获物.webp"
if ResourceLoader.exists(harvest_texture_path):
var texture = load(harvest_texture_path)
if texture:
print("仓库加载作物收获物图片:", crop_name)
return texture
# 如果没有找到收获物图片,使用成熟图片作为后备
var mature_texture_path = crop_path + "成熟.webp"
if ResourceLoader.exists(mature_texture_path):
var texture = load(mature_texture_path)
if texture:
print("仓库使用成熟图片作为收获物:", crop_name)
return texture
# 如果都没有找到,使用默认的收获物图片
var default_harvest_path = "res://assets/作物/默认/收获物.webp"
if ResourceLoader.exists(default_harvest_path):
var texture = load(default_harvest_path)
if texture:
print("仓库使用默认收获物图片:", crop_name)
return texture
# 最后尝试默认成熟图片
var default_mature_path = "res://assets/作物/默认/成熟.webp"
if ResourceLoader.exists(default_mature_path):
var texture = load(default_mature_path)
if texture:
print("仓库使用默认成熟图片:", crop_name)
return texture
return null
# 更新按钮的作物图片
func _update_button_crop_image(button: Button, crop_name: String):
# 检查按钮是否有CropImage节点
var crop_image = button.get_node_or_null("CropImage")
if not crop_image:
print("仓库按钮没有找到CropImage节点", button.name)
return
# 获取作物的收获物图片
var texture = _get_crop_harvest_texture(crop_name)
if texture:
# CropImage是Sprite2D直接设置texture属性
crop_image.texture = texture
crop_image.visible = true
else:
crop_image.visible = false
print("仓库无法获取作物收获物图片:", crop_name)
#=========================面板通用处理=========================
#手动刷新作物仓库面板
func _on_refresh_button_pressed() -> void:
# 刷新作物仓库UI
update_crop_warehouse_ui()
Toast.show("作物仓库已刷新", Color.GREEN, 2.0, 1.0)
# 关闭作物仓库面板
func _on_quit_button_pressed():
#打开面板后暂时禁用相机功能
GlobalVariables.isZoomDisabled = false
self.hide()
#=========================面板通用处理=========================

View File

@@ -0,0 +1 @@
uid://ptdj0qmobihd

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://smypui0vyso5"]
[ext_resource type="Script" uid="uid://c0jfbtkh0mj5b" path="res://游戏弹窗模板/DailyCheckInPanel.gd" id="1_fj7a7"]
[ext_resource type="Script" uid="uid://c0jfbtkh0mj5b" path="res://GUI/DailyCheckInPanel.gd" id="1_fj7a7"]
[node name="DailyCheckInPanel" type="Panel"]
offset_right = 600.0
@@ -13,6 +13,12 @@ offset_top = -1.0
offset_right = 600.0
offset_bottom = 41.0
theme_override_colors/font_color = Color(0.624759, 0.8051, 0.828302, 1)
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 3
theme_override_constants/shadow_offset_y = 3
theme_override_constants/outline_size = 10
theme_override_constants/shadow_outline_size = 10
theme_override_font_sizes/font_size = 35
text = "📅每日签到📅"
horizontal_alignment = 1

68
GUI/GameSettingPanel.tscn Normal file
View File

@@ -0,0 +1,68 @@
[gd_scene load_steps=2 format=3 uid="uid://dos15dmc1b6bt"]
[ext_resource type="Script" uid="uid://ct7rhywlql4y4" path="res://GUI/GameSettingPanel.gd" id="1_0c52c"]
[node name="GameSettingPanel" type="Panel"]
offset_right = 1398.0
offset_bottom = 720.0
script = ExtResource("1_0c52c")
[node name="Title" type="Label" parent="."]
layout_mode = 0
offset_right = 1398.0
offset_bottom = 80.0
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 4
theme_override_constants/shadow_offset_y = 4
theme_override_constants/outline_size = 20
theme_override_constants/shadow_outline_size = 20
theme_override_font_sizes/font_size = 45
text = "游戏设置"
horizontal_alignment = 1
vertical_alignment = 1
[node name="QuitButton" type="Button" parent="."]
custom_minimum_size = Vector2(60, 60)
layout_mode = 0
offset_left = 1327.0
offset_right = 1400.0
offset_bottom = 80.0
theme_override_font_sizes/font_size = 35
text = "X"
[node name="LinkButton" type="LinkButton" parent="."]
layout_mode = 0
offset_left = 15.0
offset_top = 17.0
offset_right = 79.0
offset_bottom = 57.0
text = "打开网页"
uri = "http://192.168.1.110:19132/site/python"
[node name="Scroll" type="ScrollContainer" parent="."]
layout_mode = 0
offset_top = 80.0
offset_right = 1400.0
offset_bottom = 720.0
[node name="Panel" type="Panel" parent="Scroll"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Label" type="Label" parent="Scroll/Panel"]
layout_mode = 2
offset_right = 210.0
offset_bottom = 42.0
theme_override_font_sizes/font_size = 30
text = "背景音乐音量:"
[node name="HSlider" type="HSlider" parent="Scroll/Panel"]
layout_mode = 0
offset_left = 210.0
offset_top = 15.0
offset_right = 573.0
offset_bottom = 31.0
[connection signal="pressed" from="QuitButton" to="." method="_on_quit_button_pressed"]

View File

@@ -118,10 +118,7 @@ func display_updates(updates: Array) -> void:
# 处理换行符
content = content.replace("\\r\\n", "\n").replace("\\n", "\n")
# 高亮特殊符号
content = content.replace("", "[color=green]✓[/color]")
content = content.replace("修复:", "[color=yellow]修复:[/color]")
content = content.replace("添加", "[color=cyan]添加[/color]")
content = content.replace("修改", "[color=orange]修改[/color]")
#content = content.replace("✓", "[color=green]✓[/color]")
update_text += "[color=white]" + content + "[/color]\n"

280
GUI/ItemBagPanel.gd Normal file
View File

@@ -0,0 +1,280 @@
extends Panel
# 这是道具背包面板,用来显示玩家获得的道具
# 道具背包格子容器
@onready var bag_grid: GridContainer = $ScrollContainer/Bag_Grid
@onready var quit_button : Button = $QuitButton
# 预添加常用的面板
@onready var main_game = get_node("/root/main")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 道具使用状态
var selected_item_name: String = ""
var selected_item_button: Button = null
var is_item_selected: bool = false
# 准备函数
func _ready():
# 隐藏面板(初始默认隐藏)
self.hide()
# 初始化道具背包
func init_item_bag():
# 清空道具背包格子
for child in bag_grid.get_children():
child.queue_free()
# 显示背包中的道具
update_item_bag_ui()
# 更新道具背包UI
func update_item_bag_ui():
# 清空道具背包格子
for child in bag_grid.get_children():
child.queue_free()
print("更新道具背包UI背包中道具数量", main_game.item_bag.size())
# 为背包中的每个道具创建按钮
for item_data in main_game.item_bag:
var item_name = item_data["name"]
var item_count = item_data["count"]
# 创建道具按钮
var button = _create_item_button(item_name)
# 更新按钮文本显示数量
button.text = str(item_name + "\n数量:" + str(item_count))
# 根据是否处于访问模式连接不同的事件
if main_game.is_visiting_mode:
# 访问模式下,点击道具只显示信息,不能使用
button.pressed.connect(func(): _on_visit_item_selected(item_name, item_count))
else:
# 正常模式下,连接道具选择事件
button.pressed.connect(func(): _on_item_selected(item_name, item_count, button))
bag_grid.add_child(button)
# 创建道具按钮
func _create_item_button(item_name: String) -> Button:
# 使用绿色按钮作为道具按钮的默认样式
var button = main_game.item_button.duplicate()
# 确保按钮可见并可点击
button.visible = true
button.disabled = false
button.focus_mode = Control.FOCUS_ALL
# 设置按钮文本
button.text = item_name
# 添加工具提示从item_config.json获取道具信息
var item_config = _load_item_config()
if item_config and item_config.has(item_name):
var item_info = item_config[item_name]
var description = item_info.get("描述", "暂无描述")
var cost = item_info.get("花费", 0)
button.tooltip_text = str(
"道具: " + item_name + "\n" +
"价格: " + str(cost) + "\n" +
"描述: " + description + "\n" +
"点击选择道具,然后对地块使用"
)
else:
button.tooltip_text = str("道具: " + item_name + "\n描述: 暂无信息")
# 如果按钮有标题标签,设置标题
if button.has_node("Title"):
button.get_node("Title").text = "道具"
button.get_node("Title").modulate = Color.CYAN # 道具标题使用青色
# 更新按钮的道具图片
_update_button_item_image(button, item_name)
return button
# 加载道具配置数据
func _load_item_config() -> Dictionary:
# 从item_config.json加载道具配置数据
var file = FileAccess.open("res://Server/config/item_config.json", FileAccess.READ)
if not file:
print("无法读取道具配置文件!")
return {}
var json_text = file.get_as_text()
file.close()
var json = JSON.new()
var parse_result = json.parse(json_text)
if parse_result != OK:
print("道具配置JSON解析错误", json.get_error_message())
return {}
return json.get_data()
# 正常模式下的道具点击处理 - 选择道具
func _on_item_selected(item_name: String, item_count: int, button: Button):
# 检查道具是否可以使用
if not _is_item_usable(item_name):
# 显示道具信息
_show_item_info(item_name, item_count)
return
# 取消之前选择的道具
if selected_item_button and selected_item_button != button:
_deselect_item()
if selected_item_name == item_name:
# 如果点击的是已选择的道具,取消选择
_deselect_item()
Toast.show("已取消选择道具", Color.YELLOW, 2.0, 1.0)
else:
# 选择新道具
_select_item(item_name, button)
#点击后关闭玩家道具面板
_on_quit_button_pressed()
Toast.show("已选择 " + item_name + ",点击地块使用道具", Color.CYAN, 3.0, 1.0)
# 选择道具
func _select_item(item_name: String, button: Button):
selected_item_name = item_name
selected_item_button = button
is_item_selected = true
# 设置全局选择状态
main_game.selected_item_name = item_name
main_game.is_item_selected = true
# 更改按钮样式表示选中
if button.has_node("Title"):
button.get_node("Title").modulate = Color.YELLOW # 选中时使用黄色
# 取消选择道具
func _deselect_item():
selected_item_name = ""
is_item_selected = false
# 清除全局选择状态
main_game.selected_item_name = ""
main_game.is_item_selected = false
# 恢复按钮样式
if selected_item_button and selected_item_button.has_node("Title"):
selected_item_button.get_node("Title").modulate = Color.CYAN
selected_item_button = null
# 检查道具是否可以使用
func _is_item_usable(item_name: String) -> bool:
# 根据道具类型判断是否可以使用
match item_name:
"农家肥", "金坷垃", "生长素":
return true # 施肥道具
"水壶", "水桶":
return true # 浇水道具
"铲子":
return true # 铲除道具
"除草剂":
return true # 除草道具
"精准采集锄", "时运锄":
return true # 采集道具
"杀虫剂":
return false # 其他道具(暂不实现)
_:
return false
# 显示道具信息
func _show_item_info(item_name: String, item_count: int):
var info_text = ""
var item_config = _load_item_config()
if item_config and item_config.has(item_name):
var item_info = item_config[item_name]
var description = item_info.get("描述", "暂无描述")
var cost = item_info.get("花费", 0)
info_text = item_name + " (数量: " + str(item_count) + ")\n"
info_text += "价格: " + str(cost) + "\n"
info_text += "描述: " + description
if not _is_item_usable(item_name):
info_text += "\n注意: 此道具功能暂未实现"
else:
info_text = item_name + " (数量: " + str(item_count) + ")\n描述: 暂无信息"
Toast.show(info_text, Color.CYAN, 3.0, 1.0)
# 访问模式下的道具点击处理
func _on_visit_item_selected(item_name: String, item_count: int):
# 显示道具信息
_show_item_info(item_name, item_count)
# 更新按钮的道具图片
func _update_button_item_image(button: Button, item_name: String):
# 检查按钮是否有CropImage节点
var item_image = button.get_node_or_null("CropImage")
if not item_image:
print("道具背包按钮没有找到CropImage节点", button.name)
return
# 从配置文件获取道具图片路径
var item_config = _load_item_config()
var texture = null
if item_config and item_config.has(item_name):
var item_info = item_config[item_name]
var image_path = item_info.get("道具图片", "")
if image_path != "" and ResourceLoader.exists(image_path):
# 尝试加载道具图片
texture = load(image_path)
if texture:
print("成功加载道具图片:", item_name, " -> ", image_path)
else:
print("加载道具图片失败:", item_name, " -> ", image_path)
else:
print("道具图片路径无效或不存在:", item_name, " -> ", image_path)
# 如果没有找到道具图片,尝试使用默认道具图片
if not texture:
var default_item_path = "res://assets/道具图片/默认道具.webp"
if ResourceLoader.exists(default_item_path):
texture = load(default_item_path)
if texture:
print("使用默认道具图片:", item_name)
# 设置图片
if texture:
# CropImage是Sprite2D直接设置texture属性
item_image.texture = texture
item_image.visible = true
print("道具背包更新道具图片:", item_name)
else:
# 如果没有图片,隐藏图片节点
item_image.visible = false
print("道具背包无法获取道具图片:", item_name)
#=========================面板通用处理=========================
# 关闭道具背包面板
func _on_quit_button_pressed() -> void:
# 打开面板后暂时禁用相机功能
GlobalVariables.isZoomDisabled = false
self.hide()
#手动刷新道具背包面板
func _on_refresh_button_pressed() -> void:
# 刷新道具背包UI
update_item_bag_ui()
Toast.show("道具背包已刷新", Color.GREEN, 2.0, 1.0)
#=========================面板通用处理=========================
# 获取当前选择的道具名称
func get_selected_item_name() -> String:
return selected_item_name
# 检查是否有道具被选择
func is_item_currently_selected() -> bool:
return is_item_selected

1
GUI/ItemBagPanel.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://b701r833vse3u

227
GUI/ItemStorePanel.gd Normal file
View File

@@ -0,0 +1,227 @@
extends Panel
# 这是道具商店面板,用来展示各种道具
# 道具商店格子容器
@onready var store_grid: GridContainer = $ScrollContainer/Store_Grid
@onready var quit_button : Button = $QuitButton
# 预添加常用的面板
@onready var main_game = get_node("/root/main")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 道具配置数据
var item_config : Dictionary = {}
# 准备函数
func _ready():
# 连接关闭按钮信号
quit_button.pressed.connect(self._on_quit_button_pressed)
# 隐藏面板(初始默认隐藏)
self.hide()
# 初始化道具商店
func init_item_store():
# 加载道具配置数据
_load_item_config()
# 清空道具商店格子
for child in store_grid.get_children():
child.queue_free()
# 显示商店中的道具
update_item_store_ui()
# 更新道具商店UI
func update_item_store_ui():
# 清空道具商店格子
for child in store_grid.get_children():
child.queue_free()
print("更新道具商店UI道具种类", item_config.size())
# 为每个道具配置创建按钮
for item_name in item_config.keys():
var item_info = item_config[item_name]
var item_cost = item_info.get("花费", 0)
var item_desc = item_info.get("描述", "暂无描述")
# 创建道具按钮
var button = _create_item_button(item_name, item_cost, item_desc)
# 更新按钮文本显示价格
button.text = str(item_name + "\n价格:" + str(item_cost) + "")
# 连接购买点击事件
button.pressed.connect(func(): _on_store_item_selected(item_name, item_cost, item_desc))
store_grid.add_child(button)
# 创建道具按钮
func _create_item_button(item_name: String, item_cost: int, item_desc: String) -> Button:
# 使用橙色按钮作为道具商店按钮的样式
var button = main_game.item_button.duplicate()
# 确保按钮可见并可点击
button.visible = true
button.disabled = false
button.focus_mode = Control.FOCUS_ALL
# 设置按钮文本
button.text = item_name
# 添加工具提示
button.tooltip_text = str(
"道具: " + item_name + "\n" +
"价格: " + str(item_cost) + "\n" +
"描述: " + item_desc + "\n" +
"点击购买道具"
)
# 如果按钮有标题标签,设置标题
if button.has_node("Title"):
button.get_node("Title").text = "商店"
button.get_node("Title").modulate = Color.GOLD # 商店标题使用金色
# 更新按钮的道具图片
_update_button_item_image(button, item_name)
return button
# 加载道具配置数据
func _load_item_config():
# 从item_config.json加载道具配置数据
var file = FileAccess.open("res://Server/config/item_config.json", FileAccess.READ)
if not file:
print("无法读取道具配置文件!")
item_config = {}
return
var json_text = file.get_as_text()
file.close()
var json = JSON.new()
var parse_result = json.parse(json_text)
if parse_result != OK:
print("道具配置JSON解析错误", json.get_error_message())
item_config = {}
return
item_config = json.get_data()
print("成功加载道具配置,道具种类:", item_config.size())
# 商店道具点击处理 - 购买道具
func _on_store_item_selected(item_name: String, item_cost: int, item_desc: String):
# 检查玩家金钱是否足够
if main_game.money < item_cost:
Toast.show("金钱不足!需要 " + str(item_cost) + " 元,当前只有 " + str(main_game.money) + "", Color.RED, 3.0, 1.0)
return
# 显示购买确认对话框
_show_buy_confirmation_dialog(item_name, item_cost, item_desc)
# 显示购买确认对话框
func _show_buy_confirmation_dialog(item_name: String, item_cost: int, item_desc: String):
# 创建确认对话框
var confirm_dialog = AcceptDialog.new()
confirm_dialog.dialog_text = str(
"确认购买道具?\n\n" +
"道具名称: " + item_name + "\n" +
"购买价格: " + str(item_cost) + "\n" +
"道具描述: " + item_desc + "\n\n" +
"当前金钱: " + str(main_game.money) + "\n" +
"购买后余额: " + str(main_game.money - item_cost) + ""
)
confirm_dialog.title = "购买道具确认"
confirm_dialog.ok_button_text = "确认购买"
confirm_dialog.add_cancel_button("取消")
# 添加到场景
add_child(confirm_dialog)
# 连接信号
confirm_dialog.confirmed.connect(_on_confirm_buy_item.bind(item_name, item_cost, confirm_dialog))
confirm_dialog.canceled.connect(_on_cancel_buy_item.bind(confirm_dialog))
# 显示对话框
confirm_dialog.popup_centered()
# 确认购买道具
func _on_confirm_buy_item(item_name: String, item_cost: int, dialog: AcceptDialog):
if network_manager and network_manager.has_method("sendBuyItem"):
if network_manager.sendBuyItem(item_name, item_cost):
Toast.show("正在购买 " + item_name + "...", Color.YELLOW, 2.0, 1.0)
else:
Toast.show("发送购买请求失败", Color.RED, 2.0, 1.0)
else:
Toast.show("网络管理器不可用", Color.RED, 2.0, 1.0)
# 清理对话框
if dialog:
dialog.queue_free()
# 取消购买道具
func _on_cancel_buy_item(dialog: AcceptDialog):
if dialog:
dialog.queue_free()
# 更新按钮的道具图片
func _update_button_item_image(button: Button, item_name: String):
# 检查按钮是否有CropImage节点
var item_image = button.get_node_or_null("CropImage")
if not item_image:
print("道具商店按钮没有找到CropImage节点", button.name)
return
# 从配置文件获取道具图片路径
var texture = null
if item_config.has(item_name):
var item_info = item_config[item_name]
var image_path = item_info.get("道具图片", "")
if image_path != "" and ResourceLoader.exists(image_path):
# 尝试加载道具图片
texture = load(image_path)
if texture:
print("成功加载道具图片:", item_name, " -> ", image_path)
else:
print("加载道具图片失败:", item_name, " -> ", image_path)
else:
print("道具图片路径无效或不存在:", item_name, " -> ", image_path)
# 如果没有找到道具图片,尝试使用默认道具图片
if not texture:
var default_item_path = "res://assets/道具图片/默认道具.webp"
if ResourceLoader.exists(default_item_path):
texture = load(default_item_path)
if texture:
print("使用默认道具图片:", item_name)
# 设置图片
if texture:
# CropImage是Sprite2D直接设置texture属性
item_image.texture = texture
item_image.visible = true
print("道具商店更新道具图片:", item_name)
else:
# 如果没有图片,隐藏图片节点
item_image.visible = false
print("道具商店无法获取道具图片:", item_name)
#=========================面板通用处理=========================
#手动刷新道具商店面板
func _on_refresh_button_pressed() -> void:
# 重新初始化道具商店
init_item_store()
Toast.show("道具商店已刷新", Color.GREEN, 2.0, 1.0)
# 关闭道具商店面板
func _on_quit_button_pressed() -> void:
# 打开面板后暂时禁用相机功能
GlobalVariables.isZoomDisabled = false
self.hide()
pass
#=========================面板通用处理=========================

View File

@@ -0,0 +1 @@
uid://bruqwi63myl1m

598
GUI/LandPanel.gd Normal file
View File

@@ -0,0 +1,598 @@
extends Panel
#获取玩家要操作的地块序号
var selected_lot_index = 0
#预添加常用的面板
@onready var main_game = get_node("/root/main")
@onready var land_panel = get_node("/root/main/UI/LandPanel")
@onready var crop_store_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var player_ranking_panel = get_node("/root/main/UI/PlayerRankingPanel")
@onready var player_bag_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
@onready var quit_button :Button = $Quit_Button
@onready var dig_button: Button = $Grid/Dig_Button #开垦
@onready var water_button: Button = $Grid/Water_Button #浇水
@onready var fertilize_button: Button = $Grid/Fertilize_Button #施肥
@onready var upgrade_button: Button = $Grid/Upgrade_Button #升级
@onready var plant_button: Button = $Grid/Plant_Button #种植
@onready var remove_button: Button = $Grid/Remove_Button #铲除
@onready var harvest_button: Button = $Grid/Harvest_Button #收获
@onready var kill_insect_button: Button = $Grid/KillInsect_Button #杀虫
#下面这些来实时获取被点击地块的作物情况
@onready var crop_texture_rect: TextureRect = $TextureRect #这个显示作物当前图片
@onready var progress_bar: ProgressBar = $VBox/ProgressBar #显示作物当前生长进度
@onready var cost: Label = $VBox/HBox1/cost #显示花费
@onready var earn: Label = $VBox/HBox1/earn #显示收益
@onready var growthtime: Label = $VBox/HBox1/growthtime #生长时间
@onready var experience: Label = $VBox/HBox1/experience #收获经验
@onready var canbuy: Label = $VBox/HBox2/canbuy #能否购买
@onready var quality: Label = $VBox/HBox2/quality #作物品质
@onready var weatherability: Label = $VBox/HBox2/weatherability #耐候性
@onready var level: Label = $VBox/HBox2/level #种植等级
@onready var description: Label = $VBox/HBox3/description #描述
#没有作物直接一键隐藏这个
@onready var v_box: VBoxContainer = $VBox
func _ready():
self.hide()
quit_button.pressed.connect(self._on_quit_button_pressed)
dig_button.pressed.connect(self._on_dig_button_pressed)
water_button.pressed.connect(self._on_water_button_pressed)
fertilize_button.pressed.connect(self._on_fertilize_button_pressed)
upgrade_button.pressed.connect(self._on_upgrade_button_pressed)
plant_button.pressed.connect(self._on_plant_button_pressed)
remove_button.pressed.connect(self._on_remove_button_pressed)
harvest_button.pressed.connect(self._on_harvest_button_pressed)
# 显示浇水、施肥、升级按钮
water_button.visible = true
fertilize_button.visible = true
upgrade_button.visible = true
_update_button_texts()
# 显示面板时更新按钮状态
func show_panel():
self.show()
_update_button_texts()
_update_button_availability()
_update_crop_info()
# 更新按钮可用性
func _update_button_availability():
if main_game.is_visiting_mode:
# 访问模式下禁用一些按钮
dig_button.hide()
remove_button.hide()
upgrade_button.hide()
plant_button.hide()
# 启用允许的按钮
water_button.show()
fertilize_button.show()
harvest_button.show()
else:
# 自己农场模式下启用所有按钮
dig_button.show()
remove_button.show()
upgrade_button.show()
plant_button.show()
water_button.show()
fertilize_button.show()
harvest_button.show()
# 更新按钮文本
func _update_button_texts():
# 根据是否访问模式显示不同的按钮文本
if main_game.is_visiting_mode:
water_button.text = "帮助浇水"+"\n¥50"
fertilize_button.text = "帮助施肥"+"\n¥150"
harvest_button.text = "偷菜"
else:
dig_button.text = "开垦"+"\n"+str(main_game.dig_money)
remove_button.text = "铲除"+"\n¥500"
water_button.text = "浇水"+"\n¥50"
fertilize_button.text = "施肥"+"\n¥150"
# 升级按钮动态显示
_update_upgrade_button_text()
harvest_button.text = "收获"
# 更新升级按钮文本
func _update_upgrade_button_text():
if not main_game or not main_game.farm_lots:
upgrade_button.text = "升级\n¥1000"
return
if selected_lot_index >= 0 and selected_lot_index < main_game.farm_lots.size():
var lot = main_game.farm_lots[selected_lot_index]
var current_level = int(lot.get("土地等级", 0)) # 确保是整数
var upgrade_config = {
0: {"cost": 1000, "name": "黄土地"},
1: {"cost": 2000, "name": "红土地"},
2: {"cost": 4000, "name": "紫土地"},
3: {"cost": 8000, "name": "黑土地"}
}
if current_level >= 4:
upgrade_button.text = "已满级"
elif upgrade_config.has(current_level):
var config = upgrade_config[current_level]
upgrade_button.text = "升级到\n" + config["name"] + "\n" + str(config["cost"])
else:
upgrade_button.text = "等级异常\n" + str(current_level)
else:
upgrade_button.text = "选择地块"
#=====================================土地面板功能处理=========================================
#开垦
func _on_dig_button_pressed():
# 检查是否处于访问模式
if main_game.is_visiting_mode:
Toast.show("访问模式下无法开垦土地", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查玩家金钱是否足够
var dig_cost = main_game.dig_money
if main_game.money < dig_cost:
Toast.show("金钱不足,开垦土地需要 " + str(dig_cost) + " 金钱", Color.RED, 2.0, 1.0)
self.hide()
return
# 检查地块是否已经开垦
var lot = main_game.farm_lots[selected_lot_index]
if lot.get("is_diged", false):
Toast.show("此地块已经开垦过了", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 发送开垦土地请求到服务器
if network_manager and network_manager.is_connected_to_server():
if network_manager.sendDigGround(selected_lot_index):
self.hide()
else:
Toast.show("发送开垦请求失败", Color.RED, 2.0, 1.0)
self.hide()
else:
Toast.show("网络未连接,无法开垦土地", Color.RED, 2.0, 1.0)
self.hide()
#浇水
func _on_water_button_pressed():
# 检查玩家金钱是否足够(无论是否访问模式都检查自己的钱)
var water_cost = 50
var my_money = main_game.money
# 如果是访问模式,需要检查自己的原始金钱数据
if main_game.is_visiting_mode:
my_money = main_game.original_player_data.get("money", 0)
if my_money < water_cost:
var action_text = "帮助浇水" if main_game.is_visiting_mode else "浇水"
Toast.show("金钱不足," + action_text + "需要 " + str(water_cost) + " 金钱", Color.RED, 2.0, 1.0)
self.hide()
return
# 检查地块状态
var lot = main_game.farm_lots[selected_lot_index]
if not lot.get("is_planted", false) or lot.get("crop_type", "") == "":
Toast.show("此地块没有种植作物", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查作物是否已死亡
if lot.get("is_dead", false):
Toast.show("死亡的作物无法浇水", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查是否已经成熟
if lot.get("grow_time", 0) >= lot.get("max_grow_time", 1):
Toast.show("作物已经成熟,无需浇水", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查是否已经浇过水
var current_time = Time.get_unix_time_from_system()
var last_water_time = lot.get("浇水时间", 0)
var water_cooldown = 3600 # 1小时冷却时间
if current_time - last_water_time < water_cooldown:
var remaining_time = water_cooldown - (current_time - last_water_time)
var remaining_minutes = int(remaining_time / 60)
var remaining_seconds = int(remaining_time) % 60
Toast.show("浇水冷却中,还需等待 " + str(remaining_minutes) + " 分钟 " + str(remaining_seconds) + "", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 发送浇水请求到服务器
var target_username = ""
if main_game.is_visiting_mode:
target_username = main_game.visited_player_data.get("user_name", "")
if network_manager and network_manager.is_connected_to_server():
if network_manager.sendWaterCrop(selected_lot_index, target_username):
self.hide()
else:
Toast.show("发送浇水请求失败", Color.RED, 2.0, 1.0)
self.hide()
else:
var action_text = "帮助浇水" if main_game.is_visiting_mode else "浇水"
Toast.show("网络未连接,无法" + action_text, Color.RED, 2.0, 1.0)
self.hide()
#施肥
func _on_fertilize_button_pressed():
# 检查玩家金钱是否足够(无论是否访问模式都检查自己的钱)
var fertilize_cost = 150
var my_money = main_game.money
# 如果是访问模式,需要检查自己的原始金钱数据
if main_game.is_visiting_mode:
my_money = main_game.original_player_data.get("money", 0)
if my_money < fertilize_cost:
var action_text = "帮助施肥" if main_game.is_visiting_mode else "施肥"
Toast.show("金钱不足," + action_text + "需要 " + str(fertilize_cost) + " 金钱", Color.RED, 2.0, 1.0)
self.hide()
return
# 检查地块状态
var lot = main_game.farm_lots[selected_lot_index]
if not lot.get("is_planted", false) or lot.get("crop_type", "") == "":
Toast.show("此地块没有种植作物", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查作物是否已死亡
if lot.get("is_dead", false):
Toast.show("死亡的作物无法施肥", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查是否已经成熟
if lot.get("grow_time", 0) >= lot.get("max_grow_time", 1):
Toast.show("作物已经成熟,无需施肥", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查是否已经施过肥
if lot.get("已施肥", false):
Toast.show("此作物已经施过肥了", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 发送施肥请求到服务器
var target_username = ""
if main_game.is_visiting_mode:
target_username = main_game.visited_player_data.get("user_name", "")
if network_manager and network_manager.is_connected_to_server():
if network_manager.sendFertilizeCrop(selected_lot_index, target_username):
self.hide()
else:
Toast.show("发送施肥请求失败", Color.RED, 2.0, 1.0)
self.hide()
else:
var action_text = "帮助施肥" if main_game.is_visiting_mode else "施肥"
Toast.show("网络未连接,无法" + action_text, Color.RED, 2.0, 1.0)
self.hide()
#升级
func _on_upgrade_button_pressed():
# 检查是否处于访问模式
if main_game.is_visiting_mode:
Toast.show("访问模式下无法升级", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查地块索引是否有效
if selected_lot_index < 0 or selected_lot_index >= main_game.farm_lots.size():
Toast.show("无效的地块选择", Color.RED, 2.0, 1.0)
self.hide()
return
# 获取地块数据
var lot = main_game.farm_lots[selected_lot_index]
# 检查地块是否已开垦
if not lot.get("is_diged", false):
Toast.show("此地块尚未开垦", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 获取当前土地等级和升级配置
var current_level = int(lot.get("土地等级", 0)) # 确保是整数
print("当前选择地块索引: ", selected_lot_index)
print("当前土地等级: ", current_level, " (类型: ", typeof(current_level), ")")
var upgrade_config = {
0: {"cost": 1000, "name": "黄土地", "speed": "2倍"},
1: {"cost": 2000, "name": "红土地", "speed": "4倍"},
2: {"cost": 4000, "name": "紫土地", "speed": "6倍"},
3: {"cost": 8000, "name": "黑土地", "speed": "10倍"}
}
# 检查是否已达到最高等级
if current_level >= 4:
Toast.show("此土地已达到最高等级(黑土地)", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查土地等级是否有效
if not upgrade_config.has(current_level):
Toast.show("土地等级数据异常,当前等级: " + str(current_level), Color.RED, 2.0, 1.0)
print("土地等级异常,当前等级: ", current_level, ",可用等级: ", upgrade_config.keys())
self.hide()
return
var config = upgrade_config[current_level]
var upgrade_cost = config["cost"]
var next_name = config["name"]
var speed_info = config["speed"]
# 检查玩家金钱是否足够
if main_game.money < upgrade_cost:
Toast.show("金钱不足,升级到" + next_name + "需要 " + str(upgrade_cost) + " 金钱", Color.RED, 2.0, 1.0)
self.hide()
return
# 发送升级请求到服务器
if network_manager and network_manager.is_connected_to_server():
print("发送升级请求,地块索引: ", selected_lot_index, ",当前等级: ", current_level)
if network_manager.sendUpgradeLand(selected_lot_index):
self.hide()
else:
Toast.show("发送升级请求失败", Color.RED, 2.0, 1.0)
self.hide()
else:
Toast.show("网络未连接,无法升级土地", Color.RED, 2.0, 1.0)
self.hide()
#种植
func _on_plant_button_pressed():
# 检查是否处于访问模式
if main_game.is_visiting_mode:
Toast.show("访问模式下无法种植", Color.ORANGE, 2.0, 1.0)
self.hide()
return
player_bag_panel.show()
self.hide()
pass
#铲除
func _on_remove_button_pressed():
# 检查是否处于访问模式
if main_game.is_visiting_mode:
Toast.show("访问模式下无法铲除作物", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查玩家金钱是否足够
var removal_cost = 500
if main_game.money < removal_cost:
Toast.show("金钱不足,铲除作物需要 " + str(removal_cost) + " 金钱", Color.RED, 2.0, 1.0)
self.hide()
return
# 检查地块是否有作物
var lot = main_game.farm_lots[selected_lot_index]
if not lot.get("is_planted", false) or lot.get("crop_type", "") == "":
Toast.show("此地块没有种植作物", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 发送铲除作物请求到服务器
if network_manager and network_manager.is_connected_to_server():
if network_manager.sendRemoveCrop(selected_lot_index):
self.hide()
else:
Toast.show("发送铲除请求失败", Color.RED, 2.0, 1.0)
self.hide()
else:
Toast.show("网络未连接,无法铲除作物", Color.RED, 2.0, 1.0)
self.hide()
pass
#收获
func _on_harvest_button_pressed():
# 检查地块状态
var lot = main_game.farm_lots[selected_lot_index]
if not lot.get("is_planted", false) or lot.get("crop_type", "") == "":
Toast.show("此地块没有种植作物", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 检查作物是否成熟
if lot.get("grow_time", 0) < lot.get("max_grow_time", 1) and not lot.get("is_dead", false):
Toast.show("作物尚未成熟", Color.ORANGE, 2.0, 1.0)
self.hide()
return
# 发送收获请求到服务器
var target_username = ""
if main_game.is_visiting_mode:
target_username = main_game.visited_player_data.get("user_name", "")
if network_manager and network_manager.is_connected_to_server():
if network_manager.sendHarvestCrop(selected_lot_index, target_username):
self.hide()
else:
Toast.show("发送收获请求失败", Color.RED, 2.0, 1.0)
self.hide()
else:
var action_text = "偷菜" if main_game.is_visiting_mode else "收获"
Toast.show("网络未连接,无法" + action_text, Color.RED, 2.0, 1.0)
self.hide()
pass
#=====================================土地面板功能处理=========================================
#关闭土地面板按钮
func _on_quit_button_pressed():
self.hide()
pass
# 更新作物信息显示
func _update_crop_info():
print("调试_update_crop_info 被调用selected_lot_index = ", selected_lot_index)
if not main_game or not main_game.farm_lots:
print("调试main_game 或 farm_lots 不存在")
v_box.hide()
crop_texture_rect.hide()
return
if selected_lot_index < 0 or selected_lot_index >= main_game.farm_lots.size():
print("调试selected_lot_index 无效: ", selected_lot_index, " / ", main_game.farm_lots.size())
v_box.hide()
crop_texture_rect.hide()
return
var lot = main_game.farm_lots[selected_lot_index]
print("调试:地块数据: ", lot)
# 检查地块是否有作物
if not lot.get("is_planted", false) or lot.get("crop_type", "") == "":
print("调试:地块没有作物")
v_box.hide()
crop_texture_rect.hide()
# 清除所有显示内容
crop_texture_rect.texture = null
progress_bar.value = 0
cost.text = ""
earn.text = ""
growthtime.text = ""
experience.text = ""
canbuy.text = ""
quality.text = ""
weatherability.text = ""
level.text = ""
description.text = ""
return
# 获取作物类型
var crop_type = lot.get("crop_type", "")
print("调试:作物类型: ", crop_type)
# 从网络管理器获取作物数据
var crop_data = null
if network_manager and network_manager.has_method("get_crop_data"):
crop_data = network_manager.get_crop_data()
# 如果没有作物数据,尝试从主游戏获取
if not crop_data and main_game and main_game.has_method("get_crop_data"):
crop_data = main_game.get_crop_data()
# 如果仍然没有作物数据,隐藏信息面板
if not crop_data or not crop_data.has(crop_type):
print("调试:没有作物数据或作物类型不存在: ", crop_type)
v_box.hide()
crop_texture_rect.hide()
return
print("调试:找到作物数据,开始显示作物信息")
# 显示作物信息面板
v_box.show()
crop_texture_rect.show()
# 获取作物信息
var crop_info = crop_data[crop_type]
print("调试:作物信息: ", crop_info)
# 更新作物图片
var crop_texture_path = "res://assets/作物/" + crop_type + "/0.webp"
if ResourceLoader.exists(crop_texture_path):
var texture = load(crop_texture_path)
crop_texture_rect.texture = texture
else:
# 如果没有序列帧,尝试加载单个图片
crop_texture_path = "res://assets/作物/" + crop_type + ".webp"
if ResourceLoader.exists(crop_texture_path):
var texture = load(crop_texture_path)
crop_texture_rect.texture = texture
else:
# 加载默认图片
crop_texture_path = "res://assets/作物/默认/0.webp"
if ResourceLoader.exists(crop_texture_path):
var texture = load(crop_texture_path)
crop_texture_rect.texture = texture
else:
crop_texture_rect.texture = null
# 更新进度条
var grow_time = lot.get("grow_time", 0)
var max_grow_time = lot.get("max_grow_time", 1)
var progress = float(grow_time) / float(max_grow_time) * 100.0
progress_bar.value = min(progress, 100.0)
# 更新作物信息标签
cost.text = "花费: ¥" + str(crop_info.get("花费", 0))
earn.text = "收益: ¥" + str(crop_info.get("收益", 0))
# 格式化生长时间
var growth_seconds = crop_info.get("生长时间", 0)
var growth_time_text = _format_time_seconds(growth_seconds)
growthtime.text = "生长时间: " + growth_time_text
experience.text = "经验: " + str(crop_info.get("经验", 0))
canbuy.text = "可购买: " + ("" if crop_info.get("能否购买", false) else "")
quality.text = "品质: " + str(crop_info.get("品质", "普通"))
weatherability.text = "耐候性: " + str(crop_info.get("耐候性", 0))
level.text = "等级要求: " + str(crop_info.get("等级", 1))
# 检查是否为杂草,显示特殊描述并控制收获按钮
var is_weed = crop_info.get("是否杂草", false)
if is_weed:
description.text = "描述: " + str(crop_info.get("描述", "无描述")) + " [杂草不能收获,只能铲除]"
# 隐藏收获按钮(杂草不能收获)
harvest_button.hide()
else:
description.text = "描述: " + str(crop_info.get("描述", "无描述"))
# 显示收获按钮并设置正常文本
harvest_button.show()
if main_game.is_visiting_mode:
harvest_button.text = "偷菜"
else:
harvest_button.text = "收获"
# 格式化时间(秒转换为时分秒)
func _format_time_seconds(seconds: int) -> String:
var hours = seconds / 3600
var minutes = (seconds % 3600) / 60
var secs = seconds % 60
if hours > 0:
return str(hours) + "" + str(minutes) + "" + str(secs) + ""
elif minutes > 0:
return str(minutes) + "" + str(secs) + ""
else:
return str(secs) + ""

1
GUI/LandPanel.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://bljtkxil64h14

256
GUI/LandPanel.tscn Normal file
View File

@@ -0,0 +1,256 @@
[gd_scene load_steps=3 format=3 uid="uid://dckc8nrn7p425"]
[ext_resource type="Script" uid="uid://bljtkxil64h14" path="res://GUI/LandPanel.gd" id="1_nmy5p"]
[ext_resource type="Texture2D" uid="uid://2sdfbvf1isif" path="res://icon.svg" id="2_07q41"]
[node name="LandPanel" type="Panel"]
offset_left = 385.0
offset_top = 69.0
offset_right = 901.0
offset_bottom = 540.0
script = ExtResource("1_nmy5p")
[node name="Quit_Button" type="Button" parent="."]
layout_mode = 0
offset_left = 475.0
offset_right = 515.0
offset_bottom = 43.0
theme_override_font_sizes/font_size = 25
text = "X"
[node name="Title" type="Label" parent="."]
self_modulate = Color(0, 0.87451, 1, 1)
layout_mode = 2
offset_right = 516.0
offset_bottom = 42.0
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 4
theme_override_constants/shadow_offset_y = 4
theme_override_constants/outline_size = 15
theme_override_constants/shadow_outline_size = 15
theme_override_font_sizes/font_size = 30
text = "土地面板"
horizontal_alignment = 1
vertical_alignment = 1
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 2
offset_left = 224.0
offset_top = 249.0
offset_right = 352.0
offset_bottom = 377.0
scale = Vector2(0.5, 0.5)
size_flags_horizontal = 4
texture = ExtResource("2_07q41")
expand_mode = 1
[node name="VBox" type="VBoxContainer" parent="."]
layout_mode = 0
offset_top = 313.0
offset_right = 1287.0
offset_bottom = 700.0
scale = Vector2(0.4, 0.4)
[node name="ProgressBar" type="ProgressBar" parent="VBox"]
modulate = Color(0, 1, 0, 1)
layout_mode = 2
theme_override_font_sizes/font_size = 30
[node name="HBox1" type="HBoxContainer" parent="VBox"]
layout_mode = 2
size_flags_vertical = 3
[node name="cost" type="Label" parent="VBox/HBox1"]
modulate = Color(1, 1, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "花费:999"
[node name="earn" type="Label" parent="VBox/HBox1"]
modulate = Color(1, 1, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "收益:999"
[node name="growthtime" type="Label" parent="VBox/HBox1"]
modulate = Color(1, 0.635294, 1, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "生长时间:999"
[node name="experience" type="Label" parent="VBox/HBox1"]
modulate = Color(0.164706, 1, 0.341176, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "收获经验:999"
[node name="HBox2" type="HBoxContainer" parent="VBox"]
layout_mode = 2
size_flags_vertical = 3
[node name="canbuy" type="Label" parent="VBox/HBox2"]
modulate = Color(0.466667, 1, 1, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "能否购买:是"
[node name="quality" type="Label" parent="VBox/HBox2"]
modulate = Color(1, 0.607843, 0.239216, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "品质:传奇"
[node name="weatherability" type="Label" parent="VBox/HBox2"]
modulate = Color(0.784314, 0.647059, 0.498039, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "耐候性:999"
[node name="level" type="Label" parent="VBox/HBox2"]
modulate = Color(0.394367, 0.644385, 0.816557, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "种植等级:999"
[node name="HBox3" type="HBoxContainer" parent="VBox"]
layout_mode = 2
size_flags_vertical = 3
[node name="description" type="Label" parent="VBox/HBox3"]
modulate = Color(0.988235, 0.831373, 1, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 40
text = "描述:啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"
[node name="Grid" type="GridContainer" parent="."]
layout_mode = 2
offset_top = 42.0
offset_right = 516.0
offset_bottom = 249.0
columns = 5
[node name="Dig_Button" type="Button" parent="Grid"]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
theme_override_colors/font_disabled_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_colors/font_color = Color(1, 0, 0, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "开垦"
icon_alignment = 1
expand_icon = true
[node name="Plant_Button" type="Button" parent="Grid"]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
theme_override_colors/font_disabled_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
theme_override_colors/font_color = Color(0.760784, 0.533333, 0.160784, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "种植"
icon_alignment = 1
expand_icon = true
[node name="Remove_Button" type="Button" parent="Grid"]
visible = false
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
theme_override_colors/font_disabled_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
theme_override_colors/font_color = Color(0.870588, 0.870588, 0, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "铲除"
icon_alignment = 1
expand_icon = true
[node name="Harvest_Button" type="Button" parent="Grid"]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
theme_override_colors/font_disabled_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
theme_override_colors/font_color = Color(0.188235, 0.839216, 0.243137, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "收获"
icon_alignment = 1
expand_icon = true
[node name="Water_Button" type="Button" parent="Grid"]
visible = false
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
theme_override_colors/font_disabled_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_colors/font_color = Color(0, 0.87451, 0.87451, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "浇水"
icon_alignment = 1
expand_icon = true
[node name="Fertilize_Button" type="Button" parent="Grid"]
visible = false
custom_minimum_size = Vector2(80, 80)
layout_mode = 2
theme_override_colors/font_color = Color(0.509804, 0.301961, 0.85098, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "施肥"
icon_alignment = 1
expand_icon = true
[node name="Upgrade_Button" type="Button" parent="Grid"]
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
theme_override_colors/font_color = Color(0.0705882, 0.411765, 0.87451, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "升级"
icon_alignment = 1
expand_icon = true
[node name="KillInsect_Button" type="Button" parent="Grid"]
visible = false
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
theme_override_colors/font_color = Color(0.988235, 0.929412, 0.760784, 1)
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "杀虫"
icon_alignment = 1
expand_icon = true
[node name="Grid2" type="GridContainer" parent="."]
layout_mode = 0
offset_top = 345.0
offset_right = 515.0
offset_bottom = 468.0
columns = 3

530
GUI/LoginPanel.gd Normal file
View File

@@ -0,0 +1,530 @@
#玩家登录注册面板
extends PanelContainer
#玩家登录账号用QQ号代替
@onready var username_input : LineEdit = $VBox/UserName/username_input
#用户登录密码
@onready var password_input : LineEdit = $VBox/Password1/password_input
#登录按钮
@onready var login_button : Button = $VBox/LoginRegister/login_button
#下面是注册相关的
#注册按钮
@onready var register_button : Button = $VBox/LoginRegister/register_button
#注册账号时二次确认密码
@onready var password_input_2 : LineEdit = $VBox/Password2/password_input2
#农场名称
@onready var farmname_input : LineEdit = $VBox/FarmName/farmname_input
#玩家昵称
@onready var playername_input :LineEdit = $VBox/PlayerName/playername_input
#邮箱验证码
@onready var verificationcode_input :LineEdit = $VBox/VerificationCode/verificationcode_input
#发送验证码按钮
@onready var send_button :Button = $VBox/VerificationCode/SendButton
#状态提示标签
@onready var status_label : Label = $VBox/status_label
#隐藏注册相关
@onready var password_2: HBoxContainer = $VBox/Password2
@onready var verification_code: HBoxContainer = $VBox/VerificationCode
@onready var player_name: HBoxContainer = $VBox/PlayerName
@onready var farm_name: HBoxContainer = $VBox/FarmName
# 记住密码选项
var remember_password : bool = true # 默认记住密码
# 引用主场景和全局函数
@onready var main_game = get_node("/root/main")
@onready var land_panel = get_node("/root/main/UI/LandPanel")
@onready var crop_store_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var player_ranking_panel = get_node("/root/main/UI/PlayerRankingPanel")
@onready var player_bag_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var tcp_network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 准备函数
func _ready():
# 连接按钮信号
login_button.pressed.connect(self._on_login_button_pressed)
register_button.pressed.connect(self._on_register_button_pressed)
send_button.pressed.connect(self._on_send_button_pressed)
# 加载保存的登录信息
_load_login_info()
# 显示客户端版本号
_display_version_info()
# 处理登录按钮点击
func _on_login_button_pressed():
var user_name = username_input.text.strip_edges() # 修剪前后的空格
var user_password = password_input.text.strip_edges()
var farmname = farmname_input.text.strip_edges()
if user_name == "" or user_password == "":
status_label.text = "用户名或密码不能为空!"
status_label.modulate = Color.RED
return
# 检查网络连接状态
if !tcp_network_manager.client.is_client_connected():
status_label.text = "未连接到服务器,正在尝试连接..."
status_label.modulate = Color.YELLOW
# 尝试自动连接到服务器
tcp_network_manager.connect_to_current_server()
await get_tree().create_timer(2.0).timeout
# 禁用按钮,防止重复点击
login_button.disabled = true
status_label.text = "正在登录,请稍候..."
status_label.modulate = Color.YELLOW
# 如果启用了记住密码,保存登录信息
if remember_password:
_save_login_info(user_name, user_password)
tcp_network_manager.sendLoginInfo(user_name, user_password)
# 更新主游戏数据
main_game.user_name = user_name
main_game.user_password = user_password
# 5秒后重新启用按钮如果没有收到响应
await get_tree().create_timer(5.0).timeout
if login_button.disabled:
login_button.disabled = false
status_label.text = "登录超时,请重试!"
status_label.modulate = Color.RED
# 处理验证码发送按钮点击
func _on_send_button_pressed():
var user_name = username_input.text.strip_edges()
if user_name == "":
status_label.text = "请输入QQ号以接收验证码"
status_label.modulate = Color.RED
return
if !is_valid_qq_number(user_name):
status_label.text = "请输入正确的QQ号码5-12位数字"
status_label.modulate = Color.RED
return
# 检查网络连接状态
if !tcp_network_manager.client.is_client_connected():
status_label.text = "未连接到服务器,正在尝试连接..."
status_label.modulate = Color.YELLOW
# 尝试自动连接到服务器
tcp_network_manager.connect_to_current_server()
await get_tree().create_timer(2.0).timeout
# 再次检查连接状态
if !tcp_network_manager.client.is_client_connected():
status_label.text = "连接服务器失败,正在尝试其他服务器..."
status_label.modulate = Color.YELLOW
# 等待自动服务器切换完成
await get_tree().create_timer(3.0).timeout
# 禁用按钮,防止重复点击
send_button.disabled = true
status_label.text = "正在发送验证码,请稍候..."
status_label.modulate = Color.YELLOW
# 发送验证码请求
tcp_network_manager.sendVerificationCodeRequest(user_name)
# 60秒后重新启用按钮或收到响应后提前启用
var timer = 60
while timer > 0 and send_button.disabled:
send_button.text = "重新发送(%d)" % timer
await get_tree().create_timer(1.0).timeout
timer -= 1
if send_button.disabled:
send_button.disabled = false
send_button.text = "发送验证码"
if status_label.text == "正在发送验证码,请稍候...":
status_label.text = "验证码发送超时,请重试!"
status_label.modulate = Color.RED
# 处理注册按钮点击
func _on_register_button_pressed():
password_2.show()
verification_code.show()
player_name.show()
farm_name.show()
var user_name = username_input.text.strip_edges()
var user_password = password_input.text.strip_edges()
var user_password_2 = password_input_2.text.strip_edges()
var farmname = farmname_input.text.strip_edges()
var player_name = playername_input.text.strip_edges()
var verification_code = verificationcode_input.text.strip_edges()
# 检查密码格式(只允许数字和字母)
if not is_valid_password(user_password):
status_label.text = "密码只能包含数字和字母!"
status_label.modulate = Color.RED
return
if user_name == "" or user_password == "":
status_label.text = "用户名或密码不能为空!"
status_label.modulate = Color.RED
return
if farmname == "":
status_label.text = "农场名称不能为空!"
status_label.modulate = Color.RED
return
if user_password != user_password_2:
status_label.text = "两次输入的密码不一致!"
status_label.modulate = Color.RED
return
if !is_valid_qq_number(user_name):
status_label.text = "请输入正确的QQ号码5-12位数字"
status_label.modulate = Color.RED
return
if verification_code == "":
status_label.text = "请输入验证码!"
status_label.modulate = Color.RED
return
# 检查网络连接状态
if !tcp_network_manager.client.is_client_connected():
status_label.text = "未连接到服务器,正在尝试连接..."
status_label.modulate = Color.YELLOW
# 尝试自动连接到服务器
tcp_network_manager.connect_to_current_server()
await get_tree().create_timer(2.0).timeout
# 再次检查连接状态
if !tcp_network_manager.client.is_client_connected():
status_label.text = "连接服务器失败,正在尝试其他服务器..."
status_label.modulate = Color.YELLOW
# 等待自动服务器切换完成
await get_tree().create_timer(3.0).timeout
# 禁用按钮,防止重复点击
register_button.disabled = true
status_label.text = "正在注册,请稍候..."
status_label.modulate = Color.YELLOW
# 发送注册请求
tcp_network_manager.sendRegisterInfo(user_name, user_password, farmname, player_name, verification_code)
# 更新主游戏数据
#main_game.user_name = user_name
#main_game.user_password = user_password
#main_game.farmname = farmname
# 5秒后重新启用按钮如果没有收到响应
await get_tree().create_timer(5.0).timeout
if register_button.disabled:
register_button.disabled = false
status_label.text = "注册超时,请重试!"
status_label.modulate = Color.RED
# 处理验证码发送响应
func _on_verification_code_response(success: bool, message: String):
if success:
status_label.text = message
status_label.modulate = Color.GREEN
else:
status_label.text = message
status_label.modulate = Color.RED
send_button.disabled = false
send_button.text = "发送验证码"
# 处理验证码验证响应
func _on_verify_code_response(success: bool, message: String):
if success:
status_label.text = message
status_label.modulate = Color.GREEN
else:
status_label.text = message
status_label.modulate = Color.RED
# 验证QQ号是否有效
func is_valid_qq_number(qq_number: String) -> bool:
# QQ号的标准格式是5到12位的数字
var qq_regex = RegEx.new()
var pattern = r"^\d{5,12}$"
var error = qq_regex.compile(pattern)
if error != OK:
status_label.text = "QQ号验证失败部错误"
status_label.modulate = Color.RED
return false
return qq_regex.search(qq_number) != null
# 添加密码验证函数
func is_valid_password(password: String) -> bool:
# 检查密码是否为空
if password.length() == 0:
return false
# 遍历密码中的每个字符
for i in range(password.length()):
var char = password[i]
# 检查字符是否为数字
var is_digit = char >= "0" and char <= "9"
# 检查字符是否为大写字母
var is_upper = char >= "A" and char <= "Z"
# 检查字符是否为小写字母
var is_lower = char >= "a" and char <= "z"
# 如果字符既不是数字也不是字母则返回false
if not (is_digit or is_upper or is_lower):
return false
# 如果所有字符都是字母或数字则返回true
return true
# 处理登录响应
func _on_login_response_received(success: bool, message: String, user_data: Dictionary):
# 启用按钮
login_button.disabled = false
if success:
status_label.text = "登录成功!正在加载游戏..."
status_label.modulate = Color.GREEN
# 保存登录数据到主游戏
main_game.login_data = user_data.duplicate()
# 更新主游戏数据
main_game.experience = user_data.get("experience", 0)
main_game.farm_lots = user_data.get("farm_lots", [])
main_game.level = user_data.get("level", 1)
main_game.money = user_data.get("money", 0)
main_game.stamina = user_data.get("体力值", 20)
main_game.show_farm_name.text = "农场名称:"+user_data.get("farm_name", "")
main_game.show_player_name.text = "玩家昵称:"+user_data.get("player_name", "")
farmname_input.text = user_data.get("farm_name", "")
# 加载玩家背包数据
if user_data.has("player_bag"):
main_game.player_bag = user_data.get("player_bag", [])
else:
main_game.player_bag = []
# 加载作物仓库数据
if user_data.has("作物仓库"):
main_game.crop_warehouse = user_data.get("作物仓库", [])
else:
main_game.crop_warehouse = []
# 加载道具背包数据
if user_data.has("道具背包"):
main_game.item_bag = user_data.get("道具背包", [])
else:
main_game.item_bag = []
main_game.start_game = true
self.hide()
# 确保在更新数据后调用主游戏的 UI 更新函数
main_game._update_ui()
main_game._refresh_farm_lots()
player_bag_panel.update_player_bag_ui()
# 更新作物仓库和道具背包UI
if main_game.crop_warehouse_panel and main_game.crop_warehouse_panel.has_method("update_crop_warehouse_ui"):
main_game.crop_warehouse_panel.update_crop_warehouse_ui()
if main_game.item_bag_panel and main_game.item_bag_panel.has_method("update_item_bag_ui"):
main_game.item_bag_panel.update_item_bag_ui()
# 调用主游戏的登录成功处理函数
main_game.handle_login_success(user_data)
else:
status_label.text = "登录失败:" + message
status_label.modulate = Color.RED
# 如果登录失败且是密码错误,可以选择清除保存的信息
if "密码" in message or "password" in message.to_lower():
print("登录失败可能是密码错误。如需清除保存的登录信息请调用_clear_login_info()")
# 处理注册响应
func _on_register_response_received(success: bool, message: String):
# 启用按钮
register_button.disabled = false
if success:
status_label.text = "注册成功!请登录游戏"
status_label.modulate = Color.GREEN
# 注册成功后,如果启用了记住密码,保存登录信息
if remember_password:
var user_name = username_input.text.strip_edges()
var user_password = password_input.text.strip_edges()
_save_login_info(user_name, user_password)
# 清除注册相关的输入框
password_input_2.text = ""
verificationcode_input.text = ""
else:
status_label.text = "注册失败:" + message
status_label.modulate = Color.RED
# 保存登录信息到JSON文件
func _save_login_info(user_name: String, password: String):
var login_data = {
"user_name": user_name,
"password": password
}
var file = FileAccess.open("user://login.json", FileAccess.WRITE)
if file:
var json_string = JSON.stringify(login_data, "\t")
file.store_string(json_string)
file.close()
print("登录信息已保存")
else:
print("无法保存登录信息")
# 从JSON文件加载登录信息
func _load_login_info():
var file = FileAccess.open("user://login.json", FileAccess.READ)
if file:
var json_text = file.get_as_text()
file.close()
var json = JSON.new()
var parse_result = json.parse(json_text)
if parse_result == OK:
var login_data = json.get_data()
if login_data.has("user_name") and login_data.has("password"):
var saved_username = login_data.get("user_name", "")
var saved_password = login_data.get("password", "")
if saved_username != "" and saved_password != "":
username_input.text = saved_username
password_input.text = saved_password
status_label.text = "已加载保存的登录信息"
status_label.modulate = Color.CYAN
print("登录信息已加载:用户名 =", saved_username)
else:
status_label.text = "欢迎使用萌芽农场"
status_label.modulate = Color.WHITE
print("没有有效的保存登录信息")
else:
print("登录信息格式错误")
else:
print("登录信息JSON解析错误", json.get_error_message())
else:
# 创建默认的登录信息文件
_save_login_info("", "")
status_label.text = "欢迎使用萌芽农场"
status_label.modulate = Color.WHITE
print("没有找到保存的登录信息,已创建默认文件")
# 清除保存的登录信息
func _clear_login_info():
var file = FileAccess.open("user://login.json", FileAccess.WRITE)
if file:
var empty_data = {
"user_name": "",
"password": ""
}
var json_string = JSON.stringify(empty_data, "\t")
file.store_string(json_string)
file.close()
print("登录信息已清除")
else:
print("无法清除登录信息")
# 切换记住密码选项
func toggle_remember_password():
remember_password = !remember_password
print("记住密码选项:", "开启" if remember_password else "关闭")
# 如果关闭了记住密码,清除已保存的信息
if not remember_password:
_clear_login_info()
# 检查是否有保存的登录信息
func has_saved_login_info() -> bool:
var file = FileAccess.open("user://login.json", FileAccess.READ)
if file:
var json_text = file.get_as_text()
file.close()
var json = JSON.new()
var parse_result = json.parse(json_text)
if parse_result == OK:
var login_data = json.get_data()
var user_name = login_data.get("user_name", "")
var password = login_data.get("password", "")
return user_name != "" and password != ""
return false
# 快捷登录(使用保存的登录信息)
func quick_login():
if has_saved_login_info():
var user_name = username_input.text.strip_edges()
var user_password = password_input.text.strip_edges()
if user_name != "" and user_password != "":
print("执行快捷登录...")
_on_login_button_pressed()
else:
status_label.text = "保存的登录信息不完整"
status_label.modulate = Color.ORANGE
else:
status_label.text = "没有保存的登录信息"
status_label.modulate = Color.ORANGE
# 获取保存的用户名(用于调试或显示)
func get_saved_username() -> String:
var file = FileAccess.open("user://login.json", FileAccess.READ)
if file:
var json_text = file.get_as_text()
file.close()
var json = JSON.new()
var parse_result = json.parse(json_text)
if parse_result == OK:
var login_data = json.get_data()
return login_data.get("user_name", "")
return ""
# 显示版本信息
func _display_version_info():
# 在状态标签中显示客户端版本信息
if status_label.text == "欢迎使用萌芽农场" or status_label.text == "连接状态":
status_label.text = "萌芽农场 v" + main_game.client_version + " - 欢迎使用"
status_label.modulate = Color.CYAN
# 处理连接断开事件
func _on_connection_lost():
print("登录面板收到连接断开通知")
# 更新状态标签
status_label.text = "与服务器连接已断开,请重新登录"
status_label.modulate = Color.ORANGE
# 重新启用所有按钮
login_button.disabled = false
register_button.disabled = false
send_button.disabled = false
send_button.text = "发送验证码"

1
GUI/LoginPanel.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://cka0r4g8tbf0

View File

@@ -27,8 +27,8 @@ signal draw_failed(error_message: String) # 抽奖失败信号
# =============================================================================
var reward_templates: Array[RichTextLabel] = []
var current_rewards: Array = []
var network_manager = null
var main_game = null
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
@onready var main_game = get_node("/root/main")
# 15种不同的模板颜色
var template_colors: Array[Color] = [
@@ -47,10 +47,10 @@ var template_colors: Array[Color] = [
Color(1.0, 0.95, 0.8, 1.0), # 淡香槟色
Color(0.85, 0.8, 1.0, 1.0), # 淡薰衣草色
Color(0.95, 1.0, 0.85, 1.0) # 淡春绿色
]
var anticipation_tween: Tween = null
# =============================================================================
# 基础奖励配置 - 根据 crop_data.json 调整
# =============================================================================
@@ -60,7 +60,6 @@ var base_rewards: Dictionary = {
"empty": {"name": "谢谢惠顾", "icon": "😅", "color": "#CCCCCC"}
}
# 根据 crop_data.json 动态构建的种子奖励
var seed_rewards: Dictionary = {}
# 抽奖费用配置
@@ -81,11 +80,8 @@ var server_reward_pools: Dictionary = {}
func _ready() -> void:
_initialize_system()
#初始化抽奖系统
func _initialize_system() -> void:
"""初始化抽奖系统"""
# 获取网络管理器和主游戏引用
network_manager = get_node("/root/main/UI/TCPNetworkManager")
main_game = get_node("/root/main")
# 连接信号
if main_game:
@@ -97,15 +93,15 @@ func _initialize_system() -> void:
_generate_reward_templates()
_update_template_display()
#从主游戏加载作物数据并构建种子奖励
func _load_crop_data_and_build_rewards() -> void:
"""从主游戏加载作物数据并构建种子奖励"""
if main_game and main_game.has_method("get_crop_data"):
var crop_data = main_game.get_crop_data()
if crop_data:
_build_seed_rewards_from_crop_data(crop_data)
#根据 crop_data.json 构建种子奖励配置
func _build_seed_rewards_from_crop_data(crop_data: Dictionary) -> void:
"""根据 crop_data.json 构建种子奖励配置"""
seed_rewards.clear()
for crop_name in crop_data.keys():
@@ -126,8 +122,8 @@ func _build_seed_rewards_from_crop_data(crop_data: Dictionary) -> void:
"cost": crop_info.get("花费", 50)
}
#根据稀有度获取颜色
func _get_rarity_color(rarity: String) -> String:
"""根据稀有度获取颜色"""
match rarity:
"普通":
return "#90EE90"
@@ -270,7 +266,6 @@ func _format_template_text(reward: Dictionary) -> String:
## 执行网络抽奖
func _perform_network_draw(draw_type: String) -> void:
"""通过网络请求执行抽奖"""
if not network_manager or not network_manager.is_connected_to_server():
_show_error_message("网络未连接,无法进行抽奖")
return
@@ -292,7 +287,6 @@ func _perform_network_draw(draw_type: String) -> void:
## 显示等待动画
func _show_waiting_animation(draw_type: String) -> void:
"""显示抽奖等待动画"""
# 禁用抽奖按钮
_set_draw_buttons_enabled(false)
@@ -304,7 +298,6 @@ func _show_waiting_animation(draw_type: String) -> void:
## 处理服务器抽奖响应
func handle_lucky_draw_response(response: Dictionary) -> void:
"""处理来自服务器的抽奖响应"""
# 停止期待动画
_stop_anticipation_animation()
@@ -329,7 +322,6 @@ func handle_lucky_draw_response(response: Dictionary) -> void:
## 显示服务器返回的抽奖结果
func _show_server_draw_results(rewards: Array, draw_type: String, cost: int) -> void:
"""显示服务器返回的抽奖结果"""
current_rewards = rewards
# 显示结果动画已在handle_lucky_draw_response中停止
@@ -492,7 +484,7 @@ func _play_anticipation_animation() -> void:
0.0, 1.0, 0.5
)
var anticipation_tween: Tween = null
func _anticipation_flash(template: RichTextLabel, progress: float) -> void:
"""期待动画闪烁效果"""
@@ -501,7 +493,6 @@ func _anticipation_flash(template: RichTextLabel, progress: float) -> void:
## 停止期待动画
func _stop_anticipation_animation() -> void:
"""停止期待动画"""
if anticipation_tween:
anticipation_tween.kill()
anticipation_tween = null
@@ -524,7 +515,6 @@ func _play_result_animation() -> void:
## 显示错误信息
func _show_error_message(message: String) -> void:
"""显示错误信息"""
lucky_draw_reward.text = "[center][color=#FF6B6B]❌ %s[/color][/center]" % message
lucky_draw_reward.show()
@@ -579,6 +569,5 @@ func clear_draw_results() -> void:
## 刷新奖励显示(当作物数据更新时调用)
func refresh_reward_display() -> void:
"""刷新奖励显示"""
_load_crop_data_and_build_rewards()
_update_template_display()

View File

@@ -13,6 +13,12 @@ offset_top = -1.0
offset_right = 600.0
offset_bottom = 58.0
theme_override_colors/font_color = Color(0.624759, 0.8051, 0.828302, 1)
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 3
theme_override_constants/shadow_offset_y = 3
theme_override_constants/outline_size = 10
theme_override_constants/shadow_outline_size = 10
theme_override_font_sizes/font_size = 35
text = "幸运抽奖"
horizontal_alignment = 1

View File

@@ -1,13 +1,13 @@
[gd_scene load_steps=9 format=3 uid="uid://bypjb28h4ntdr"]
[ext_resource type="Script" uid="uid://badqjgdfhg7vt" path="res://GUI/MainMenuPanel.gd" id="1_wpehy"]
[ext_resource type="Texture2D" uid="uid://bhdqkhf0y2ply" path="res://assets/UI/背景1.jpg" id="2_fys16"]
[ext_resource type="Script" path="res://GUI/GameSettingPanel.gd" id="2_n0pjj"]
[ext_resource type="Texture2D" uid="uid://4kvddwqlodpg" path="res://assets/logo_title/logo1.png" id="3_sr106"]
[ext_resource type="Script" path="res://GUI/GameAboutPanel.gd" id="3_y0inj"]
[ext_resource type="Texture2D" uid="uid://ddcmrh50o1y0q" path="res://assets/菜单UI/背景1.webp" id="2_eghpk"]
[ext_resource type="Texture2D" uid="uid://h8tto256aww4" path="res://assets/菜单Logo/logo1.webp" id="3_eghpk"]
[ext_resource type="Script" uid="uid://bob7a4vhw4nl3" path="res://GUI/GameAboutPanel.gd" id="3_y0inj"]
[ext_resource type="Texture2D" uid="uid://dgdootc5bny5q" path="res://assets/菜单UI/QQ群.webp" id="4_eghpk"]
[ext_resource type="Script" uid="uid://kj7v1uxk2i6h" path="res://GUI/GameUpdatePanel.gd" id="4_fys16"]
[ext_resource type="Texture2D" uid="uid://b5of6puh4efui" path="res://assets/杂项/柚小青装饰品.png" id="5_eghpk"]
[ext_resource type="Texture2D" uid="uid://cuuqapjbrsdy7" path="res://assets/UI/QQ群.jpg" id="5_y0inj"]
[ext_resource type="Texture2D" uid="uid://ccav04woielxa" path="res://assets/菜单UI/柚小青装饰品.webp" id="5_6jmhb"]
[ext_resource type="PackedScene" uid="uid://dos15dmc1b6bt" path="res://GUI/GameSettingPanel.tscn" id="6_eghpk"]
[node name="MainMenuPanel" type="Control"]
layout_mode = 3
@@ -26,7 +26,7 @@ offset_left = -131.0
offset_top = -24.0
offset_right = 1568.0
offset_bottom = 734.0
texture = ExtResource("2_fys16")
texture = ExtResource("2_eghpk")
[node name="GUI" type="Control" parent="."]
anchors_preset = 0
@@ -40,7 +40,7 @@ offset_top = -24.0
offset_right = 1730.0
offset_bottom = 696.0
scale = Vector2(0.4, 0.4)
texture = ExtResource("3_sr106")
texture = ExtResource("3_eghpk")
stretch_mode = 2
[node name="RichTextLabel" type="RichTextLabel" parent="GUI"]
@@ -79,7 +79,7 @@ offset_top = 43.0
offset_right = 952.0
offset_bottom = 1229.0
scale = Vector2(0.3, 0.3)
texture = ExtResource("5_y0inj")
texture = ExtResource("4_eghpk")
[node name="YouXiaoQing" type="TextureRect" parent="GUI/AddGroupLabel"]
layout_mode = 0
@@ -88,7 +88,7 @@ offset_top = 82.0
offset_right = 1233.0
offset_bottom = 1268.0
scale = Vector2(0.14, 0.14)
texture = ExtResource("5_eghpk")
texture = ExtResource("5_6jmhb")
[node name="VBox" type="VBoxContainer" parent="."]
layout_mode = 0
@@ -131,41 +131,8 @@ size_flags_horizontal = 4
theme_override_font_sizes/font_size = 40
text = "退出游戏"
[node name="GameSettingPanel" type="Panel" parent="."]
visible = false
[node name="GameSettingPanel" parent="." instance=ExtResource("6_eghpk")]
layout_mode = 0
offset_right = 1398.0
offset_bottom = 720.0
script = ExtResource("2_n0pjj")
[node name="Title" type="Label" parent="GameSettingPanel"]
layout_mode = 0
offset_right = 1398.0
offset_bottom = 80.0
theme_override_font_sizes/font_size = 45
text = "游戏设置"
horizontal_alignment = 1
vertical_alignment = 1
[node name="QuitButton" type="Button" parent="GameSettingPanel"]
custom_minimum_size = Vector2(60, 60)
layout_mode = 0
offset_left = 1340.0
offset_right = 1400.0
offset_bottom = 60.0
theme_override_font_sizes/font_size = 35
text = "X"
[node name="Scroll" type="ScrollContainer" parent="GameSettingPanel"]
layout_mode = 0
offset_top = 80.0
offset_right = 1400.0
offset_bottom = 720.0
[node name="Contents" type="RichTextLabel" parent="GameSettingPanel/Scroll"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="GameAboutPanel" type="Panel" parent="."]
layout_mode = 0
@@ -177,6 +144,13 @@ script = ExtResource("3_y0inj")
layout_mode = 0
offset_right = 1398.0
offset_bottom = 80.0
theme_override_colors/font_color = Color(0.780392, 1, 0.905882, 1)
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 5
theme_override_constants/shadow_offset_y = 5
theme_override_constants/outline_size = 10
theme_override_constants/shadow_outline_size = 10
theme_override_font_sizes/font_size = 45
text = "关于"
horizontal_alignment = 1
@@ -185,9 +159,9 @@ vertical_alignment = 1
[node name="QuitButton" type="Button" parent="GameAboutPanel"]
custom_minimum_size = Vector2(60, 60)
layout_mode = 0
offset_left = 1340.0
offset_left = 1325.0
offset_right = 1400.0
offset_bottom = 60.0
offset_bottom = 80.0
theme_override_font_sizes/font_size = 35
text = "X"
@@ -210,7 +184,8 @@ text = "玩法介绍:
4.不要一上来就把钱用完了(比如某某人一上来就十连抽),可以去偷别人的菜
致谢名单:
虚空领主:(美术抠图)
程序牛马:(作物处理+抠图)
虚空领主:(抠图)
豆包:(万能的美术)"
[node name="GameUpdatePanel" type="Panel" parent="."]
@@ -263,6 +238,5 @@ text = "刷新"
[connection signal="pressed" from="VBox/GameUpdateButton" to="." method="_on_game_update_button_pressed"]
[connection signal="pressed" from="VBox/GameAboutButton" to="." method="_on_game_about_button_pressed"]
[connection signal="pressed" from="VBox/ExitButton" to="." method="_on_exit_button_pressed"]
[connection signal="pressed" from="GameSettingPanel/QuitButton" to="GameSettingPanel" method="_on_quit_button_pressed"]
[connection signal="pressed" from="GameAboutPanel/QuitButton" to="GameAboutPanel" method="_on_quit_button_pressed"]
[connection signal="pressed" from="GameUpdatePanel/QuitButton" to="GameUpdatePanel" method="_on_quit_button_pressed"]

View File

@@ -21,6 +21,7 @@ extends Panel
@onready var one_column_plant_btn: Button = $Grid/OneColumnPlantBtn #列种植
@onready var nine_square_plant_btn: Button = $Grid/NineSquarePlantBtn #九宫格种植
@onready var cross_plant_btn: Button = $Grid/CrossPlantBtn #十字法种植
@onready var random_plant_btn: Button = $Grid/RandomPlantBtn #随机种植
# 引用主游戏和其他面板
@onready var main_game = get_node("/root/main")
@@ -36,6 +37,9 @@ const BASE_COST = 500 # 基础费用
const COST_RATE = 0.2 # 种植成本比例20%
const PLANT_INTERVAL = 0.25 # 种植间隔时间
# 种植状态变量
var is_planting = false
var selected_crop_name = ""
@@ -57,6 +61,7 @@ func _ready():
one_column_plant_btn.pressed.connect(_on_one_column_plant_pressed)
nine_square_plant_btn.pressed.connect(_on_nine_square_plant_pressed)
cross_plant_btn.pressed.connect(_on_cross_plant_pressed)
random_plant_btn.pressed.connect(_on_random_plant_pressed)
# 设置按钮提示文本
_setup_button_tooltips()
@@ -68,6 +73,8 @@ func _process(delta):
plant_timer = 0.0
_process_plant_queue()
#=================================一键种植模式=========================================
# 全屏种植按钮处理
func _on_full_screen_plant_pressed():
_request_crop_selection("全屏种植", "选择要种植的作物进行全屏种植")
@@ -88,111 +95,10 @@ func _on_nine_square_plant_pressed():
func _on_cross_plant_pressed():
_start_lot_selection_mode("十字法种植")
# 开始地块选择模式
func _start_lot_selection_mode(plant_type: String):
is_waiting_for_lot_selection = true
pending_plant_type = plant_type
# 随机种植按钮处理
func _on_random_plant_pressed():
_prepare_random_plant()
# 隐藏一键种植面板
self.hide()
# 显示提示信息
var tip_message = ""
match plant_type:
"行种植":
tip_message = "请点击一个地块来确定要种植的行"
"列种植":
tip_message = "请点击一个地块来确定要种植的列"
"九宫格种植":
tip_message = "请点击一个地块来确定九宫格种植的中心位置"
"十字法种植":
tip_message = "请点击一个地块来确定十字法种植的中心位置"
_:
tip_message = "请点击一个地块"
Toast.show(tip_message + "按ESC键取消", Color.CYAN)
print("进入地块选择模式:%s" % plant_type)
# 处理地块选择从MainGame调用
func on_lot_selected(lot_index: int):
if not is_waiting_for_lot_selection:
return false # 不是等待地块选择状态返回false让MainGame正常处理
# 退出地块选择模式
is_waiting_for_lot_selection = false
# 设置选择的地块索引
main_game.selected_lot_index = lot_index
# 开始作物选择
_request_crop_selection(pending_plant_type, "选择要种植的作物进行" + pending_plant_type)
# 清空待处理的种植类型
pending_plant_type = ""
return true # 返回true表示已处理了地块选择
# 请求作物选择
func _request_crop_selection(plant_type: String, tip_message: String):
# 检查背包是否有种子
if main_game.player_bag.size() == 0:
Toast.show("背包中没有种子,请先去商店购买", Color.RED)
return
var has_seeds = false
for item in main_game.player_bag:
if item["count"] > 0:
has_seeds = true
break
if not has_seeds:
Toast.show("背包中没有可用的种子", Color.RED)
return
Toast.show(tip_message, Color.CYAN)
self.hide()
# 设置背包面板的种植模式回调
player_bag_panel.set_planting_mode(plant_type, self)
player_bag_panel.show()
# 背包选择作物回调函数
func on_crop_selected(crop_name: String, plant_type: String):
selected_crop_name = crop_name
# 检查背包中的作物数量
selected_crop_count = _get_crop_count_in_bag(crop_name)
if selected_crop_count <= 0:
Toast.show("背包中没有 " + crop_name + " 种子", Color.RED)
return
print("开始准备一键种植:")
print(" 选择作物:%s" % crop_name)
print(" 种植模式:%s" % plant_type)
print(" 背包数量:%d" % selected_crop_count)
# 根据种植类型生成种植队列
match plant_type:
"全屏种植":
_prepare_full_screen_plant()
"行种植":
_prepare_row_plant()
"列种植":
_prepare_column_plant()
"九宫格种植":
_prepare_nine_square_plant()
"十字法种植":
_prepare_cross_plant()
_:
Toast.show("未知的种植模式:" + plant_type, Color.RED)
print("错误:未知的种植模式:%s" % plant_type)
# 获取背包中指定作物的数量
func _get_crop_count_in_bag(crop_name: String) -> int:
for item in main_game.player_bag:
if item["name"] == crop_name:
return item["count"]
return 0
# 准备全屏种植
func _prepare_full_screen_plant():
@@ -277,6 +183,210 @@ func _prepare_cross_plant():
_start_planting("十字法种植")
# 准备随机种植
func _prepare_random_plant():
# 检查背包是否有种子
if main_game.player_bag.size() == 0:
Toast.show("背包中没有种子,请先去商店购买", Color.RED)
return
# 获取背包中所有的种子类型和数量
var available_seeds = []
for item in main_game.player_bag:
if item["count"] > 0:
# 根据种子数量添加多个相同种子到列表中
for i in range(item["count"]):
available_seeds.append(item["name"])
if available_seeds.size() == 0:
Toast.show("背包中没有可用的种子", Color.RED)
return
# 打乱种子列表
available_seeds.shuffle()
# 获取所有可种植的地块
var available_lots = []
for i in range(len(main_game.farm_lots)):
if _can_plant_at_index(i):
available_lots.append(i)
if available_lots.size() == 0:
Toast.show("没有可种植的地块", Color.YELLOW)
return
# 根据种子数量和可种植地块数量确定实际种植数量
var plant_count = min(available_seeds.size(), available_lots.size())
# 准备种植队列,每个元素包含地块索引和对应的种子名称
plant_queue.clear()
var random_plant_data = [] # 存储地块索引和对应种子的映射
for i in range(plant_count):
var lot_index = available_lots[i]
var seed_name = available_seeds[i]
plant_queue.append(lot_index)
random_plant_data.append({"lot_index": lot_index, "seed_name": seed_name})
# 存储随机种植数据到全局变量,供种植过程使用
if not has_meta("random_plant_data"):
set_meta("random_plant_data", random_plant_data)
else:
set_meta("random_plant_data", random_plant_data)
# 计算总费用(基于所有要种植的种子)
var total_crop_cost = 0
for data in random_plant_data:
var crop_data = main_game.can_planted_crop.get(data["seed_name"], {})
var crop_price = crop_data.get("花费", 0)
total_crop_cost += crop_price
var service_fee = int(total_crop_cost * COST_RATE) + BASE_COST
print("随机种植费用计算:")
var seed_names = []
for data in random_plant_data:
seed_names.append(data["seed_name"])
print(" 将要种植的种子:%s" % str(seed_names))
print(" 种植数量:%d 个地块" % plant_count)
print(" 作物总成本:%d" % total_crop_cost)
print(" 服务费率:%.1f%%" % (COST_RATE * 100))
print(" 基础费用:%d" % BASE_COST)
print(" 总服务费:%d" % service_fee)
print(" 玩家当前金钱:%d" % main_game.money)
# 检查金钱是否足够支付服务费
if main_game.money < service_fee:
Toast.show("金钱不足!随机种植需要服务费 %d 元(当前:%d 元)" % [service_fee, main_game.money], Color.RED)
return
# 扣除服务费
main_game.money -= service_fee
main_game._update_ui()
# 开始种植
is_planting = true
current_plant_index = 0
plant_timer = 0.0
# 更新按钮状态为种植中
_update_buttons_planting_state(true)
# 计算不同种子的数量
var unique_seeds = {}
for data in random_plant_data:
unique_seeds[data["seed_name"]] = true
var unique_seed_count = unique_seeds.size()
Toast.show("开始随机种植,预计种植 %d 个地块,使用 %d 种不同种子,服务费 %d" % [plant_count, unique_seed_count, service_fee], Color.GREEN)
#=================================一键种植模式=========================================
# 开始地块选择模式
func _start_lot_selection_mode(plant_type: String):
is_waiting_for_lot_selection = true
pending_plant_type = plant_type
# 隐藏一键种植面板
self.hide()
# 显示提示信息
var tip_message = ""
match plant_type:
"行种植":
tip_message = "请点击一个地块来确定要种植的行"
"列种植":
tip_message = "请点击一个地块来确定要种植的列"
"九宫格种植":
tip_message = "请点击一个地块来确定九宫格种植的中心位置"
"十字法种植":
tip_message = "请点击一个地块来确定十字法种植的中心位置"
_:
tip_message = "请点击一个地块"
Toast.show(tip_message + "按ESC键取消", Color.CYAN)
print("进入地块选择模式:%s" % plant_type)
# 处理地块选择从MainGame调用
func on_lot_selected(lot_index: int):
if not is_waiting_for_lot_selection:
return false # 不是等待地块选择状态返回false让MainGame正常处理
# 退出地块选择模式
is_waiting_for_lot_selection = false
# 设置选择的地块索引
main_game.selected_lot_index = lot_index
# 开始作物选择
_request_crop_selection(pending_plant_type, "选择要种植的作物进行" + pending_plant_type)
# 清空待处理的种植类型
pending_plant_type = ""
return true # 返回true表示已处理了地块选择
# 请求作物选择
func _request_crop_selection(plant_type: String, tip_message: String):
# 检查背包是否有种子
if main_game.player_bag.size() == 0:
Toast.show("背包中没有种子,请先去商店购买", Color.RED)
return
var has_seeds = false
for item in main_game.player_bag:
if item["count"] > 0:
has_seeds = true
break
if not has_seeds:
Toast.show("背包中没有可用的种子", Color.RED)
return
Toast.show(tip_message, Color.CYAN)
self.hide()
# 设置背包面板的种植模式回调
player_bag_panel.set_planting_mode(plant_type, self)
player_bag_panel.show()
# 背包选择作物回调函数
func on_crop_selected(crop_name: String, plant_type: String):
selected_crop_name = crop_name
# 检查背包中的作物数量
selected_crop_count = _get_crop_count_in_bag(crop_name)
if selected_crop_count <= 0:
Toast.show("背包中没有 " + crop_name + " 种子", Color.RED)
return
# 根据种植类型生成种植队列
match plant_type:
"全屏种植":
_prepare_full_screen_plant()
"行种植":
_prepare_row_plant()
"列种植":
_prepare_column_plant()
"九宫格种植":
_prepare_nine_square_plant()
"十字法种植":
_prepare_cross_plant()
_:
Toast.show("未知的种植模式:" + plant_type, Color.RED)
print("错误:未知的种植模式:%s" % plant_type)
# 获取背包中指定作物的数量
func _get_crop_count_in_bag(crop_name: String) -> int:
for item in main_game.player_bag:
if item["name"] == crop_name:
return item["count"]
return 0
# 开始种植
func _start_planting(plant_type: String):
if plant_queue.size() == 0:
@@ -322,7 +432,6 @@ func _start_planting(plant_type: String):
_update_buttons_planting_state(true)
Toast.show("开始%s,预计种植 %d 个地块,服务费 %d" % [plant_type, plant_queue.size(), total_cost], Color.GREEN)
print("开始%s,种植队列: %s" % [plant_type, str(plant_queue)])
# 处理种植队列
func _process_plant_queue():
@@ -333,6 +442,20 @@ func _process_plant_queue():
var lot_index = plant_queue[current_plant_index]
# 检查是否是随机种植模式
if has_meta("random_plant_data"):
# 随机种植模式:每个地块种植不同的种子
var random_plant_data = get_meta("random_plant_data")
if current_plant_index < random_plant_data.size():
var plant_data = random_plant_data[current_plant_index]
var seed_name = plant_data["seed_name"]
# 检查是否还有该种子和该地块是否仍可种植
if _get_crop_count_in_bag(seed_name) > 0 and _can_plant_at_index(lot_index):
# 执行随机种植
_plant_at_index_with_seed(lot_index, seed_name)
else:
# 普通种植模式:所有地块种植相同的种子
# 检查是否还有种子和该地块是否仍可种植
if _get_crop_count_in_bag(selected_crop_name) > 0 and _can_plant_at_index(lot_index):
# 执行种植
@@ -343,26 +466,32 @@ func _process_plant_queue():
# 完成种植
func _finish_planting():
is_planting = false
var planted_count = current_plant_index
var success_count = min(planted_count, selected_crop_count)
# 恢复按钮状态
_update_buttons_planting_state(false)
Toast.show("一键种植完成!成功种植 %d 个地块" % success_count, Color.GREEN)
print("一键种植完成,成功种植了 %d 个地块" % success_count)
# 清空队列
plant_queue.clear()
current_plant_index = 0
# 清理随机种植的元数据
if has_meta("random_plant_data"):
remove_meta("random_plant_data")
# 在指定索引处种植
func _plant_at_index(lot_index: int):
if network_manager and network_manager.sendPlantCrop(lot_index, selected_crop_name):
print("发送种植请求:地块 %d,作物 %s" % [lot_index, selected_crop_name])
pass
else:
print("发送种植请求失败:地块 %d" % lot_index)
# 在指定索引处种植指定种子(用于随机种植)
func _plant_at_index_with_seed(lot_index: int, seed_name: String):
if network_manager and network_manager.sendPlantCrop(lot_index, seed_name):
pass
else:
print("发送种植请求失败:地块 %d,种子 %s" % [lot_index, seed_name])
# 检查指定索引的地块是否可以种植
func _can_plant_at_index(index: int) -> bool:
if index < 0 or index >= len(main_game.farm_lots):
@@ -403,6 +532,7 @@ func _setup_button_tooltips():
one_column_plant_btn.tooltip_text = "在选定地块所在的列中从上到下依次种植\n点击此按钮后,再点击农场中的任意地块确定列位置\n费用种植总成本的20% + 500元基础费"
nine_square_plant_btn.tooltip_text = "以选定地块为中心的3x3九宫格范围内种植\n点击此按钮后,再点击农场中的任意地块确定中心位置\n费用种植总成本的20% + 500元基础费"
cross_plant_btn.tooltip_text = "以选定地块为中心的十字形(上下左右+中心)种植\n点击此按钮后,再点击农场中的任意地块确定中心位置\n费用种植总成本的20% + 500元基础费"
random_plant_btn.tooltip_text = "获取背包中所有种子并打乱后随机种植到所有空地块\n自动使用背包中的各种种子,每个地块种植不同种子\n费用种植总成本的20% + 500元基础费"
# 更新按钮状态
func _update_buttons_planting_state(planting: bool):
@@ -413,12 +543,14 @@ func _update_buttons_planting_state(planting: bool):
one_column_plant_btn.disabled = true
nine_square_plant_btn.disabled = true
cross_plant_btn.disabled = true
random_plant_btn.disabled = true
full_screen_plant_btn.text = "种植中..."
one_row_plant_btn.text = "种植中..."
one_column_plant_btn.text = "种植中..."
nine_square_plant_btn.text = "种植中..."
cross_plant_btn.text = "种植中..."
random_plant_btn.text = "种植中..."
else:
# 种植完成,恢复按钮状态
full_screen_plant_btn.disabled = false
@@ -426,12 +558,14 @@ func _update_buttons_planting_state(planting: bool):
one_column_plant_btn.disabled = false
nine_square_plant_btn.disabled = false
cross_plant_btn.disabled = false
random_plant_btn.disabled = false
full_screen_plant_btn.text = "全屏种植"
one_row_plant_btn.text = "行种植"
one_column_plant_btn.text = "列种植"
nine_square_plant_btn.text = "九宫格种植"
cross_plant_btn.text = "十字法种植"
nine_square_plant_btn.text = "九宫格\n种植"
cross_plant_btn.text = "十字法\n种植"
random_plant_btn.text = "随机\n种植"
# 取消地块选择模式
func cancel_lot_selection():
@@ -439,7 +573,6 @@ func cancel_lot_selection():
is_waiting_for_lot_selection = false
pending_plant_type = ""
Toast.show("已取消地块选择", Color.YELLOW)
print("用户取消了地块选择")
# 重新显示一键种植面板
self.show()
@@ -448,10 +581,9 @@ func stop_planting():
if is_planting:
is_planting = false
Toast.show("一键种植已停止", Color.YELLOW)
print("用户停止了一键种植")
_finish_planting()
#这个不用管
#关闭一键种植面板
func _on_quit_button_pressed() -> void:
# 如果正在种植,先停止种植
if is_planting:
@@ -459,6 +591,6 @@ func _on_quit_button_pressed() -> void:
# 如果正在等待地块选择,取消选择
elif is_waiting_for_lot_selection:
cancel_lot_selection()
return # cancel_lot_selection已经重新显示了面板不需要hide
return
self.hide()
pass

229
GUI/OnlineGiftPanel.gd Normal file
View File

@@ -0,0 +1,229 @@
extends Panel
@onready var one_minute: Button = $Grid/OneMinute
@onready var three_minutes: Button = $Grid/ThreeMinutes
@onready var five_minutes: Button = $Grid/FiveMinutes
@onready var ten_minutes: Button = $Grid/TenMinutes
@onready var thirty_minutes: Button = $Grid/ThirtyMinutes
@onready var one_hour: Button = $Grid/OneHour
@onready var three_hours: Button = $Grid/ThreeHours
@onready var five_hours: Button = $Grid/FiveHours
# 网络管理器引用,运行时获取
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 在线礼包数据结构
var online_gift_config = {
"1分钟": {
"time_seconds": 60,
"rewards": {
"money": 100,
"experience": 50,
"seeds": [{"name": "小麦", "count": 5}, {"name": "胡萝卜", "count": 3}]
}
},
"3分钟": {
"time_seconds": 180,
"rewards": {
"money": 250,
"experience": 150,
"seeds": [{"name": "胡萝卜", "count": 5}, {"name": "玉米", "count": 3}]
}
},
"5分钟": {
"time_seconds": 300,
"rewards": {
"money": 500,
"experience": 250,
"seeds": [{"name": "玉米", "count": 3}, {"name": "番茄", "count": 2}]
}
},
"10分钟": {
"time_seconds": 600,
"rewards": {
"money": 500,
"experience": 200,
"seeds": [{"name": "玉米", "count": 3}, {"name": "番茄", "count": 2}]
}
},
"30分钟": {
"time_seconds": 1800,
"rewards": {
"money": 1200,
"experience": 500,
"seeds": [{"name": "草莓", "count": 2}, {"name": "花椰菜", "count": 1}]
}
},
"1小时": {
"time_seconds": 3600,
"rewards": {
"money": 2500,
"experience": 1000,
"seeds": [{"name": "葡萄", "count": 1}, {"name": "南瓜", "count": 1}, {"name": "咖啡豆", "count": 1}]
}
},
"3小时": {
"time_seconds": 10800,
"rewards": {
"money": 6000,
"experience": 2500,
"seeds": [{"name": "人参", "count": 1}, {"name": "藏红花", "count": 1}]
}
},
"5小时": {
"time_seconds": 18000,
"rewards": {
"money": 12000,
"experience": 5000,
"seeds": [{"name": "龙果", "count": 1}, {"name": "松露", "count": 1}, {"name": "月光草", "count": 1}]
}
}
}
# 按钮映射
var button_mapping = {}
# 礼包领取状态
var gift_claimed_status = {}
# 在线开始时间
var online_start_time: float = 0
# 当前在线时长
var current_online_duration: float = 0
func _ready():
# 初始化按钮映射
button_mapping = {
"1分钟": one_minute,
"3分钟": three_minutes,
"5分钟": five_minutes,
"10分钟": ten_minutes,
"30分钟": thirty_minutes,
"1小时": one_hour,
"3小时": three_hours,
"5小时": five_hours
}
# 连接按钮信号
for gift_name in button_mapping.keys():
var button = button_mapping[gift_name]
if button:
button.pressed.connect(_on_gift_button_pressed.bind(gift_name))
# 初始化时禁用所有按钮
disable_all_buttons()
#显示面板并请求最新数据
func show_panel_and_request_data():
show()
move_to_front()
request_online_gift_data()
#禁用所有礼包按钮
func disable_all_buttons():
for button in button_mapping.values():
if button:
button.disabled = true
#更新按钮状态
func update_button_status():
for gift_name in online_gift_config.keys():
var config = online_gift_config[gift_name]
var button = button_mapping[gift_name]
if not button:
continue
var required_time = config["time_seconds"]
var is_claimed = gift_claimed_status.get(gift_name, false)
if is_claimed:
# 已领取
button.disabled = true
button.text = gift_name + "\n(已领取)"
elif current_online_duration >= required_time:
# 可以领取
button.disabled = false
button.text = gift_name + "\n(可领取)"
else:
# 时间未到
button.disabled = true
var remaining_time = required_time - current_online_duration
button.text = gift_name + "\n(" + format_time(remaining_time) + ")"
#格式化时间显示
func format_time(seconds: float) -> String:
var hours = int(seconds / 3600)
var minutes = int(int(seconds) % 3600 / 60)
var secs = int(int(seconds) % 60)
if hours > 0:
return "%d:%02d:%02d" % [hours, minutes, secs]
else:
return "%02d:%02d" % [minutes, secs]
#处理礼包按钮点击
func _on_gift_button_pressed(gift_name: String):
if gift_claimed_status.get(gift_name, false):
Toast.show("该礼包已经领取过了!", Color.RED)
return
# 发送领取请求到服务器
request_claim_online_gift(gift_name)
#请求在线礼包数据
func request_online_gift_data():
network_manager.sendGetOnlineGiftData()
#请求领取在线礼包
func request_claim_online_gift(gift_name: String):
network_manager.sendClaimOnlineGift(gift_name)
#处理在线礼包数据响应
func handle_online_gift_data_response(data: Dictionary):
if data.has("claimed_gifts"):
gift_claimed_status = data["claimed_gifts"]
if data.has("online_start_time"):
online_start_time = data["online_start_time"]
# 直接使用服务端计算的在线时长
if data.has("current_online_duration"):
current_online_duration = data["current_online_duration"]
# 更新按钮状态
update_button_status()
#处理领取在线礼包响应
func handle_claim_online_gift_response(data: Dictionary):
var success = data.get("success", false)
var message = data.get("message", "")
var gift_name = data.get("gift_name", "")
if success:
# 标记为已领取
gift_claimed_status[gift_name] = true
# 显示奖励信息
var rewards = data.get("rewards", {})
var reward_text = "获得奖励: "
if rewards.has("money"):
reward_text += "金币+" + str(rewards["money"]) + " "
if rewards.has("experience"):
reward_text += "经验+" + str(rewards["experience"]) + " "
if rewards.has("seeds"):
for seed in rewards["seeds"]:
reward_text += seed["name"] + "x" + str(seed["count"]) + " "
Toast.show(reward_text, Color.GOLD)
Toast.show(message, Color.GREEN)
# 更新按钮状态
update_button_status()
else:
Toast.show(message, Color.RED)
#关闭在线礼包面板
func _on_quit_button_pressed() -> void:
self.hide()

View File

@@ -0,0 +1 @@
uid://ccaqrb6sdwbux

510
GUI/PlayerBagPanel.gd Normal file
View File

@@ -0,0 +1,510 @@
extends Panel
# 背包格子容器
@onready var player_bag_grid_container : GridContainer = $ScrollContainer/Bag_Grid
@onready var quit_button : Button = $QuitButton
#各种排序过滤按钮
@onready var sort_all_button : Button = $SortContainer/Sort_All#全部
@onready var sort_common_button : Button = $SortContainer/Sort_Common#普通
@onready var sort_superior_button : Button = $SortContainer/Sort_Superior#优良
@onready var sort_rare_button : Button = $SortContainer/Sort_Rare#稀有
@onready var sort_epic_button : Button = $SortContainer/Sort_Epic#史诗
@onready var sort_legendary_button : Button = $SortContainer/Sort_Legendary#传奇
@onready var sort_price_button : Button = $SortContainer/Sort_Price#价格
@onready var sort_growtime_button : Button = $SortContainer/Sort_GrowTime#生长时间
@onready var sort_profit_button : Button = $SortContainer/Sort_Profit#收益
@onready var sort_level_button : Button = $SortContainer/Sort_Level#等级
#预添加常用的面板
@onready var main_game = get_node("/root/main")
@onready var land_panel = get_node("/root/main/UI/LandPanel")
@onready var crop_store_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var player_ranking_panel = get_node("/root/main/UI/PlayerRankingPanel")
@onready var player_bag_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 作物图片缓存(复用主游戏的缓存系统)
var crop_textures_cache : Dictionary = {}
var crop_frame_counts : Dictionary = {}
# 当前选择的地块索引从MainGame获取
var selected_lot_index : int = -1
# 当前过滤和排序设置
var current_filter_quality = ""
var current_sort_key = ""
var current_sort_ascending = true
# 一键种植模式相关变量
var is_planting_mode = false
var planting_type = ""
var one_click_plant_panel = null
# 准备函数
func _ready():
# 连接按钮信号
_connect_buttons()
# 隐藏面板(初始默认隐藏)
self.hide()
# 连接所有按钮信号
func _connect_buttons():
# 关闭按钮
quit_button.pressed.connect(self._on_quit_button_pressed)
# 过滤按钮
sort_all_button.pressed.connect(func(): _filter_by_quality(""))
sort_common_button.pressed.connect(func(): _filter_by_quality("普通"))
sort_superior_button.pressed.connect(func(): _filter_by_quality("优良"))
sort_rare_button.pressed.connect(func(): _filter_by_quality("稀有"))
sort_epic_button.pressed.connect(func(): _filter_by_quality("史诗"))
sort_legendary_button.pressed.connect(func(): _filter_by_quality("传奇"))
# 排序按钮
sort_price_button.pressed.connect(func(): _sort_by("花费"))
sort_growtime_button.pressed.connect(func(): _sort_by("生长时间"))
sort_profit_button.pressed.connect(func(): _sort_by("收益"))
sort_level_button.pressed.connect(func(): _sort_by("等级"))
# 初始化玩家背包
func init_player_bag():
# 清空玩家背包格子
for child in player_bag_grid_container.get_children():
child.queue_free()
# 显示背包中的种子
update_player_bag_ui()
# 更新玩家背包UI
func update_player_bag_ui():
# 清空玩家背包格子
for child in player_bag_grid_container.get_children():
child.queue_free()
#print("更新背包UI背包中物品数量", main_game.player_bag.size())
# 应用过滤和排序
var filtered_seeds = _get_filtered_and_sorted_seeds()
# 为背包中的每个过滤后的种子创建按钮
for seed_item in filtered_seeds:
var crop_name = seed_item["name"]
var crop_quality = seed_item.get("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))
# 根据是否处于访问模式连接不同的事件
if main_game.is_visiting_mode:
# 访问模式下,点击种子只显示信息,不能种植
button.pressed.connect(func(): _on_visit_seed_selected(crop_name, crop_count))
else:
# 正常模式下,连接种植事件
button.pressed.connect(func(): _on_bag_seed_selected(crop_name))
player_bag_grid_container.add_child(button)
# 获取过滤和排序后的种子列表
func _get_filtered_and_sorted_seeds():
var filtered_seeds = []
# 收集符合条件的种子
for seed_item in main_game.player_bag:
# 安全获取品质字段(兼容老数据)
var item_quality = seed_item.get("quality", "普通")
# 品质过滤
if current_filter_quality != "" and item_quality != current_filter_quality:
continue
# 获取种子对应的作物数据
var crop_data = null
if main_game.can_planted_crop.has(seed_item["name"]):
crop_data = main_game.can_planted_crop[seed_item["name"]]
# 添加到过滤后的列表
filtered_seeds.append({
"name": seed_item["name"],
"quality": item_quality,
"count": seed_item["count"],
"data": crop_data
})
# 如果有排序条件且数据可用,进行排序
if current_sort_key != "":
filtered_seeds.sort_custom(Callable(self, "_sort_seed_items"))
return filtered_seeds
# 自定义排序函数
func _sort_seed_items(a, b):
# 检查是否有有效数据用于排序
if a["data"] == null or b["data"] == null:
# 如果某一项没有数据,将其排在后面
if a["data"] == null and b["data"] != null:
return false
if a["data"] != null and b["data"] == null:
return true
# 如果都没有数据,按名称排序
return a["name"] < b["name"]
# 确保排序键存在于数据中
if !a["data"].has(current_sort_key) or !b["data"].has(current_sort_key):
print("警告: 排序键 ", current_sort_key, " 在某些种子数据中不存在")
return false
# 执行排序
if current_sort_ascending:
return a["data"][current_sort_key] < b["data"][current_sort_key]
else:
return a["data"][current_sort_key] > b["data"][current_sort_key]
# 按品质过滤种子
func _filter_by_quality(quality: String):
current_filter_quality = quality
update_player_bag_ui()
# 按指定键排序
func _sort_by(sort_key: String):
# 切换排序方向或设置新排序键
if current_sort_key == sort_key:
current_sort_ascending = !current_sort_ascending
else:
current_sort_key = sort_key
current_sort_ascending = true
update_player_bag_ui()
# 创建作物按钮
func _create_crop_button(crop_name: String, crop_quality: String) -> Button:
# 根据品质选择相应的进度条
var button = main_game.item_button.duplicate()
# 确保按钮可见并可点击
button.visible = true
button.disabled = false
button.focus_mode = Control.FOCUS_ALL
# 设置按钮文本
button.text = str(crop_quality + "-" + crop_name)
# 添加工具提示 (tooltip)
if main_game.can_planted_crop.has(crop_name):
var crop = main_game.can_planted_crop[crop_name]
# 将成熟时间从秒转换为天时分秒格式
var total_seconds = int(crop["生长时间"])
# 定义时间单位换算
var SECONDS_PER_MINUTE = 60
var SECONDS_PER_HOUR = 3600
var SECONDS_PER_DAY = 86400
# 计算各时间单位
var days = total_seconds / SECONDS_PER_DAY
total_seconds %= SECONDS_PER_DAY
var hours = total_seconds / SECONDS_PER_HOUR
total_seconds %= SECONDS_PER_HOUR
var minutes = total_seconds / SECONDS_PER_MINUTE
var seconds = total_seconds % SECONDS_PER_MINUTE
# 构建时间字符串(只显示有值的单位)
var time_str = ""
if days > 0:
time_str += str(days) + ""
if hours > 0:
time_str += str(hours) + "小时"
if minutes > 0:
time_str += str(minutes) + "分钟"
if seconds > 0:
time_str += str(seconds) + ""
button.tooltip_text = str(
"作物: " + crop_name + "\n" +
"品质: " + crop_quality + "\n" +
"价格: " + str(crop["花费"]) + "\n" +
"成熟时间: " + time_str + "\n" +
"收获收益: " + str(crop["收益"]) + "\n" +
"需求等级: " + str(crop["等级"]) + "\n" +
"耐候性: " + str(crop["耐候性"]) + "\n" +
"经验: " + str(crop["经验"]) + "\n" +
"描述: " + str(crop["描述"])
)
# 如果按钮有标题标签,设置标题
if button.has_node("Title"):
button.get_node("Title").text = crop_quality
match crop_quality:
"普通":
button.get_node("Title").modulate = Color.HONEYDEW#白色
"优良":
button.get_node("Title").modulate =Color.DODGER_BLUE#深蓝色
"稀有":
button.get_node("Title").modulate =Color.HOT_PINK#品红色
"史诗":
button.get_node("Title").modulate =Color.YELLOW#黄色
"传奇":
button.get_node("Title").modulate =Color.ORANGE_RED#红色
# 更新按钮的作物图片
_update_button_crop_image(button, crop_name)
return button
# 从背包中选择种子并种植
func _on_bag_seed_selected(crop_name):
# 检查是否处于访问模式
if main_game.is_visiting_mode:
Toast.show("访问模式下无法种植", Color.ORANGE, 2.0, 1.0)
return
# 检查是否是一键种植模式
if is_planting_mode:
# 一键种植模式下,回调给一键种植面板
if one_click_plant_panel and one_click_plant_panel.has_method("on_crop_selected"):
one_click_plant_panel.on_crop_selected(crop_name, planting_type)
# 退出种植模式
_exit_planting_mode()
self.hide()
return
# 从主场景获取当前选择的地块索引
selected_lot_index = main_game.selected_lot_index
if selected_lot_index != -1:
# 检查背包中是否有这个种子
var seed_index = -1
for i in range(len(main_game.player_bag)):
if main_game.player_bag[i]["name"] == crop_name:
seed_index = i
break
if seed_index != -1 and main_game.player_bag[seed_index]["count"] > 0:
# 种植种子并从背包中减少数量
_plant_crop_from_bag(selected_lot_index, crop_name, seed_index)
main_game.selected_lot_index = -1
self.hide()
# 访问模式下的种子点击处理
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)
# 从背包种植作物
func _plant_crop_from_bag(index, crop_name, seed_index):
var crop = main_game.can_planted_crop[crop_name]
# 检查是否有效的种子索引,防止越界访问
if seed_index < 0 or seed_index >= main_game.player_bag.size():
#print("错误:无效的种子索引 ", seed_index)
return
# 发送种植请求到服务器
if network_manager and network_manager.sendPlantCrop(index, crop_name):
# 关闭背包面板
hide()
# 设置种植模式
func set_planting_mode(plant_type: String, plant_panel):
is_planting_mode = true
planting_type = plant_type
one_click_plant_panel = plant_panel
print("进入种植模式:", plant_type)
# 退出种植模式
func _exit_planting_mode():
is_planting_mode = false
planting_type = ""
one_click_plant_panel = null
print("退出种植模式")
# 获取作物的成熟图片(用于背包显示)
func _get_crop_final_texture(crop_name: String) -> Texture2D:
# 优先从主游戏的缓存中获取成熟图片
if main_game and main_game.crop_mature_textures_cache.has(crop_name):
return main_game.crop_mature_textures_cache[crop_name]
# 如果缓存中没有,再尝试加载"成熟.webp"图片
var crop_path = "res://assets/作物/" + crop_name + "/"
var mature_texture_path = crop_path + "成熟.webp"
if ResourceLoader.exists(mature_texture_path):
var texture = load(mature_texture_path)
if texture:
print("背包加载作物成熟图片:", crop_name)
# 如果主游戏存在,也缓存到主游戏中
if main_game:
main_game.crop_mature_textures_cache[crop_name] = texture
return texture
# 如果没有找到作物的成熟图片,使用默认的成熟图片
if main_game and main_game.crop_mature_textures_cache.has("默认"):
var default_texture = main_game.crop_mature_textures_cache["默认"]
# 缓存给这个作物
main_game.crop_mature_textures_cache[crop_name] = default_texture
return default_texture
# 最后尝试直接加载默认成熟图片
var default_mature_path = "res://assets/作物/默认/成熟.webp"
if ResourceLoader.exists(default_mature_path):
var texture = load(default_mature_path)
if texture:
print("背包使用默认成熟图片:", crop_name)
# 缓存到主游戏
if main_game:
main_game.crop_mature_textures_cache["默认"] = texture
main_game.crop_mature_textures_cache[crop_name] = texture
return texture
return null
# 加载作物图片序列帧(复用主游戏的逻辑)
func _load_crop_textures(crop_name: String) -> Array:
if crop_textures_cache.has(crop_name):
return crop_textures_cache[crop_name]
var textures = []
var crop_path = "res://assets/作物/" + crop_name + "/"
var default_path = "res://assets/作物/默认/"
# 检查作物文件夹是否存在
if DirAccess.dir_exists_absolute(crop_path):
# 尝试加载作物的序列帧从0开始
var frame_index = 0
while true:
var texture_path = crop_path + str(frame_index) + ".webp"
if ResourceLoader.exists(texture_path):
var texture = load(texture_path)
if texture:
textures.append(texture)
frame_index += 1
else:
break
else:
break
if textures.size() > 0:
print("背包加载作物 ", crop_name, "", textures.size(), " 帧图片")
else:
print("背包:作物 ", crop_name, " 文件夹存在但没有找到有效图片,使用默认图片")
textures = _load_default_textures()
else:
print("背包:作物 ", crop_name, " 的文件夹不存在,使用默认图片")
textures = _load_default_textures()
# 缓存结果
crop_textures_cache[crop_name] = textures
crop_frame_counts[crop_name] = textures.size()
return textures
# 加载默认图片
func _load_default_textures() -> Array:
if crop_textures_cache.has("默认"):
return crop_textures_cache["默认"]
var textures = []
var default_path = "res://assets/作物/默认/"
# 尝试加载默认图片序列帧
var frame_index = 0
while true:
var texture_path = default_path + str(frame_index) + ".webp"
if ResourceLoader.exists(texture_path):
var texture = load(texture_path)
if texture:
textures.append(texture)
frame_index += 1
else:
break
else:
break
# 如果没有找到序列帧,尝试加载单个默认图片
if textures.size() == 0:
var single_texture_path = default_path + ".webp"
if ResourceLoader.exists(single_texture_path):
var texture = load(single_texture_path)
if texture:
textures.append(texture)
# 缓存默认图片
crop_textures_cache["默认"] = textures
crop_frame_counts["默认"] = textures.size()
print("背包加载了 ", textures.size(), " 个默认作物图片")
return textures
# 更新按钮的作物图片
func _update_button_crop_image(button: Button, crop_name: String):
# 检查按钮是否有CropImage节点
var crop_image = button.get_node_or_null("CropImage")
if not crop_image:
print("背包按钮没有找到CropImage节点", button.name)
return
# 获取作物的最后一帧图片
var texture = _get_crop_final_texture(crop_name)
if texture:
# CropImage是Sprite2D直接设置texture属性
crop_image.texture = texture
crop_image.visible = true
print("背包更新作物图片:", crop_name)
else:
crop_image.visible = false
print("背包无法获取作物图片:", crop_name)
#=========================面板通用处理=========================
#手动刷新种子仓库面板
func _on_refresh_button_pressed() -> void:
# 刷新种子背包UI
update_player_bag_ui()
Toast.show("种子背包已刷新", Color.GREEN, 2.0, 1.0)
# 关闭面板
func _on_quit_button_pressed():
#打开面板后暂时禁用相机功能
GlobalVariables.isZoomDisabled = false
# 退出种植模式(如果当前在种植模式下)
if is_planting_mode:
_exit_planting_mode()
self.hide()
#=========================面板通用处理=========================

View File

@@ -0,0 +1 @@
uid://cgr332wsx63a8

View File

@@ -0,0 +1,87 @@
[gd_scene load_steps=3 format=3 uid="uid://crd28qnymob7"]
[ext_resource type="Texture2D" uid="uid://dsln1w1aqgf1k" path="res://assets/游戏UI/玩家默认头像.webp" id="1_sgoxp"]
[ext_resource type="Script" uid="uid://0d2j5m6j2ema" path="res://Components/HTTPTextureRect.gd" id="2_ky0k8"]
[node name="player_ranking_item" type="VBoxContainer"]
offset_right = 1152.0
offset_bottom = 82.0
[node name="HBox" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="SerialNumber" type="Label" parent="HBox"]
visible = false
layout_mode = 2
theme_override_font_sizes/font_size = 30
text = "1."
[node name="PlayerAvatar" type="TextureRect" parent="HBox"]
layout_mode = 2
texture = ExtResource("1_sgoxp")
expand_mode = 3
script = ExtResource("2_ky0k8")
metadata/_custom_type_script = "uid://0d2j5m6j2ema"
[node name="PlayerName" type="Label" parent="HBox"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 30
text = "树萌芽"
[node name="PlayerMoney" type="Label" parent="HBox"]
modulate = Color(1, 1, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 30
text = "钱币999"
[node name="SeedNum" type="Label" parent="HBox"]
modulate = Color(0, 1, 0, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 30
text = "种子数999"
[node name="PlayerLevel" type="Label" parent="HBox"]
modulate = Color(0, 1, 1, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 30
text = "等级999"
[node name="VisitButton" type="Button" parent="HBox"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 30
text = "访问"
[node name="HBox2" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="LastLoginTime" type="Label" parent="HBox2"]
modulate = Color(0.811765, 1, 0.811765, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "最后在线2025年12时09分35秒"
[node name="OnlineTime" type="Label" parent="HBox2"]
modulate = Color(0.784314, 0.733333, 0.521569, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "累计在线时长99时60分60秒"
[node name="IsOnlineTime" type="Label" parent="HBox2"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "正在检测中..."
[node name="LikeNum" type="Label" parent="HBox2"]
modulate = Color(1, 0.611765, 1, 1)
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "点赞数999"

314
GUI/PlayerRankingPanel.gd Normal file
View File

@@ -0,0 +1,314 @@
extends Panel
@onready var player_ranking_list : VBoxContainer = $Scroll/PlayerList
@onready var refresh_button : Button = $RefreshButton #刷新玩家排行榜面板按钮
@onready var quit_button : Button = $QuitButton #关闭面板按钮
@onready var search_button: Button = $SearchButton #搜索玩家按钮
@onready var register_player_num: Label = $RegisterPlayerNum #显示注册总人数
#搜索玩家输入框通过输入QQ号来查询
@onready var search_line_edit: LineEdit = $SearchLineEdit
#排序筛选玩家面板按钮,默认按从大到小排序
#排序元素:种子数,等级,在线时长,最后登录时长,点赞数
#筛选元素:是否在线 筛选出在线玩家
@onready var seed_sort_btn: Button = $FiterAndSortHBox/SeedSortBtn
@onready var level_sort_btn: Button = $FiterAndSortHBox/LevelSortBtn
@onready var online_time_sort_btn: Button = $FiterAndSortHBox/OnlineTimeSortBtn
@onready var login_time_sort_btn: Button = $FiterAndSortHBox/LoginTimeSortBtn
@onready var like_num_sort_btn: Button = $FiterAndSortHBox/LikeNumSortBtn
@onready var money_sort_btn: Button = $FiterAndSortHBox/MoneySortBtn
@onready var is_online_sort_btn: Button = $FiterAndSortHBox/IsOnlineSortBtn
#预添加常用的面板
@onready var main_game = get_node("/root/main")
@onready var land_panel = get_node("/root/main/UI/LandPanel")
@onready var crop_store_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var player_ranking_panel = get_node("/root/main/UI/PlayerRankingPanel")
@onready var player_bag_panel = get_node("/root/main/UI/PlayerBagPanel")
@onready var network_manager = get_node("/root/main/UI/TCPNetworkManager")
# 排序状态管理
var current_sort_by = "level" # 当前排序字段
var current_sort_order = "desc" # 当前排序顺序
var filter_online_only = false # 是否只显示在线玩家
var current_search_qq = "" # 当前搜索的QQ号
#下面这是每个玩家要展示的信息直接获取服务器玩家数据json文件来实现
#模板用于复制创建新的玩家条目
@onready var player_info_template : VBoxContainer = $Scroll/PlayerList/player_ranking_item
func _ready() -> void:
# 隐藏模板
player_info_template.visible = false
# 连接按钮信号
refresh_button.pressed.connect(_on_refresh_button_pressed)
quit_button.pressed.connect(_on_quit_button_pressed)
search_button.pressed.connect(_on_search_button_pressed)
# 连接排序按钮信号
seed_sort_btn.pressed.connect(func(): _on_sort_button_pressed("seed_count"))
level_sort_btn.pressed.connect(func(): _on_sort_button_pressed("level"))
online_time_sort_btn.pressed.connect(func(): _on_sort_button_pressed("online_time"))
login_time_sort_btn.pressed.connect(func(): _on_sort_button_pressed("login_time"))
like_num_sort_btn.pressed.connect(func(): _on_sort_button_pressed("like_num"))
money_sort_btn.pressed.connect(func(): _on_sort_button_pressed("money"))
is_online_sort_btn.pressed.connect(_on_online_filter_pressed)
# 初始化按钮状态
_update_button_states()
# 排序按钮点击处理
func _on_sort_button_pressed(sort_field: String):
# 如果点击的是当前排序字段,切换排序顺序
if current_sort_by == sort_field:
current_sort_order = "asc" if current_sort_order == "desc" else "desc"
else:
# 切换到新的排序字段,默认降序
current_sort_by = sort_field
current_sort_order = "desc"
# 更新按钮状态
_update_button_states()
# 重新请求排行榜
request_player_rankings()
# 在线筛选按钮点击处理
func _on_online_filter_pressed():
filter_online_only = !filter_online_only
_update_button_states()
request_player_rankings()
# 更新按钮状态显示
func _update_button_states():
# 重置所有排序按钮
var sort_buttons = [seed_sort_btn, level_sort_btn, online_time_sort_btn, login_time_sort_btn, like_num_sort_btn, money_sort_btn]
var sort_fields = ["seed_count", "level", "online_time", "login_time", "like_num", "money"]
var sort_names = ["种子数", "等级", "游玩时间", "登录时间", "点赞数", "金币数"]
for i in range(sort_buttons.size()):
var btn = sort_buttons[i]
var field = sort_fields[i]
var name = sort_names[i]
if current_sort_by == field:
# 当前排序字段,显示排序方向
var arrow = "" if current_sort_order == "desc" else ""
btn.text = name + arrow
btn.modulate = Color.YELLOW
else:
# 非当前排序字段
btn.text = name
btn.modulate = Color.WHITE
# 更新在线筛选按钮
if filter_online_only:
is_online_sort_btn.text = "仅在线✓"
is_online_sort_btn.modulate = Color.GREEN
else:
is_online_sort_btn.text = "全部玩家"
is_online_sort_btn.modulate = Color.WHITE
# 请求玩家排行榜数据
func request_player_rankings():
if not network_manager:
register_player_num.text = "网络管理器不可用"
register_player_num.modulate = Color.RED
return false
if not network_manager.is_connected_to_server():
register_player_num.text = "未连接服务器"
register_player_num.modulate = Color.RED
return false
var success = network_manager.sendGetPlayerRankings(current_sort_by, current_sort_order, filter_online_only, current_search_qq)
if not success:
register_player_num.text = "请求发送失败"
register_player_num.modulate = Color.RED
return false
return true
# 处理玩家排行榜响应
func handle_player_rankings_response(data):
# 重新启用刷新按钮
refresh_button.disabled = false
refresh_button.text = "刷新"
# 检查响应是否成功
if not data.get("success", false):
register_player_num.text = "获取注册人数失败"
register_player_num.modulate = Color.RED
Toast.show("获取排行榜失败:" + data.get("message", "未知错误"), Color.RED)
return
# 显示注册总人数和在线人数
var total_registered = data.get("total_registered_players", 0)
var players_list = data.get("players", [])
var online_count = 0
for player in players_list:
if player.get("is_online", false):
online_count += 1
# 显示搜索和筛选信息
var info_text = "总人数:" + str(int(total_registered)) + "| 在线:" + str(online_count)
if current_search_qq != "":
info_text += "| 搜索:" + current_search_qq
if filter_online_only:
info_text += "| 仅在线"
register_player_num.text = info_text
register_player_num.modulate = Color.CYAN
# 清除现有的玩家条目(除了模板)
for child in player_ranking_list.get_children():
if child != player_info_template:
child.queue_free()
# 添加玩家条目
var players = players_list
for player_data in players:
add_player_entry(player_data)
print("排行榜数据已更新,显示", players.size(), "个玩家,注册总人数:", total_registered)
var result_text = "排行榜已刷新!显示 " + str(players.size()) + " 个玩家"
if current_search_qq != "":
result_text += "(搜索:" + current_search_qq + ""
if filter_online_only:
result_text += "(仅在线)"
Toast.show(result_text, Color.GREEN)
# 添加单个玩家条目
func add_player_entry(player_data):
# 复制模板
var player_entry = player_info_template.duplicate()
player_entry.visible = true
player_ranking_list.add_child(player_entry)
# 设置玩家信息
var player_name = player_entry.get_node("HBox/PlayerName")
var player_level = player_entry.get_node("HBox/PlayerLevel")
var player_money = player_entry.get_node("HBox/PlayerMoney")
var player_seed_num = player_entry.get_node("HBox/SeedNum")
var player_online_time = player_entry.get_node("HBox2/OnlineTime")
var player_last_login_time = player_entry.get_node("HBox2/LastLoginTime")
var player_avatar = player_entry.get_node("HBox/PlayerAvatar")
var visit_button = player_entry.get_node("HBox/VisitButton")
var player_is_online_time = player_entry.get_node("HBox2/IsOnlineTime")
var player_like_num = player_entry.get_node("HBox2/LikeNum")
# 填充数据
var username = player_data.get("user_name", "未知")
var display_name = player_data.get("player_name", username)
player_name.text = display_name
#都是整数,不要乱用浮点数
player_level.text = "等级: " + str(int(player_data.get("level", 0)))
player_money.text = "金币: " + str(int(player_data.get("money", 0)))
player_seed_num.text = "种子: " + str(int(player_data.get("seed_count", 0)))
player_online_time.text = "游玩时间: " + player_data.get("total_login_time", "0时0分0秒")
player_last_login_time.text = "最后登录: " + player_data.get("last_login_time", "未知")
# 设置在线状态显示
var is_online = player_data.get("is_online", false)
if is_online:
player_is_online_time.text = "🟢 在线"
player_is_online_time.modulate = Color.GREEN
else:
player_is_online_time.text = "🔴 离线"
player_is_online_time.modulate = Color.GRAY
# 设置点赞数显示
player_like_num.text = "点赞: " + str(int(player_data.get("like_num", 0)))
# 尝试加载玩家头像(使用用户名/QQ号加载头像而不是显示名
if username.is_valid_int():
player_avatar.load_from_url("http://q1.qlogo.cn/g?b=qq&nk=" + username + "&s=100")
# 设置访问按钮
visit_button.pressed.connect(func(): _on_visit_player_pressed(username))
# 访问玩家按钮点击
func _on_visit_player_pressed(username):
#访问玩家后取消禁用相机功能,否则无法恢复
GlobalVariables.isZoomDisabled = false
# 检查网络连接
if not network_manager or not network_manager.is_connected_to_server():
Toast.show("未连接服务器,无法访问玩家", Color.RED)
return
# 检查是否尝试访问自己
if main_game and main_game.user_name == username:
Toast.show("不能访问自己的农场", Color.ORANGE)
return
# 发送访问玩家请求
if network_manager and network_manager.has_method("sendVisitPlayer"):
var success = network_manager.sendVisitPlayer(username)
if success:
Toast.show("正在访问 " + username + " 的农场...", Color.YELLOW)
else:
Toast.show("发送访问请求失败", Color.RED)
else:
Toast.show("网络管理器不可用", Color.RED)
# 刷新按钮点击
func _on_refresh_button_pressed():
# 检查网络连接
if not network_manager or not network_manager.is_connected_to_server():
register_player_num.text = "未连接服务器,无法刷新"
register_player_num.modulate = Color.RED
Toast.show("未连接服务器,无法刷新排行榜", Color.RED)
return
# 显示加载状态
register_player_num.text = "正在刷新排行榜..."
register_player_num.modulate = Color.YELLOW
refresh_button.disabled = true
refresh_button.text = "刷新中..."
# 请求排行榜数据
request_player_rankings()
# 5秒后重新启用按钮防止卡住
await get_tree().create_timer(5.0).timeout
if refresh_button.disabled:
refresh_button.disabled = false
refresh_button.text = "刷新"
if register_player_num.text == "正在刷新排行榜...":
register_player_num.text = "刷新超时,请重试"
register_player_num.modulate = Color.RED
# 退出按钮点击
func _on_quit_button_pressed():
#打开面板后暂时禁用相机功能
GlobalVariables.isZoomDisabled = false
self.hide()
#搜索按钮点击 - 通过QQ号查询玩家
func _on_search_button_pressed():
var search_text = search_line_edit.text.strip_edges()
# 如果搜索框为空,清除搜索条件
if search_text == "":
current_search_qq = ""
Toast.show("已清除搜索条件", Color.YELLOW)
else:
# 验证输入是否为数字QQ号
if not search_text.is_valid_int():
Toast.show("请输入有效的QQ号纯数字", Color.RED)
return
current_search_qq = search_text
Toast.show("搜索QQ号" + search_text, Color.YELLOW)
# 重新请求排行榜
request_player_rankings()

View File

@@ -0,0 +1 @@
uid://fk4q3x6uqydd

190
GUI/loginPanel.tscn Normal file
View File

@@ -0,0 +1,190 @@
[gd_scene load_steps=2 format=3 uid="uid://cbhitturvihqj"]
[ext_resource type="Script" uid="uid://cka0r4g8tbf0" path="res://GUI/LoginPanel.gd" id="1_xnwaq"]
[node name="LoginPanel" type="PanelContainer"]
offset_left = 449.0
offset_top = 77.0
offset_right = 952.0
offset_bottom = 550.0
script = ExtResource("1_xnwaq")
[node name="VBox" type="VBoxContainer" parent="."]
layout_mode = 2
[node name="Title" type="Label" parent="VBox"]
modulate = Color(1, 1, 0.537255, 1)
layout_mode = 2
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/shadow_offset_x = 5
theme_override_constants/shadow_offset_y = 5
theme_override_constants/outline_size = 15
theme_override_constants/shadow_outline_size = 15
theme_override_font_sizes/font_size = 30
text = "登录/注册面板"
horizontal_alignment = 1
vertical_alignment = 1
[node name="UserName" type="HBoxContainer" parent="VBox"]
layout_mode = 2
[node name="Label" type="Label" parent="VBox/UserName"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "账号"
horizontal_alignment = 1
vertical_alignment = 1
[node name="username_input" type="LineEdit" parent="VBox/UserName"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
placeholder_text = "请输入QQ号"
metadata/_edit_use_anchors_ = true
[node name="Password1" type="HBoxContainer" parent="VBox"]
layout_mode = 2
[node name="Label2" type="Label" parent="VBox/Password1"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "密码"
horizontal_alignment = 1
vertical_alignment = 1
[node name="password_input" type="LineEdit" parent="VBox/Password1"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
placeholder_text = "请输入密码"
[node name="Password2" type="HBoxContainer" parent="VBox"]
visible = false
layout_mode = 2
[node name="Label2" type="Label" parent="VBox/Password2"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "确认密码"
horizontal_alignment = 1
vertical_alignment = 1
[node name="password_input2" type="LineEdit" parent="VBox/Password2"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
placeholder_text = "请再次输入密码"
[node name="VerificationCode" type="HBoxContainer" parent="VBox"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="VBox/VerificationCode"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "验证码"
horizontal_alignment = 1
vertical_alignment = 1
[node name="verificationcode_input" type="LineEdit" parent="VBox/VerificationCode"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
placeholder_text = "请输入您的QQ邮箱收到的验证码"
metadata/_edit_use_anchors_ = true
[node name="SendButton" type="Button" parent="VBox/VerificationCode"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "发送验证码"
[node name="PlayerName" type="HBoxContainer" parent="VBox"]
visible = false
layout_mode = 2
[node name="Label2" type="Label" parent="VBox/PlayerName"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "玩家昵称"
horizontal_alignment = 1
vertical_alignment = 1
[node name="playername_input" type="LineEdit" parent="VBox/PlayerName"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
placeholder_text = "请输入您的玩家昵称"
[node name="FarmName" type="HBoxContainer" parent="VBox"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="VBox/FarmName"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "农场名称"
horizontal_alignment = 1
vertical_alignment = 1
[node name="farmname_input" type="LineEdit" parent="VBox/FarmName"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
placeholder_text = "请输入您的农场名称"
metadata/_edit_use_anchors_ = true
[node name="LoginRegister" type="HBoxContainer" parent="VBox"]
layout_mode = 2
[node name="login_button" type="Button" parent="VBox/LoginRegister"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "登录"
[node name="register_button" type="Button" parent="VBox/LoginRegister"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "注册"
[node name="Password3" type="HBoxContainer" parent="VBox"]
visible = false
layout_mode = 2
[node name="login_button" type="Button" parent="VBox/Password3"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "发送验证码"
[node name="Label2" type="Label" parent="VBox/Password3"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "找回密码"
horizontal_alignment = 1
vertical_alignment = 1
[node name="password_input2" type="LineEdit" parent="VBox/Password3"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
placeholder_text = "请输入QQ邮箱验证码"
[node name="Note" type="Label" parent="VBox"]
modulate = Color(1, 0.552941, 1, 1)
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "注意:首次游玩游戏需要注册账号,
账号请直接输入您的QQ号系统会直接向您的QQ
邮箱发送一串验证码进行注册验证,密码请设置的复杂一
点,以免被暴力破解("
horizontal_alignment = 1
vertical_alignment = 1
[node name="status_label" type="Label" parent="VBox"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "连接状态"
horizontal_alignment = 1

142
GameCamera2D.gd Normal file
View File

@@ -0,0 +1,142 @@
extends Camera2D
# 相机移动速度
@export var move_speed: float = 400.0 # 每秒移动的像素数
@export var zoom_speed: float = 0.02 # 缩放速度
@export var min_zoom: float = 0.7 # 最小缩放值
@export var max_zoom: float = 1.2 # 最大缩放值
# 移动端触摸设置
@export var touch_sensitivity: float = 1.0 # 触摸灵敏度
@export var enable_touch_zoom: bool = true # 是否启用双指缩放
# 移动边界(可选)
@export var bounds_enabled: bool = false
@export var bounds_min: Vector2 = Vector2(-1000, -1000)
@export var bounds_max: Vector2 = Vector2(1000, 1000)
@export var current_zoom_level: float = 1.0
# 触摸相关变量
var is_dragging: bool = false
var last_touch_position: Vector2
var touch_points: Dictionary = {} # 存储多点触摸信息
var initial_zoom_distance: float = 0.0
func _ready():
# 初始化相机
zoom = Vector2(current_zoom_level, current_zoom_level)
func _process(delta):
#其他地方可通过这个方法来禁用相机功能
if GlobalVariables.isZoomDisabled == true:
return
# 处理相机移动
var input_dir = Vector2.ZERO
# WASD 键移动
if Input.is_action_pressed("ui_up") or Input.is_key_pressed(KEY_W):
input_dir.y -= 1
if Input.is_action_pressed("ui_down") or Input.is_key_pressed(KEY_S):
input_dir.y += 1
if Input.is_action_pressed("ui_left") or Input.is_key_pressed(KEY_A):
input_dir.x -= 1
if Input.is_action_pressed("ui_right") or Input.is_key_pressed(KEY_D):
input_dir.x += 1
# 归一化移动向量,确保对角线移动不会更快
if input_dir.length() > 0:
input_dir = input_dir.normalized()
# 相机移动
position += input_dir * move_speed * delta / current_zoom_level
# 如果启用了边界限制,确保相机在边界内
if bounds_enabled:
position.x = clamp(position.x, bounds_min.x, bounds_max.x)
position.y = clamp(position.y, bounds_min.y, bounds_max.y)
# 处理相机缩放KEY_EQUAL
if Input.is_key_pressed(KEY_EQUAL) or Input.is_key_pressed(KEY_KP_ADD): # + 键放大
zoom_camera(-zoom_speed)
if Input.is_key_pressed(KEY_MINUS) or Input.is_key_pressed(KEY_KP_SUBTRACT): # - 键缩小
zoom_camera(zoom_speed)
# 处理输入事件(包括触摸和鼠标)
func _input(event):
#其他地方可通过这个方法来禁用相机功能
if GlobalVariables.isZoomDisabled == true:
return
# 鼠标滚轮缩放
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
zoom_camera(-zoom_speed)
elif event.button_index == MOUSE_BUTTON_WHEEL_UP:
zoom_camera(zoom_speed)
# 触摸开始
elif event is InputEventScreenTouch:
if event.pressed:
# 记录触摸点
touch_points[event.index] = event.position
if len(touch_points) == 1:
# 单指触摸,开始拖动
is_dragging = true
last_touch_position = event.position
elif len(touch_points) == 2 and enable_touch_zoom:
# 双指触摸,准备缩放
is_dragging = false
var touches = touch_points.values()
initial_zoom_distance = touches[0].distance_to(touches[1])
else:
# 触摸结束
if touch_points.has(event.index):
touch_points.erase(event.index)
if len(touch_points) == 0:
is_dragging = false
elif len(touch_points) == 1:
# 从双指回到单指,重新开始拖动
is_dragging = true
last_touch_position = touch_points.values()[0]
# 触摸拖动
elif event is InputEventScreenDrag:
if touch_points.has(event.index):
touch_points[event.index] = event.position
if len(touch_points) == 1 and is_dragging:
# 单指拖动,移动相机
var drag_delta = last_touch_position - event.position
# 根据当前缩放级别调整移动距离
position += drag_delta * touch_sensitivity / current_zoom_level
# 应用边界限制
if bounds_enabled:
position.x = clamp(position.x, bounds_min.x, bounds_max.x)
position.y = clamp(position.y, bounds_min.y, bounds_max.y)
last_touch_position = event.position
elif len(touch_points) == 2 and enable_touch_zoom:
# 双指缩放
var touches = touch_points.values()
var current_distance = touches[0].distance_to(touches[1])
if initial_zoom_distance > 0:
var zoom_factor = current_distance / initial_zoom_distance
var zoom_change = (zoom_factor - 1.0) * zoom_speed * 10
zoom_camera(zoom_change)
initial_zoom_distance = current_distance
# 缩放相机
func zoom_camera(zoom_amount):
current_zoom_level = clamp(current_zoom_level + zoom_amount, min_zoom, max_zoom)
zoom = Vector2(current_zoom_level, current_zoom_level)

1
GameCamera2D.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://c7bxje0wvvgo4

View File

@@ -1,3 +1,5 @@
extends Node
const client_version :String = "1.0.3" #记录客户端版本
const client_version :String = "1.0.5" #记录客户端版本
var isZoomDisabled :bool = false

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -17,10 +17,10 @@ var client: TCPClient = TCPClient.new()
# 服务器配置 - 支持多个服务器地址
var server_configs = [
#{"host": "127.0.0.1", "port": 4040, "name": "本地"},
{"host": "127.0.0.1", "port": 4040, "name": "本地"},
#{"host": "192.168.1.110", "port": 4040, "name": "局域网"},
#{"host": "47.108.90.0", "port": 4040, "name": "成都内网穿透"}#成都内网穿透
{"host": "47.108.90.0", "port": 6060, "name": "成都公网"}#成都服务器
#{"host": "47.108.90.0", "port": 6060, "name": "成都公网"}#成都服务器
]
var current_server_index = 0
@@ -39,6 +39,7 @@ var ping_interval = 3.0 # 每3秒ping一次
var ping_timeout = 5.0 # ping超时时间
var is_measuring_ping = false
#=====================================网络连接基本处理=========================================
func _ready():
# 创建TCP客户端实例
self.add_child(client)
@@ -70,16 +71,16 @@ func _process(delta):
if is_trying_to_connect:
var elapsed_time = Time.get_unix_time_from_system() - connection_start_time
if elapsed_time > connection_timeout:
print("连接超时,尝试下一个服务器")
is_trying_to_connect = false
client.disconnect_from_server()
if auto_retry and not has_tried_all_servers:
try_next_server()
else:
status_label.text = "服务器连接失败"
status_label.text = "连接超时"
status_label.modulate = Color.RED
has_tried_all_servers = false # 重置标志,允许下次重试
connection_button.text = "连接"
# 通知主游戏更新在线人数显示
if main_game and main_game.has_method("_update_online_players_display"):
main_game._update_online_players_display(0, false, false)
# 处理延迟测量
if client.is_client_connected():
@@ -92,7 +93,6 @@ func _process(delta):
if is_measuring_ping:
var ping_elapsed = Time.get_unix_time_from_system() - ping_start_time
if ping_elapsed > ping_timeout:
print("Ping超时重置测量状态")
is_measuring_ping = false
current_ping = 999 # 显示为高延迟
@@ -109,7 +109,7 @@ func _process(delta):
func _on_connected():
print("成功连接到服务器: ", server_configs[current_server_index]["name"])
status_label.text = "已连接 测量中..."
status_label.text = "已连接 ..."
status_label.modulate = Color.GREEN
connection_button.text = "断开"
is_trying_to_connect = false
@@ -127,11 +127,9 @@ func _on_connected():
})
# 连接成功后立即请求作物数据
print("连接成功,正在请求最新作物数据...")
sendGetCropData()
# 连接成功后立即请求在线人数
print("连接成功,正在请求在线人数...")
sendGetOnlinePlayers()
# 立即开始第一次ping测量
@@ -150,12 +148,8 @@ func _on_connection_failed():
ping_timer = 0.0
# 通知主游戏更新在线人数显示
if main_game and main_game.has_method("_update_online_players_display"):
main_game._update_online_players_display(0, false, false)
# 自动尝试下一个服务器
if auto_retry:
try_next_server()
func _on_connection_closed():
print("连接断开: ", server_configs[current_server_index]["name"])
@@ -173,15 +167,11 @@ func _on_connection_closed():
if main_game and main_game.has_method("_update_online_players_display"):
main_game._update_online_players_display(0, false, false)
# 自动重连,优先尝试其他服务器
if auto_retry:
print("连接断开,准备重连...")
var timer = get_tree().create_timer(retry_delay)
await timer.timeout
if not client.is_client_connected():
# 先尝试下一个服务器,如果所有服务器都失败了再回到当前服务器
try_next_server()
# 通知主游戏连接已断开,显示登录面板
main_game._on_connection_lost()
#=========================客户端与服务端通信核心=========================================
func _on_data_received(data):
# 根据数据类型处理数据
response_label.text = "收到: %s" % JSON.stringify(data)
@@ -194,9 +184,6 @@ func _on_data_received(data):
match message_type:
"ping": #ping是否在线
return
"pong": #服务器回复pong响应
handle_pong_response()
return
"response": #服务器通用响应
return
"login_response": #登录响应
@@ -243,9 +230,14 @@ func _on_data_received(data):
main_game.level = updated_data["level"]
if updated_data.has("体力值"):
main_game.stamina = updated_data["体力值"]
if updated_data.has("作物仓库"):
main_game.crop_warehouse = updated_data["作物仓库"]
# 更新UI
main_game._update_ui()
# 更新作物仓库UI
if main_game.crop_warehouse_panel:
main_game.crop_warehouse_panel.update_crop_warehouse_ui()
Toast.show(message, Color.GREEN)
else:
Toast.show(message, Color.RED)
@@ -274,18 +266,75 @@ func _on_data_received(data):
Toast.show(message, Color.GREEN)
else:
Toast.show(message, Color.RED)
"buy_item":#处理购买道具响应
if success:
# 更新玩家数据
if updated_data.has("money"):
main_game.money = updated_data["money"]
if updated_data.has("道具背包"):
main_game.item_bag = updated_data["道具背包"]
# 更新UI
main_game._update_ui()
if main_game.item_bag_panel:
main_game.item_bag_panel.update_item_bag_ui()
Toast.show(message, Color.GREEN)
else:
Toast.show(message, Color.RED)
"use_item":#处理使用道具响应
print("调试:收到道具使用响应")
print(" - success: ", success)
print(" - message: ", message)
print(" - updated_data: ", updated_data)
if success:
print("调试:道具使用成功,开始更新数据")
# 更新玩家数据
if updated_data.has("道具背包"):
main_game.item_bag = updated_data["道具背包"]
print("调试:更新道具背包")
if updated_data.has("farm_lots"):
print("调试:更新地块数据")
main_game.farm_lots = updated_data["farm_lots"]
if updated_data.has("experience"):
main_game.experience = updated_data["experience"]
print("调试:更新经验值: ", main_game.experience)
if updated_data.has("level"):
main_game.level = updated_data["level"]
print("调试:更新等级: ", main_game.level)
# 更新UI
print("调试开始更新UI")
main_game._update_ui()
main_game._update_farm_lots_state()
if main_game.item_bag_panel:
main_game.item_bag_panel.update_item_bag_ui()
print("调试UI更新完成")
Toast.show(message, Color.GREEN)
else:
print("错误:道具使用失败: ", message)
Toast.show(message, Color.RED)
"dig_ground":#处理开垦土地
if success:
# 更新玩家数据
if updated_data.has("money"):
main_game.money = updated_data["money"]
if updated_data.has("experience"):
main_game.experience = updated_data["experience"]
if updated_data.has("level"):
main_game.level = updated_data["level"]
if updated_data.has("farm_lots"):
main_game.farm_lots = updated_data["farm_lots"]
if updated_data.has("player_bag"):
main_game.player_bag = updated_data["player_bag"]
# 更新UI
main_game._update_ui()
main_game._update_farm_lots_state()
Toast.show(message, Color.GREEN)
# 更新背包UI
if main_game.player_bag_panel:
main_game.player_bag_panel.update_player_bag_ui()
Toast.show(message, Color.GREEN, 3.0, 1.0)
else:
Toast.show(message, Color.RED)
"remove_crop":#处理铲除作物
@@ -309,8 +358,10 @@ func _on_data_received(data):
main_game.money = updated_data["money"]
if updated_data.has("farm_lots"):
main_game.farm_lots = updated_data["farm_lots"]
if updated_data.has("体力值"):
main_game.stamina = updated_data["体力值"]
if updated_data.has("experience"):
main_game.experience = updated_data["experience"]
if updated_data.has("level"):
main_game.level = updated_data["level"]
# 更新UI
main_game._update_ui()
@@ -325,8 +376,10 @@ func _on_data_received(data):
main_game.money = updated_data["money"]
if updated_data.has("farm_lots"):
main_game.farm_lots = updated_data["farm_lots"]
if updated_data.has("体力值"):
main_game.stamina = updated_data["体力值"]
if updated_data.has("experience"):
main_game.experience = updated_data["experience"]
if updated_data.has("level"):
main_game.level = updated_data["level"]
# 更新UI
main_game._update_ui()
@@ -396,15 +449,38 @@ func _on_data_received(data):
"new_player_gift_response": #新手大礼包响应
if main_game and main_game.has_method("_handle_new_player_gift_response"):
main_game._handle_new_player_gift_response(data)
"online_gift_data_response": #在线礼包数据响应
if main_game and main_game.has_method("_handle_online_gift_data_response"):
main_game._handle_online_gift_data_response(data)
"claim_online_gift_response": #领取在线礼包响应
if main_game and main_game.has_method("_handle_claim_online_gift_response"):
main_game._handle_claim_online_gift_response(data)
"pong": #延迟检测响应
handle_pong_response(data)
"modify_account_info_response": #修改账号信息响应
if main_game and main_game.has_method("_handle_account_setting_response"):
main_game._handle_account_setting_response(data)
"delete_account_response": #删除账号响应
if main_game and main_game.has_method("_handle_account_setting_response"):
main_game._handle_account_setting_response(data)
"refresh_player_info_response": #刷新玩家信息响应
if main_game and main_game.has_method("_handle_account_setting_response"):
main_game._handle_account_setting_response(data)
_:
# 显示其他类型的消息
return
_:
# 处理非JSON数据
return
#=========================客户端与服务端通信核心=========================================
#=====================================网络连接基本处理=========================================
#=====================================网络操作处理=========================================
func _on_connection_button_pressed():
if client.is_client_connected():
# 断开连接
@@ -431,7 +507,7 @@ func connect_to_current_server():
connection_start_time = Time.get_unix_time_from_system()
client.connect_to_server(config["host"], config["port"])
#手动发送消息处理
func _on_send_button_pressed():
if not client.is_client_connected():
status_label.text = "未连接,无法发送"
@@ -451,7 +527,10 @@ func _on_send_button_pressed():
# 清空输入
message_input.text = ""
#=====================================网络操作处理=========================================
#=====================================客户端向服务端发送消息处理=========================================
#发送登录信息
func sendLoginInfo(username, password):
client.send_data({
@@ -535,6 +614,36 @@ func sendBuySeed(crop_name):
})
return true
#发送购买道具信息
func sendBuyItem(item_name, item_cost):
if not client.is_client_connected():
return false
client.send_data({
"type": "buy_item",
"item_name": item_name,
"item_cost": item_cost,
"timestamp": Time.get_unix_time_from_system()
})
return true
#发送使用道具信息
func sendUseItem(lot_index, item_name, use_type, target_username = ""):
if not client.is_client_connected():
print("错误:客户端未连接")
return false
var message = {
"type": "use_item",
"lot_index": lot_index,
"item_name": item_name,
"use_type": use_type,
"target_username": target_username,
"timestamp": Time.get_unix_time_from_system()
}
client.send_data(message)
return true
#发送获取游玩时间请求
func sendGetPlayTime():
if not client.is_client_connected():
@@ -556,12 +665,16 @@ func sendUpdatePlayTime():
return true
#发送获取玩家排行榜请求
func sendGetPlayerRankings():
func sendGetPlayerRankings(sort_by = "level", sort_order = "desc", filter_online = false, search_qq = ""):
if not client.is_client_connected():
return false
client.send_data({
"type": "request_player_rankings"
"type": "request_player_rankings",
"sort_by": sort_by,
"sort_order": sort_order,
"filter_online": filter_online,
"search_qq": search_qq
})
return true
@@ -740,40 +853,41 @@ func sendClaimNewPlayerGift():
})
return true
#发送获取在线礼包数据请求
func sendGetOnlineGiftData():
if not client.is_client_connected():
return false
client.send_data({
"type": "get_online_gift_data",
"timestamp": Time.get_unix_time_from_system()
})
return true
#发送领取在线礼包请求
func sendClaimOnlineGift(gift_name: String):
if not client.is_client_connected():
return false
client.send_data({
"type": "claim_online_gift",
"gift_name": gift_name,
"timestamp": Time.get_unix_time_from_system()
})
return true
#检查是否连接到服务器
func is_connected_to_server():
return client.is_client_connected()
# 尝试连接下一个服务器
func try_next_server():
var original_index = current_server_index
current_server_index = (current_server_index + 1) % server_configs.size()
# 如果回到了原始服务器,说明所有服务器都尝试过了
if current_server_index == original_index:
if has_tried_all_servers:
print("=== 所有服务器连接失败 ===")
print("已尝试所有 ", server_configs.size(), " 个服务器")
for i in range(server_configs.size()):
print("- ", server_configs[i]["name"], " (", server_configs[i]["host"], ":", server_configs[i]["port"], ")")
status_label.text = "所有服务器连接失败"
status_label.modulate = Color.RED
is_trying_to_connect = false
return
else:
has_tried_all_servers = true
var config = server_configs[current_server_index]
print("=== 切换到下一个服务器 ===")
print("", server_configs[original_index]["name"], " 切换到 ", config["name"])
print("新服务器地址: ", config["host"], ":", config["port"])
var timer = get_tree().create_timer(1.0) # 稍微缩短等待时间
await timer.timeout
#发送通用消息
func send_message(message: Dictionary):
if not client.is_client_connected():
connect_to_current_server()
return false
client.send_data(message)
return true
# 手动切换到指定服务器
func switch_to_server(server_index: int):
@@ -815,13 +929,16 @@ func send_ping():
"timestamp": ping_start_time
})
#=====================================客户端向服务端发送消息处理=========================================
# 处理服务器返回的pong消息
func handle_pong_response(data = null):
if is_measuring_ping:
var current_time = Time.get_unix_time_from_system()
current_ping = int((current_time - ping_start_time) * 1000) # 转换为毫秒
is_measuring_ping = false
print("延迟: ", current_ping, "ms")
#print("延迟: ", current_ping, "ms")
# 更新连接状态显示
update_connection_status()
@@ -834,13 +951,13 @@ func update_connection_status():
var ping_text = str(current_ping) + "ms"
var server_name = server_configs[current_server_index]["name"]
if current_ping < 30:
if current_ping < 100:
status_label.text = "" + server_name + " " + ping_text
status_label.modulate = Color.GREEN
elif current_ping < 80:
elif current_ping < 150:
status_label.text = "🟡 " + server_name + " " + ping_text
status_label.modulate = Color.YELLOW
elif current_ping < 150:
elif current_ping < 300:
status_label.text = "🟠 " + server_name + " " + ping_text
status_label.modulate = Color.ORANGE
else:
@@ -848,7 +965,7 @@ func update_connection_status():
status_label.modulate = Color.RED
else:
var server_name = server_configs[current_server_index]["name"]
status_label.text = "🔄 " + server_name + " 测量中..."
status_label.text = "🔄 " + server_name + "..."
status_label.modulate = Color.CYAN
else:
status_label.text = "❌ 未连接"

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,35 @@
{
"测试作物": {"花费": 1, "生长时间": 5, "收益": 10000, "品质": "普通", "描述": "仅供测试使用的特殊作物", "耐候性": 10, "等级": 1, "经验": 999, "能否购买": false},
"野草1": {"花费": 0, "生长时间": 5, "收益": -110, "品质": "普通", "描述": "野草", "耐候性": 99, "等级": 1, "经验": 0, "能否购买": true,"是否杂草":true},
"野草2": {"花费": 0, "生长时间": 5, "收益": -200, "品质": "普通", "描述": "野草", "耐候性": 99, "等级": 1, "经验": 0, "能否购买": true,"是否杂草":true},
"杂草1": {"花费": 0, "生长时间": 5, "收益": -150, "品质": "普通", "描述": "杂草", "耐候性": 99, "等级": 1, "经验": 0, "能否购买": true,"是否杂草":true},
"杂草2": {"花费": 0, "生长时间": 5, "收益": -90, "品质": "普通", "描述": "野草", "耐候性": 99, "等级": 1, "经验": 0, "能否购买": true,"是否杂草":true},
"小麦": {"花费": 50, "生长时间": 300, "收益": 75, "品质": "普通", "描述": "最基础的粮食作物,生长快速,适合新手练习", "耐候性": 8, "等级": 1, "经验": 8, "能否购买": true},
"胡萝卜": {"花费": 40, "生长时间": 240, "收益": 65, "品质": "普通", "描述": "营养丰富的根茎类蔬菜,容易种植", "耐候性": 9, "等级": 1, "经验": 7, "能否购买": true},
"土豆": {"花费": 60, "生长时间": 480, "收益": 95, "品质": "普通", "描述": "耐寒的块茎作物,产量稳定", "耐候性": 12, "等级": 1, "经验": 10, "能否购买": true},
"稻谷": {"花费": 70, "生长时间": 600, "收益": 110, "品质": "普通", "描述": "重要的主粮作物,需要充足水分", "耐候性": 7, "等级": 1, "经验": 12, "能否购买": true},
"大蒜": {"花费": 50, "生长时间": 550, "收益": 100, "品质": "普通", "描述": "常用调味作物,具有抗菌功效,种植门槛低", "耐候性": 10, "等级": 1, "经验": 8, "能否购买": true},
"生菜": {"花费": 45, "生长时间": 650, "收益": 120, "品质": "普通", "描述": "速生叶菜,适合沙拉生食,需保持土壤湿润", "耐候性": 17, "等级": 1, "经验": 9, "能否购买": true},
"石榴": {"花费": 45, "生长时间": 650, "收益": 120, "品质": "普通", "描述": "速生叶菜,适合沙拉生食,需保持土壤湿润", "耐候性": 17, "等级": 1, "经验": 9, "能否购买": true},
"辣椒": {"花费": 45, "生长时间": 650, "收益": 120, "品质": "普通", "描述": "速生叶菜,适合沙拉生食,需保持土壤湿润", "耐候性": 17, "等级": 1, "经验": 9, "能否购买": true},
"玉米": {"花费": 80, "生长时间": 900, "收益": 130, "品质": "优良", "描述": "高产的谷物作物,营养价值高", "耐候性": 10, "等级": 2, "经验": 15, "能否购买": true},
"番茄": {"花费": 90, "生长时间": 720, "收益": 140, "品质": "优良", "描述": "多汁的果实,市场需求大", "耐候性": 8, "等级": 2, "经验": 16, "能否购买": true},
"洋葱": {"花费": 75, "生长时间": 840, "收益": 125, "品质": "优良", "描述": "调味蔬菜,储存时间长", "耐候性": 11, "等级": 2, "经验": 14, "能否购买": true},
"葫芦": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"柠檬": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"枇杷": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"牵牛花": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"山楂": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"仙人掌": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"杨桃": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"椰子": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"大豆": {"花费": 85, "生长时间": 1080, "收益": 145, "品质": "优良", "描述": "富含蛋白质的豆类作物", "耐候性": 9, "等级": 2, "经验": 18, "能否购买": true},
"迷迭香": {"花费": 100, "生长时间": 1680, "收益": 210, "品质": "稀有", "描述": "芳香型草本植物,可用于烹饪和精油提取,耐旱易存活", "耐候性": 12, "等级": 3, "经验": 22, "能否购买": true},
"草莓": {"花费": 120, "生长时间": 1440, "收益": 200, "品质": "稀有", "描述": "甜美的浆果,深受喜爱", "耐候性": 6, "等级": 3, "经验": 22, "能否购买": true},
"花椰菜": {"花费": 110, "生长时间": 1320, "收益": 185, "品质": "稀有", "描述": "营养丰富的十字花科蔬菜", "耐候性": 8, "等级": 3, "经验": 20, "能否购买": true},
"柿子": {"花费": 140, "生长时间": 1800, "收益": 230, "品质": "稀有", "描述": "秋季成熟的甜美果实", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
@@ -21,20 +37,24 @@
"栀子花": {"花费": 180, "生长时间": 2400, "收益": 300, "品质": "稀有", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"玫瑰花": {"花费": 190, "生长时间": 2520, "收益": 310, "品质": "稀有", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"菠萝": {"花费": 200, "生长时间": 2700, "收益": 340, "品质": "稀有", "描述": "热带水果之王", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"梨": {"花费": 210, "生长时间": 2820, "收益": 350, "品质": "稀有", "描述": "春季开花的落叶果树", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"桃": {"花费": 220, "生长时间": 2940, "收益": 360, "品质": "稀有", "描述": "粉色花海中的果实树种", "耐候性": 9, "等级": 3, "经验": 25, "能否购买": true},
"梨": {"花费": 210, "生长时间": 2820, "收益": 350, "品质": "稀有", "描述": "春季开花的落叶果树", "耐候性": 10, "等级": 3, "经验": 25, "能否购买": true},
"桃": {"花费": 220, "生长时间": 2940, "收益": 360, "品质": "稀有", "描述": "粉色花海中的果实树种", "耐候性": 9, "等级": 3, "经验": 25, "能否购买": true},
"荔枝": {"花费": 230, "生长时间": 3060, "收益": 380, "品质": "稀有", "描述": "亚热带珍稀水果,果肉如凝脂", "耐候性": 8, "等级": 3, "经验": 26, "能否购买": true},
"芒果": {"花费": 240, "生长时间": 3180, "收益": 400, "品质": "稀有", "描述": "热带阳光孕育的香甜果实", "耐候性": 10, "等级": 3, "经验": 27, "能否购买": true},
"芒果": {"花费": 240, "生长时间": 3180, "收益": 400, "品质": "稀有", "描述": "热带阳光孕育的香甜果实", "耐候性": 10, "等级": 3, "经验": 27, "能否购买": true},
"糖果树": {"花费": 250, "生长时间": 3300, "收益": 420, "品质": "稀有", "描述": "传说中结出彩色糖果的魔法树", "耐候性": 7, "等级": 3, "经验": 25, "能否购买": true},
"面包树": {"花费": 260, "生长时间": 3420, "收益": 440, "品质": "稀有", "描述": "热带地区的淀粉质主食树种", "耐候性": 9, "等级": 3, "经验": 25, "能否购买": true},
"幸运草": {"花费": 150, "生长时间": 1560, "收益": 220, "品质": "稀有", "描述": "四片叶子的幸运象征植物", "耐候性": 6, "等级": 3, "经验": 20, "能否购买": true},
"幸运花": {"花费": 170, "生长时间": 1680, "收益": 240, "品质": "稀有", "描述": "绽放时带来好运的神秘花卉", "耐候性": 7, "等级": 3, "经验": 22, "能否购买": true},
"摇钱树": {"花费": 300, "生长时间": 3600, "收益": 500, "品质": "稀有", "描述": "传说中能结出金币的神树", "耐候性": 10, "等级": 3, "经验": 30, "能否购买": true},
"葡萄": {"花费": 200, "生长时间": 2700, "收益": 340, "品质": "史诗", "描述": "用于酿酒的珍贵果实", "耐候性": 9, "等级": 4, "经验": 35, "能否购买": true},
"南瓜": {"花费": 180, "生长时间": 3600, "收益": 320, "品质": "史诗", "描述": "大型瓜果,节庆装饰的首选", "耐候性": 12, "等级": 4, "经验": 38, "能否购买": true},
"芦笋": {"花费": 220, "生长时间": 3000, "收益": 370, "品质": "史诗", "描述": "高档蔬菜,营养价值极高", "耐候性": 8, "等级": 4, "经验": 40, "能否购买": true},
"茄子": {"花费": 190, "生长时间": 2400, "收益": 310, "品质": "史诗", "描述": "紫色的营养蔬菜", "耐候性": 10, "等级": 4, "经验": 32, "能否购买": true},
"咖啡豆": {"花费": 200, "生长时间": 2500, "收益": 340, "品质": "史诗", "描述": "热带经济作物,果实经烘焙后可制成饮品,需温暖气候", "耐候性": 8, "等级": 4, "经验": 35, "能否购买": true},
"可可豆": {"花费": 200, "生长时间": 2500, "收益": 340, "品质": "史诗", "描述": "制作巧克力的原料,需高温高湿环境,经济价值较高", "耐候性": 10, "等级": 4, "经验": 36, "能否购买": true},
"西瓜": {"花费": 250, "生长时间": 4800, "收益": 450, "品质": "优良", "描述": "夏日消暑的大型水果", "耐候性": 6, "等级": 5, "经验": 50, "能否购买": true},
@@ -44,18 +64,20 @@
"百合花": {"花费": 260, "生长时间": 4800, "收益": 480, "品质": "优良", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 5, "经验": 50, "能否购买": true},
"康乃馨": {"花费": 270, "生长时间": 5100, "收益": 510, "品质": "优良", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 5, "经验": 50, "能否购买": true},
"郁金香": {"花费": 280, "生长时间": 5100, "收益": 510, "品质": "优良", "描述": "美丽的观赏植物", "耐候性": 10, "等级": 5, "经验": 50, "能否购买": true},
"藏羚羊草": {"花费": 80, "生长时间": 200, "收益": 200, "品质": "优良", "描述": "高原珍稀草种,用于生态修复,对土壤要求苛刻但市场需求大", "耐候性": 15, "等级": 5, "经验": 20, "能否购买": true},
"人参": {"花费": 400, "生长时间": 7200, "收益": 720, "品质": "传奇", "描述": "珍贵的药用植物,需要耐心培养", "耐候性": 15, "等级": 6, "经验": 80, "能否购买": true},
"富贵竹": {"花费": 350, "生长时间": 6600, "收益": 650, "品质": "传奇", "描述": "寓意吉祥的观赏植物", "耐候性": 12, "等级": 6, "经验": 75, "能否购买": true},
"芦荟": {"花费": 320, "生长时间": 6000, "收益": 600, "品质": "传奇", "描述": "具有药用价值的多肉植物", "耐候性": 18, "等级": 6, "经验": 70, "能否购买": true},
"哈密瓜": {"花费": 380, "生长时间": 7800, "收益": 700, "品质": "传奇", "描述": "甘甜的高级水果", "耐候性": 8, "等级": 6, "经验": 85, "能否购买": true},
"藏红花": {"花费": 400, "生长时间": 7000, "收益": 710, "品质": "传奇", "描述": "世界上最昂贵的香料之一,需精心照料,花朵可提取柱头", "耐候性": 9, "等级": 6, "经验": 80, "能否购买": true},
"金橘": {"花费": 500, "生长时间": 10800, "收益": 900, "品质": "传奇", "描述": "金黄色的珍贵柑橘", "耐候性": 10, "等级": 7, "经验": 120, "能否购买": true},
"苹果": {"花费": 450, "生长时间": 9600, "收益": 820, "品质": "传奇", "描述": "结果丰富的果树", "耐候性": 14, "等级": 7, "经验": 110, "能否购买": true},
"橘子": {"花费": 480, "生长时间": 10200, "收益": 850, "品质": "传奇", "描述": "维生素C丰富的果树", "耐候性": 12, "等级": 7, "经验": 115, "能否购买": true},
"香蕉": {"花费": 420, "生长时间": 8400, "收益": 780, "品质": "传奇", "描述": "热带水果之王", "耐候性": 5, "等级": 7, "经验": 100, "能否购买": true},
"苹果": {"花费": 450, "生长时间": 9600, "收益": 820, "品质": "传奇", "描述": "结果丰富的果树", "耐候性": 14, "等级": 7, "经验": 110, "能否购买": true},
"橘子": {"花费": 480, "生长时间": 10200, "收益": 850, "品质": "传奇", "描述": "维生素C丰富的果树", "耐候性": 12, "等级": 7, "经验": 115, "能否购买": true},
"香蕉": {"花费": 420, "生长时间": 8400, "收益": 780, "品质": "传奇", "描述": "热带水果之王", "耐候性": 5, "等级": 7, "经验": 100, "能否购买": true},
"向日葵": {"花费": 160, "生长时间": 3600, "收益": 280, "品质": "史诗", "描述": "向阳而生的美丽花朵", "耐候性": 13, "等级": 4, "经验": 35, "能否购买": true},
@@ -71,8 +93,10 @@
"冬虫夏草": {"花费": 600, "生长时间": 12000, "收益": 1200, "品质": "传奇", "描述": "稀世珍宝,药王之称", "耐候性": 30, "等级": 7, "经验": 180, "能否购买": true},
"山葵": {"花费": 500, "生长时间": 10800, "收益": 1000, "品质": "优良", "描述": "日式料理的珍贵调料", "耐候性": 22, "等级": 7, "经验": 150, "能否购买": true},
"鱼腥草": {"花费": 300, "生长时间": 7200, "收益": 600, "品质": "稀有", "描述": "具有特殊药用价值的野菜", "耐候性": 18, "等级": 6, "经验": 90, "能否购买": true},
"月光草": {"花费": 700, "生长时间": 14500, "收益": 1500, "品质": "传奇", "描述": "夜间开花的神秘植物,花瓣在月光下散发荧光,传说具有许愿功效", "耐候性": 20, "等级": 8, "经验": 200, "能否购买": true},
"凤凰木": {"花费": 650, "生长时间": 12600, "收益": 1400, "品质": "传奇", "描述": "传说中凤凰栖息的神树,开花时如火焰般绚烂,木材可驱邪避灾", "耐候性": 25, "等级": 8, "经验": 210, "能否购买": true},
"杂交树1": {"花费": 1200, "生长时间": 21600, "收益": 2500, "品质": "传奇", "描述": "初中生物书最后的想", "耐候性": 35, "等级": 9, "经验": 300, "能否购买": true},
"杂交树1": {"花费": 1200, "生长时间": 21600, "收益": 2500, "品质": "传奇", "描述": "初中生物书最后的想", "耐候性": 35, "等级": 9, "经验": 300, "能否购买": true},
"杂交树2": {"花费": 1500, "生长时间": 25200, "收益": 3000, "品质": "传奇", "描述": "初中生物书最后的想象", "耐候性": 40, "等级": 10, "经验": 400, "能否购买": true}
}

View File

@@ -1,7 +1,7 @@
{
"experience": 0,
"level": 1,
"money": 1000,
"money": 4000,
"体力值": 20,
"体力上次刷新时间": "",
"体力上次恢复时间": 0,
@@ -11,30 +11,29 @@
"user_password": "0123456789",
"last_login_time": "2025年12时09分35秒",
"total_login_time": "0时0分0秒",
"personal_profile": "个人简介",
"注册时间": "2025年05月21日15时00分00秒",
"farm_lots": [
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":true,"is_planted":false,"max_grow_time":3,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
@@ -63,5 +62,28 @@
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0},
{"crop_type":"","grow_time":0,"is_dead":false,"is_diged":false,"is_planted":false,"max_grow_time":5,"已浇水":false,"已施肥":false,"土地等级":0}
],
"player_bag": []
"player_bag": [],
"作物仓库": [],
"道具背包": [
{
"name": "精准采集锄",
"count": 1
},
{
"name": "农家肥",
"count": 3
}
],
"last_water_reset_date": "",
"daily_likes": {},
"seeds": {},
"last_check_in_date": "",
"check_in_count": 0,
"daily_check_in": {},
"lucky_draw_history": [],
"total_likes": 0,
"new_player_gift_claimed": false,
"new_player_gift_time": "",
"session_start_time": 0,
"online_gift": {}
}

View File

@@ -0,0 +1,12 @@
{
"精准采集-镰刀": {"花费":100,"描述":"可以在收获作物时必定掉落该作物的种子","类型":"作物道具","道具图片":"res://assets/道具图片/紫水晶镰刀.webp"},
"时运-镰刀": {"花费":100,"描述":"可以在收获作物时掉落更多的作物的收获物","类型":"作物道具","道具图片":"res://assets/道具图片/红宝石镰刀.webp"},
"农家肥": {"花费":100,"描述":"施肥道具可以在30分钟内2倍速作物生长","类型":"作物道具","道具图片":"res://assets/道具图片/农家肥.webp"},
"金坷垃": {"花费":100,"描述":"施肥道具可以在5分钟内5倍速作物的生长","类型":"作物道具","道具图片":"res://assets/道具图片/金坷垃2.webp"},
"水壶": {"花费":100,"描述":"(浇水道具)直接让作物生长进度+1%","类型":"作物道具","道具图片":"res://assets/道具图片/铁质洒水壶.webp"},
"水桶": {"花费":100,"描述":"(浇水道具)让作物生长进度+2%","类型":"作物道具","道具图片":"res://assets/道具图片/木质水桶2.webp"},
"杀虫剂": {"花费":100,"描述":"杀虫,暂时没什么用","类型":"作物道具","道具图片":"res://assets/道具图片/杀虫剂.webp"},
"除草剂": {"花费":100,"描述":"除草","类型":"作物道具","道具图片":"res://assets/道具图片/除草剂.webp"},
"生长素": {"花费":100,"描述":"时运可以10分钟内3倍速作物生长而且作物生长速度+3%","类型":"作物道具","道具图片":"res://assets/道具图片/生长素.webp"},
"铲子": {"花费":100,"描述":"铲除作物","类型":"作物道具","道具图片":"res://assets/道具图片/附魔铁铲.webp"}
}

1
Server/help.txt Normal file
View File

@@ -0,0 +1 @@
/etc/systemd/system/mengyafarm.service

View File

@@ -0,0 +1,15 @@
[Unit]
Description=MengyaFarmServer
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/shumengya/mengyafarmserver
ExecStart=/usr/bin/pip install -r requirements.txt && /usr/bin/python TCPGameServer.py
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
更新已存在玩家的注册时间为默认值的脚本
用于确保所有已存在的玩家都有默认的注册时间,不会享受新玩家奖励
"""
import os
import json
import datetime
def update_existing_players_register_time():
"""更新所有已存在玩家的注册时间为默认值"""
default_register_time = "2025年05月21日15时00分00秒"
game_saves_dir = "game_saves"
if not os.path.exists(game_saves_dir):
print("游戏存档目录不存在:", game_saves_dir)
return
updated_count = 0
error_count = 0
total_files = 0
# 获取所有玩家存档文件
for filename in os.listdir(game_saves_dir):
if filename.endswith('.json'):
total_files += 1
file_path = os.path.join(game_saves_dir, filename)
try:
# 读取玩家数据
with open(file_path, 'r', encoding='utf-8') as file:
player_data = json.load(file)
# 检查是否需要更新注册时间
current_register_time = player_data.get("注册时间", "")
# 如果没有注册时间字段,或者不是默认值,则设置为默认值
if not current_register_time:
player_data["注册时间"] = default_register_time
print(f"为玩家 {filename} 添加注册时间字段")
updated_count += 1
elif current_register_time != default_register_time:
# 如果注册时间不是默认值,说明是新注册的玩家,保持不变
print(f"玩家 {filename} 注册时间: {current_register_time} (保持不变)")
continue
else:
# 注册时间已经是默认值,无需更新
print(f"玩家 {filename} 注册时间已是默认值")
continue
# 保存更新后的数据
with open(file_path, 'w', encoding='utf-8') as file:
json.dump(player_data, file, indent=2, ensure_ascii=False)
except Exception as e:
print(f"处理文件 {filename} 时出错: {str(e)}")
error_count += 1
print(f"\n更新完成!")
print(f"总文件数: {total_files}")
print(f"已更新: {updated_count}")
print(f"错误: {error_count}")
print(f"默认注册时间: {default_register_time}")
if __name__ == "__main__":
print("开始更新已存在玩家的注册时间...")
update_existing_players_register_time()
print("脚本执行完成!")

View File

@@ -0,0 +1,54 @@
shader_type canvas_item;
// 摆动参数
uniform float sway_strength : hint_range(0.0, 0.05) = 0.02; // 摆动强度
uniform float sway_speed : hint_range(0.1, 5.0) = 1.0; // 摆动速度
uniform float wind_direction : hint_range(-1.0, 1.0) = 0.0; // 风向偏移
uniform float sway_variation : hint_range(0.0, 2.0) = 0.5; // 摆动变化
// 高度影响参数
uniform float sway_start_height : hint_range(0.0, 1.0) = 0.3; // 开始摆动的高度比例
uniform float height_curve : hint_range(1.0, 4.0) = 2.0; // 高度影响曲线
void fragment() {
vec2 uv = UV;
// 计算摆动强度(只有上半部分摆动)
float height_factor = 0.0;
if (uv.y < sway_start_height) {
// 计算从底部到摆动开始位置的渐变
height_factor = pow((sway_start_height - uv.y) / sway_start_height, height_curve);
}
// 创建多层摆动效果
float time_offset = TIME * sway_speed;
// 主摆动波
float main_sway = sin(time_offset + uv.y * 3.14159) * sway_strength;
// 次级摆动波(频率更高,幅度更小)
float secondary_sway = sin(time_offset * 2.3 + uv.y * 6.28318) * sway_strength * 0.3;
// 第三层摆动(更细微的抖动)
float micro_sway = sin(time_offset * 4.7 + uv.y * 12.56636) * sway_strength * 0.1;
// 结合所有摆动
float total_sway = (main_sway + secondary_sway + micro_sway) * height_factor;
// 添加风向偏移
total_sway += wind_direction * sway_strength * height_factor * 0.5;
// 添加摆动变化(随机性)
float variation = sin(time_offset * 0.37 + uv.x * 6.28318) * sway_variation * 0.01;
total_sway += variation * height_factor;
// 应用摆动到UV坐标
uv.x += total_sway;
// 边界检查防止UV超出范围
if (uv.x < 0.0 || uv.x > 1.0) {
COLOR = vec4(0.0, 0.0, 0.0, 0.0); // 透明
} else {
COLOR = texture(TEXTURE, uv);
}
}

View File

@@ -0,0 +1 @@
uid://ccqhg1n3d7sw8

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://duosec7bf82ms"
path="res://.godot/imported/0.webp-9339f1eb71d8e2d2c9d6eff2a61109e8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/人参/0.webp"
dest_files=["res://.godot/imported/0.webp-9339f1eb71d8e2d2c9d6eff2a61109e8.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bpybayv2tun01"
path="res://.godot/imported/1.webp-2e06968df5ac60cc2e9cb266075518b2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/人参/1.webp"
dest_files=["res://.godot/imported/1.webp-2e06968df5ac60cc2e9cb266075518b2.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://clyirnutul7bq"
path="res://.godot/imported/成熟.webp-ce9130a3e06cf6589c044054168410f9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/人参/成熟.webp"
dest_files=["res://.godot/imported/成熟.webp-ce9130a3e06cf6589c044054168410f9.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cq6lojk4o7874"
path="res://.godot/imported/收获物.webp-9ccbfd744d9be33e545ca51778406d54.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/人参/收获物.webp"
dest_files=["res://.godot/imported/收获物.webp-9ccbfd744d9be33e545ca51778406d54.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://nqjf05tbfwna"
path="res://.godot/imported/0.webp-a498150286b3ef11bcaf7062fb7c4c72.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/仙人掌/0.webp"
dest_files=["res://.godot/imported/0.webp-a498150286b3ef11bcaf7062fb7c4c72.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://blo41i0nan4tb"
path="res://.godot/imported/1.webp-eac2af28e41e5166de4e45fa1d9b023c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/仙人掌/1.webp"
dest_files=["res://.godot/imported/1.webp-eac2af28e41e5166de4e45fa1d9b023c.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bw6hipgwyv3k1"
path="res://.godot/imported/成熟.webp-571b96d5740a8d9b84111df363e5ed74.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/仙人掌/成熟.webp"
dest_files=["res://.godot/imported/成熟.webp-571b96d5740a8d9b84111df363e5ed74.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b35jvbxii87uc"
path="res://.godot/imported/收获物.webp-f5a0a563d7339ccd3c7a0634e5c0a5e2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/仙人掌/收获物.webp"
dest_files=["res://.godot/imported/收获物.webp-f5a0a563d7339ccd3c7a0634e5c0a5e2.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://pj3tv3cc2mlg"
path="res://.godot/imported/0.webp-8e6372f99a77669bfdae2b147d801863.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/冬虫夏草/0.webp"
dest_files=["res://.godot/imported/0.webp-8e6372f99a77669bfdae2b147d801863.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cvai23ne4ale2"
path="res://.godot/imported/1.webp-1c762135840fee82b6f1524cf7b93c28.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/冬虫夏草/1.webp"
dest_files=["res://.godot/imported/1.webp-1c762135840fee82b6f1524cf7b93c28.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://8w2qoa8bt2cg"
path="res://.godot/imported/2.webp-62669dec635d4d6139cbede94abc0c42.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/冬虫夏草/2.webp"
dest_files=["res://.godot/imported/2.webp-62669dec635d4d6139cbede94abc0c42.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cwmf68nddnxty"
path="res://.godot/imported/3.webp-ff0e46a5058a853b92c7d843b7523733.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/冬虫夏草/3.webp"
dest_files=["res://.godot/imported/3.webp-ff0e46a5058a853b92c7d843b7523733.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://pep35cbpo2ln"
path="res://.godot/imported/成熟.webp-5d9ed55294fc7780a9ccd1061a8db9e8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/冬虫夏草/成熟.webp"
dest_files=["res://.godot/imported/成熟.webp-5d9ed55294fc7780a9ccd1061a8db9e8.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cj46vssd21mc7"
path="res://.godot/imported/0.webp-47e115ab20922ebd97f4e5e7e5ca9983.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/凤凰木/0.webp"
dest_files=["res://.godot/imported/0.webp-47e115ab20922ebd97f4e5e7e5ca9983.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dn6ta7j43luw2"
path="res://.godot/imported/1.webp-70a0c6dc2f51cf788ff580d54c9c392f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/凤凰木/1.webp"
dest_files=["res://.godot/imported/1.webp-70a0c6dc2f51cf788ff580d54c9c392f.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://6amw1gdbfn5o"
path="res://.godot/imported/成熟.webp-704239800c91eeb80ba72e09c3239472.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/凤凰木/成熟.webp"
dest_files=["res://.godot/imported/成熟.webp-704239800c91eeb80ba72e09c3239472.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dee7f12h1hw2y"
path="res://.godot/imported/收获物.webp-e2fb798df4b68e31b5b9d36d256e4537.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/凤凰木/收获物.webp"
dest_files=["res://.godot/imported/收获物.webp-e2fb798df4b68e31b5b9d36d256e4537.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cda0yv72tjvv0"
path="res://.godot/imported/0.webp-d98890577b76bfa710d6a00e6916c0c7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/南瓜/0.webp"
dest_files=["res://.godot/imported/0.webp-d98890577b76bfa710d6a00e6916c0c7.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dvfhamkdqwok7"
path="res://.godot/imported/1.webp-113308ca15b586eaeb0bbd809b6997c6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/南瓜/1.webp"
dest_files=["res://.godot/imported/1.webp-113308ca15b586eaeb0bbd809b6997c6.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b12ny7my36aiw"
path="res://.godot/imported/2.webp-c7dbb06c083db947520775472c40c124.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/南瓜/2.webp"
dest_files=["res://.godot/imported/2.webp-c7dbb06c083db947520775472c40c124.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cuj5k8xwr8wg8"
path="res://.godot/imported/3.webp-7bbb31894686faa8c9080a58b509200d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/南瓜/3.webp"
dest_files=["res://.godot/imported/3.webp-7bbb31894686faa8c9080a58b509200d.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bgq22s3jbjuyp"
path="res://.godot/imported/4.webp-2ff3e9a99295417c9228dd9680a1f6b7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/南瓜/4.webp"
dest_files=["res://.godot/imported/4.webp-2ff3e9a99295417c9228dd9680a1f6b7.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://qctp46fg84pn"
path="res://.godot/imported/成熟.webp-80dd126437727579d2acaf9b13ad6530.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/南瓜/成熟.webp"
dest_files=["res://.godot/imported/成熟.webp-80dd126437727579d2acaf9b13ad6530.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c64al2w8qob3e"
path="res://.godot/imported/收获物.webp-760c7f62b2ac9aa0c8fa8513815e1afb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/南瓜/收获物.webp"
dest_files=["res://.godot/imported/收获物.webp-760c7f62b2ac9aa0c8fa8513815e1afb.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cq5sp4mhfgran"
path="res://.godot/imported/0.webp-821822db21f66aa9245299fab7cf906e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/可可豆/0.webp"
dest_files=["res://.godot/imported/0.webp-821822db21f66aa9245299fab7cf906e.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bandxaiut18do"
path="res://.godot/imported/成熟.webp-dad83f16e98754910ae39f797f4bc104.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/可可豆/成熟.webp"
dest_files=["res://.godot/imported/成熟.webp-dad83f16e98754910ae39f797f4bc104.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bopkaofm75ixu"
path="res://.godot/imported/收获物.webp-1abafc803996a04adbbd19db5cfa824b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/可可豆/收获物.webp"
dest_files=["res://.godot/imported/收获物.webp-1abafc803996a04adbbd19db5cfa824b.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://buexi5vwacjau"
path="res://.godot/imported/0.webp-e38fa2090339e41d8e2bc2f4382d5f43.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/向日葵/0.webp"
dest_files=["res://.godot/imported/0.webp-e38fa2090339e41d8e2bc2f4382d5f43.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bnpp8bfkxwae1"
path="res://.godot/imported/1.webp-39c5186218d6a70b3b214094d5602b76.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/向日葵/1.webp"
dest_files=["res://.godot/imported/1.webp-39c5186218d6a70b3b214094d5602b76.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://db4acrecie1gi"
path="res://.godot/imported/2.webp-a4ac518035e8dc36ed57f415183fccf4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/作物/向日葵/2.webp"
dest_files=["res://.godot/imported/2.webp-a4ac518035e8dc36ed57f415183fccf4.ctex"]
[params]
compress/mode=1
compress/high_quality=false
compress/lossy_quality=0.01
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Some files were not shown because too many files have changed in this diff Show More