From a12b8792af096131887aa44b480b9e7303611854 Mon Sep 17 00:00:00 2001 From: TsubakiLoL <2789646812@qq.com> Date: Wed, 9 Oct 2024 20:34:18 +0800 Subject: [PATCH] 10.9 --- autoload/database/script/database.gd | 10 ++ autoload/global/script/global.gd | 29 ++-- class/item_tool/item_tool.gd | 54 +++++-- json/event.json | 29 +++- json/item.json | 18 ++- json/npc.json | 2 +- json/scene.json | 4 + scene/ability_to_card_need.gd | 6 + scene/ability_to_card_need.tscn | 4 +- scene/bag_side_card.gd | 1 - scene/bag_side_card_introduction.gd | 1 + scene/bag_side_card_introduction.tscn | 2 + scene/equipment.gd | 16 ++ scene/game_flow.gd | 6 + scene/game_flow.tscn | 8 +- scene/item_level_up.gd | 70 +++++++++ scene/item_level_up.tscn | 207 ++++++++++++++++++++++++++ scene/trade.gd | 4 +- scene/trade_card.gd | 6 +- scene/trade_card.tscn | 15 ++ 20 files changed, 459 insertions(+), 33 deletions(-) create mode 100644 scene/ability_to_card_need.gd create mode 100644 scene/equipment.gd create mode 100644 scene/item_level_up.gd create mode 100644 scene/item_level_up.tscn diff --git a/autoload/database/script/database.gd b/autoload/database/script/database.gd index 8fc9efb..67b253b 100644 --- a/autoload/database/script/database.gd +++ b/autoload/database/script/database.gd @@ -273,6 +273,16 @@ func get_item_data(id:String): return ItemTool.re_process_item_data(dictionary) else: return null +#获取物品名称 +func get_item_name(id:String): + if item_data.has(id): + var dictionary:Dictionary=item_data[id] + return dictionary["name"] + else: + return null + + + pass #获取词条数据 func get_word_data(id:String): if word_data.has(id): diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index 531c313..c4f06fa 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -134,9 +134,12 @@ func load_system_game_data(): func save_system_game_data(): var f=FileAccess.open(system_game_data_path,FileAccess.WRITE) f.store_var(system_game_data) -#获取当前游戏内所有物品 +#获取当前游戏内所有物品的拷贝数据 func get_all_item_game_data()->Array: return now_game_data["item"].duplicate(true) +#获取当前游戏内所有物品的非拷贝数据 +func get_all_item_game_data_not_copy()->Array: + return now_game_data["item"] #根据type获取当前物品 func get_type_item_game_data(type:int)->Array: var item:Array=now_game_data["item"].duplicate(true) @@ -162,14 +165,17 @@ func replace_equip_with_data(page:int,pos:int,item_data): func add_item_to_bag(item_data:Dictionary): var item:Array=now_game_data["item"] if item_data["allow_merge"]: - for i in item_data.size(): - if item_data[i]["id"]==item_data["id"]: - if item_data[i].has("num"): - item_data[i]["num"]+=1 + var is_find:bool=false + for i in item.size(): + if item[i]["id"]==item_data["id"]: + is_find=true + if item[i].has("num"): + item[i]["num"]+=1 else: - item_data[i]["num"]=2 + item[i]["num"]=2 - pass + if not is_find: + item.append(item_data) pass else: item.append(item_data) @@ -189,7 +195,7 @@ func decrease_item_num_index(ind:int,num:int=1): #根据ID减少在背包内的物品 func decrease_item_num_id(id:String,num:int=1)->bool: var item:Array=now_game_data["item"] - var item_data:Dictionary + var item_data var ind:int for i in item.size(): if item[i]["id"]==id: @@ -213,7 +219,7 @@ func decrease_item_num_id(id:String,num:int=1)->bool: #通过id获取当前背包数量(如果是不允许合并的物品则返回1(有)或者0(没有)) func get_item_by_id(id:String)->int: var item:Array=now_game_data["item"] - var item_data:Dictionary + var item_data var ind:int for i in item.size(): if item[i]["id"]==id: @@ -224,6 +230,7 @@ func get_item_by_id(id:String)->int: if item_data.has("num"): return item_data["num"] else: + print(item_data) return 1 else: return 0 @@ -468,7 +475,9 @@ var triger:Dictionary={ #鉴定触发器 "show_identifaction":func(data):show_identification(data), #拍卖触发器 - "show_auction":func(data):show_auction(data) + "show_auction":func(data):show_auction(data), + #装备升级界面展示触发器 + "show_level_up":func (data):now_game_flow.show_item_level_up() } #使用事件触发器 func call_triger(triger_type:String,data): diff --git a/class/item_tool/item_tool.gd b/class/item_tool/item_tool.gd index 79a9109..248f9ac 100644 --- a/class/item_tool/item_tool.gd +++ b/class/item_tool/item_tool.gd @@ -34,6 +34,8 @@ static func re_process_item_data(item_data:Dictionary): for i in word_num: word_arr.append(get_rand_value_weight(word_lib)) new_item_data["word"]=word_arr + if item_data.has("level_up_need_material"): + item_data["level"]=0 return new_item_data static func get_weight(qalib:Dictionary): return qalib["weight"] @@ -62,24 +64,24 @@ static func get_name_from_item_data(item_data:Dictionary)->String: #劣质 普通 优秀 稀有 史诗 传说 无双 match quility: 0: - return n+"(劣质)" + n+="(劣质)" 1: - return n+"(普通)" + n+="(普通)" 2: - return n+"(优秀)" + n+="(优秀)" 3: - return n+"(稀有)" + n+="(稀有)" 4: - return n+"(史诗)" + n+="(史诗)" 5: - return n+"(传说)" + n+="(传说)" 6: - return n+"(无双)" + n+="(无双)" _: - return n - else: - return n - pass + pass + if item_data.has("level") and item_data["level"]!=0: + n+="+"+str(item_data["level"]) + return n static func get_introduction_from_item_data(item_data:Dictionary)->String: var res:String="" if item_data.has("word"): @@ -102,3 +104,33 @@ static func get_item_attribute_basic(item_data:Dictionary): return item_data["attribute"].duplicate() else: return {} +#item是否可以升级 +static func could_item_level_up(item_data:Dictionary): + if item_data.has("quality"): + var quality:int=item_data["quality"] + if quality==0 ||quality==6: + return false + if not item_data.has("level_up_need_material"): + return false + var level_up_need_material=item_data["level_up_need_material"] + if not level_up_need_material.has(str(quality)): + return false + if not item_data.has("level"): + return false + var now_level:int=item_data["level"] + + var max_level_arr=[0,5,5,3,3,3,0] + var max_level=max_level_arr[quality] + if now_level>=max_level: + return false + else: + return true + else: + return false + + pass + + +#获取当前item升级所需材料 +static func get_item_level_up_need(item_data:Dictionary): + return item_data["level_up_need_material"][str(item_data["quality"])].duplicate(true) diff --git a/json/event.json b/json/event.json index 1826f46..d918106 100644 --- a/json/event.json +++ b/json/event.json @@ -204,7 +204,7 @@ "auction_test":{ "name":"拍卖测试事件", "texture":"test_scene", - "text":"这是一个测试鉴定系统的事件", + "text":"这是一个测试拍卖系统的事件", "choice":[ { "name":"拍卖", @@ -232,5 +232,32 @@ },] } ] + }, + "item_level_up_test":{ + "name":"升级测试事件", + "texture":"test_scene", + "text":"这是一个测试装备升级系统的事件", + "choice":[ + { + "name":"升级", + "triger":[ + { + "type":"show_level_up", + "data":"" + }, + { + "type":"end_event", + "data":"" + }, + ] + }, + { + "name":"结束", + "triger":[{ + "type":"end_event", + "data":"" + },] + } + ] } } diff --git a/json/item.json b/json/item.json index 2a964fb..5a9facd 100644 --- a/json/item.json +++ b/json/item.json @@ -6,6 +6,17 @@ "attribute":{ "AGI":100 }, + "level_add_attribute":{ + + }, + "level_up_need_material":{ + "4":{ + "item_06":5 + }, + "5":{ + "item_06":10 + } + }, "quality_lib":[ { "value":4, @@ -27,14 +38,12 @@ }, ], "texture":"issuing", - "name":"发卡(测试饰品)", + "name":"发卡", "introduction":"用于测试的饰品装备,并没有什么用(现测试用于钓鱼)", "identification":{ "AGI":100 }, - "material":{ - - } + }, "item_02":{ @@ -153,6 +162,7 @@ ], "name":"绷带", "introduction":"用于测试的道具,并没有什么用", + "texture":"bandage", "material":{ } diff --git a/json/npc.json b/json/npc.json index e32959d..9c6824c 100644 --- a/json/npc.json +++ b/json/npc.json @@ -7,7 +7,7 @@ }, "npc_02":{ "name":"测试NPC2", - "sold_item":["item_03","item_04"], + "sold_item":["item_03","item_04","item_06","item_06","item_06","item_06","item_06","item_06","item_06",], "init_favor":0, "gold":7777 } diff --git a/json/scene.json b/json/scene.json index 7e5d51a..42185ec 100644 --- a/json/scene.json +++ b/json/scene.json @@ -31,6 +31,10 @@ { "name":"拍卖测试", "event":"auction_test" + }, + { + "name":"升级测试", + "event":"item_level_up_test" } ], "linked_scene":[{ diff --git a/scene/ability_to_card_need.gd b/scene/ability_to_card_need.gd new file mode 100644 index 0000000..f20bbaa --- /dev/null +++ b/scene/ability_to_card_need.gd @@ -0,0 +1,6 @@ +extends TextureRect + +func set_text(str:String): + $Label.text=str +func set_color(color:Color): + $Label.add_theme_color_override("font_color",color) diff --git a/scene/ability_to_card_need.tscn b/scene/ability_to_card_need.tscn index a3568b7..05db61e 100644 --- a/scene/ability_to_card_need.tscn +++ b/scene/ability_to_card_need.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=3 uid="uid://dbb1aw7idwsqu"] +[gd_scene load_steps=3 format=3 uid="uid://dbb1aw7idwsqu"] [ext_resource type="Texture2D" uid="uid://cax0m4frsh2pd" path="res://res/ui/ui_022_ability_to_cards/tuceng327.png" id="1_866xd"] +[ext_resource type="Script" path="res://scene/ability_to_card_need.gd" id="2_mjycf"] [node name="ability_to_card_need" type="TextureRect"] offset_right = 40.0 @@ -8,6 +9,7 @@ offset_bottom = 40.0 size_flags_horizontal = 0 size_flags_vertical = 0 texture = ExtResource("1_866xd") +script = ExtResource("2_mjycf") [node name="Label" type="Label" parent="."] layout_mode = 1 diff --git a/scene/bag_side_card.gd b/scene/bag_side_card.gd index 23b322d..2ccbf34 100644 --- a/scene/bag_side_card.gd +++ b/scene/bag_side_card.gd @@ -11,7 +11,6 @@ var data:Dictionary={ } # Called when the node enters the scene tree for the first time. func _ready() -> void: - set_data(Database.get_item_data("item_01")) pass # Replace with function body. diff --git a/scene/bag_side_card_introduction.gd b/scene/bag_side_card_introduction.gd index c1724e0..f220a5a 100644 --- a/scene/bag_side_card_introduction.gd +++ b/scene/bag_side_card_introduction.gd @@ -9,3 +9,4 @@ func _ready() -> void: %bag_card_introduction.text=ItemTool.get_introduction_from_item_data(data) get_parent().add_theme_stylebox_override("panel",StyleBoxEmpty.new()) + print(%bag_card_name.text) diff --git a/scene/bag_side_card_introduction.tscn b/scene/bag_side_card_introduction.tscn index c665143..6221bf2 100644 --- a/scene/bag_side_card_introduction.tscn +++ b/scene/bag_side_card_introduction.tscn @@ -59,6 +59,8 @@ layout_mode = 0 anchor_left = 0.180628 anchor_right = 0.913613 anchor_bottom = 0.212 +theme_override_colors/font_outline_color = Color(0, 0, 0, 1) +theme_override_constants/outline_size = 5 theme_override_font_sizes/font_size = 27 text = "物品名" vertical_alignment = 1 diff --git a/scene/equipment.gd b/scene/equipment.gd new file mode 100644 index 0000000..c072e66 --- /dev/null +++ b/scene/equipment.gd @@ -0,0 +1,16 @@ +extends Label + + +signal item_selected(index:int) + + +@export var index:int=0 +func _can_drop_data(at_position: Vector2, data: Variant) -> bool: + return true +func _drop_data(at_position: Vector2, data: Variant) -> void: + #Global.replace_equip_with_data(page,index,data) + #Global.decrease_item_num_index(data["ind"]) + index=data["ind"] + item_selected.emit(index) + pass + diff --git a/scene/game_flow.gd b/scene/game_flow.gd index cb979c0..465236e 100644 --- a/scene/game_flow.gd +++ b/scene/game_flow.gd @@ -146,3 +146,9 @@ func show_auction(npc_id_array:Array,item_id_array:Array): var item_data=Database.get_item_data(i) item_data_arr.append(item_data) %auction.set_npc_arr_and_item_arr(npc_data_arr,item_data_arr) + +func show_item_level_up(): + + %item_level_up.show() + %item_level_up.fresh() + pass diff --git a/scene/game_flow.tscn b/scene/game_flow.tscn index bc748b0..3f33724 100644 --- a/scene/game_flow.tscn +++ b/scene/game_flow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=30 format=3 uid="uid://bht5sd88340s5"] +[gd_scene load_steps=31 format=3 uid="uid://bht5sd88340s5"] [ext_resource type="Texture2D" uid="uid://5vyvaedcfv38" path="res://res/ui/ui_019_game_flow/tuceng1.png" id="1_gjw3y"] [ext_resource type="Script" path="res://scene/game_flow.gd" id="1_w6afk"] @@ -23,6 +23,7 @@ [ext_resource type="PackedScene" uid="uid://ln0ri824gh2c" path="res://scene/save_and_load.tscn" id="21_2j45w"] [ext_resource type="PackedScene" uid="uid://mcf2riinvukc" path="res://scene/single_identification.tscn" id="22_0wbgg"] [ext_resource type="PackedScene" uid="uid://cykq0nd4y57xe" path="res://scene/auction.tscn" id="23_mavou"] +[ext_resource type="PackedScene" uid="uid://b0xgo1tguum73" path="res://scene/item_level_up.tscn" id="24_7ni35"] [sub_resource type="Gradient" id="Gradient_4wq1v"] @@ -472,6 +473,11 @@ unique_name_in_owner = true visible = false layout_mode = 1 +[node name="item_level_up" parent="." instance=ExtResource("24_7ni35")] +unique_name_in_owner = true +visible = false +layout_mode = 1 + [connection signal="pressed" from="hbox/TextureRect/head_btn" to="." method="_on_head_btn_pressed"] [connection signal="pressed" from="HBoxContainer/TextureRect/save" to="." method="_on_save_pressed"] [connection signal="pressed" from="HBoxContainer/TextureRect2/load" to="." method="_on_load_pressed"] diff --git a/scene/item_level_up.gd b/scene/item_level_up.gd new file mode 100644 index 0000000..83ff7f8 --- /dev/null +++ b/scene/item_level_up.gd @@ -0,0 +1,70 @@ +extends Control +var now_select_item_index:int=-1 +const BAG_SIDE_CARD = preload("res://scene/bag_side_card.tscn") +const ABILITY_TO_CARD_NEED = preload("res://scene/ability_to_card_need.tscn") +func fresh(): + %level_up.disable(true) + var all_item=Global.get_all_item_game_data() + for i in %bag_side_card_add_pos.get_children(): + i.queue_free() + for i in %need_add_pos.get_children(): + i.queue_free() + for i in all_item.size(): + if ItemTool.could_item_level_up(all_item[i]): + var new_card=BAG_SIDE_CARD.instantiate() + %bag_side_card_add_pos.add_child(new_card) + new_card.set_data(all_item[i]) + new_card.equip_index=i + if now_select_item_index>=0: + %level_up.disable(false) + var selected_item_data=Global.get_all_item_game_data()[now_select_item_index] + %selected_face.texture=Database.get_texture(selected_item_data["texture"]) + var level_up_need_material=ItemTool.get_item_level_up_need(selected_item_data) + for i in level_up_need_material.keys(): + var new_need=ABILITY_TO_CARD_NEED.instantiate() + %need_add_pos.add_child(new_need) + var now_item_num=Global.get_item_by_id(i) + var need_num:int=level_up_need_material[i] + if now_item_num void: + fresh() + + +func _on_close_pressed() -> void: + + self.hide() + pass # Replace with function body. + + +func _on_level_item_selected(index: int) -> void: + now_select_item_index=index + fresh() + pass # Replace with function body. + + +func _on_level_up_pressed() -> void: + if now_select_item_index>=0: + var selected_item_data=Global.get_all_item_game_data_not_copy()[now_select_item_index] + var level_up_need_material=ItemTool.get_item_level_up_need(selected_item_data) + var could_level_up:bool=true + for i in level_up_need_material.keys(): + var now_item_num=Global.get_item_by_id(i) + var need_num:int=level_up_need_material[i] + if need_num>now_item_num: + could_level_up=false + break + if could_level_up: + for i in level_up_need_material.keys(): + var need_num:int=level_up_need_material[i] + Global.decrease_item_num_id(i,need_num) + var before_level:int=0 + if selected_item_data.has("level"): + before_level=selected_item_data["level"] + + selected_item_data["level"]=before_level+1 + fresh() + pass # Replace with function body. diff --git a/scene/item_level_up.tscn b/scene/item_level_up.tscn new file mode 100644 index 0000000..2df3071 --- /dev/null +++ b/scene/item_level_up.tscn @@ -0,0 +1,207 @@ +[gd_scene load_steps=10 format=3 uid="uid://b0xgo1tguum73"] + +[ext_resource type="Texture2D" uid="uid://dli3olhy3gf33" path="res://res/ui/ui_031_auction/tuceng384.png" id="1_0l7tc"] +[ext_resource type="Script" path="res://scene/item_level_up.gd" id="1_6q1tj"] +[ext_resource type="PackedScene" uid="uid://dfhx4088ydrme" path="res://scene/bag_side_card.tscn" id="2_po3t1"] +[ext_resource type="Texture2D" uid="uid://bsy0yv6edtsmw" path="res://res/ui/ui_009_skill_config/tuceng1.png" id="3_sgsks"] +[ext_resource type="Script" path="res://scene/equipment.gd" id="4_dp26x"] +[ext_resource type="PackedScene" uid="uid://dbb1aw7idwsqu" path="res://scene/ability_to_card_need.tscn" id="5_mmyo6"] +[ext_resource type="Texture2D" uid="uid://brsla1fva3fsy" path="res://res/ui/ui_022_ability_to_cards/tuceng301.png" id="6_pqdty"] +[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="7_sutp7"] +[ext_resource type="Texture2D" uid="uid://c3nm3avrqj4pf" path="res://res/ui/ui_031_auction/tuceng385.png" id="9_3c38o"] + +[node name="item_level_up" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_6q1tj") + +[node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_0l7tc") +expand_mode = 1 +stretch_mode = 6 + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.513021 +anchor_top = 0.117593 +anchor_right = 0.947396 +anchor_bottom = 0.862037 +offset_left = 6.10352e-05 +theme_override_constants/separation = 115 +metadata/_edit_use_anchors_ = true + +[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"] +custom_minimum_size = Vector2(114, 0) +layout_mode = 2 +size_flags_horizontal = 0 +horizontal_scroll_mode = 0 +vertical_scroll_mode = 3 + +[node name="bag_side_card_add_pos" type="GridContainer" parent="HBoxContainer/ScrollContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/h_separation = 30 +theme_override_constants/v_separation = 30 +columns = 6 + +[node name="bag_side_card" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card2" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card3" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card4" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card5" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card6" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card7" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card8" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card9" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card10" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card11" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="bag_side_card12" parent="HBoxContainer/ScrollContainer/bag_side_card_add_pos" instance=ExtResource("2_po3t1")] +layout_mode = 2 + +[node name="TextureRect3" type="NinePatchRect" parent="."] +clip_contents = true +custom_minimum_size = Vector2(0, 204) +layout_mode = 0 +offset_left = 233.0 +offset_top = 131.0 +offset_right = 680.0 +offset_bottom = 533.0 +size_flags_vertical = 0 +texture = ExtResource("3_sgsks") + +[node name="selected_face" type="TextureRect" parent="TextureRect3"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +expand_mode = 1 +stretch_mode = 5 + +[node name="level" type="Label" parent="TextureRect3"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 +theme_override_colors/font_color = Color(1, 1, 1, 1) +theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) +theme_override_constants/outline_size = 4 +theme_override_font_sizes/font_size = 31 +text = "+0" +horizontal_alignment = 1 +vertical_alignment = 2 +script = ExtResource("4_dp26x") +metadata/_edit_use_anchors_ = true + +[node name="need_add_pos" type="VBoxContainer" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.121354 +anchor_top = 0.55 +anchor_right = 0.297396 +anchor_bottom = 0.827778 +size_flags_vertical = 0 +theme_override_constants/separation = 15 +metadata/_edit_use_anchors_ = true + +[node name="ability_to_card_need" parent="need_add_pos" instance=ExtResource("5_mmyo6")] +layout_mode = 2 + +[node name="ability_to_card_need2" parent="need_add_pos" instance=ExtResource("5_mmyo6")] +layout_mode = 2 + +[node name="ability_to_card_need3" parent="need_add_pos" instance=ExtResource("5_mmyo6")] +layout_mode = 2 + +[node name="ability_to_card_need4" parent="need_add_pos" instance=ExtResource("5_mmyo6")] +layout_mode = 2 + +[node name="ability_to_card_need5" parent="need_add_pos" instance=ExtResource("5_mmyo6")] +layout_mode = 2 + +[node name="TextureRect2" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.121354 +anchor_top = 0.869444 +anchor_right = 0.229167 +anchor_bottom = 0.92037 +offset_bottom = -6.10352e-05 +size_flags_horizontal = 4 +size_flags_vertical = 10 +texture = ExtResource("6_pqdty") +metadata/_edit_use_anchors_ = true + +[node name="Label" type="Label" parent="TextureRect2"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_font_sizes/font_size = 24 +text = "升级" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="level_up" parent="TextureRect2" instance=ExtResource("7_sutp7")] +unique_name_in_owner = true +layout_mode = 1 + +[node name="TextureRect4" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -40.0 +offset_bottom = 40.0 +grow_horizontal = 0 +texture = ExtResource("9_3c38o") + +[node name="close" parent="TextureRect4" instance=ExtResource("7_sutp7")] +layout_mode = 1 + +[connection signal="item_selected" from="TextureRect3/level" to="." method="_on_level_item_selected"] +[connection signal="pressed" from="TextureRect2/level_up" to="." method="_on_level_up_pressed"] +[connection signal="pressed" from="TextureRect4/close" to="." method="_on_close_pressed"] diff --git a/scene/trade.gd b/scene/trade.gd index fcd95c2..c8baed2 100644 --- a/scene/trade.gd +++ b/scene/trade.gd @@ -118,10 +118,10 @@ func add_item_to_npc(item_data:Dictionary): func dec_item_from_npc(ind:int): if npc_data["sold_item"][ind].has("num"): - if npc_data["sold_item"]["num"]<=1: + if npc_data["sold_item"][ind]["num"]<=1: npc_data["sold_item"].pop_at(ind) else: - npc_data["sold_item"]["num"]-=1 + npc_data["sold_item"][ind]["num"]-=1 pass else: npc_data["sold_item"].pop_at(ind) diff --git a/scene/trade_card.gd b/scene/trade_card.gd index e56c87a..d70f3f2 100644 --- a/scene/trade_card.gd +++ b/scene/trade_card.gd @@ -8,7 +8,11 @@ func set_item(item_data:Dictionary): data=item_data %face.texture=Database.get_texture(data["texture"]) %price.text="价格:"+str(int(data["price"]*discount)) - + if data.has("num"): + %num.show() + %num.text=str(data["num"]) + else: + %num.hide() func _on_trade_card_btn_spec_pressed() -> void: click.emit() diff --git a/scene/trade_card.tscn b/scene/trade_card.tscn index 126890c..8edc385 100644 --- a/scene/trade_card.tscn +++ b/scene/trade_card.tscn @@ -53,6 +53,21 @@ text = "价格:100" horizontal_alignment = 1 vertical_alignment = 1 +[node name="num" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -83.8134 +offset_right = -17.8134 +offset_bottom = 45.0 +grow_horizontal = 0 +theme_override_font_sizes/font_size = 24 +text = "0" +horizontal_alignment = 2 +vertical_alignment = 1 + [node name="trade_card_btn_spec" type="Button" parent="."] layout_mode = 1 anchors_preset = 15