10.2
This commit is contained in:
parent
b5f8a1d451
commit
c35377e0c2
@ -321,17 +321,40 @@ var now_game_data:Dictionary={
|
||||
},
|
||||
#游戏内物品
|
||||
"item":[],
|
||||
|
||||
#存储的NPC数据(仅包含遇到的NPC,用于存储NPC的背包,在申请NPCdata时进行写入
|
||||
"NPC_data":{},
|
||||
|
||||
"now_scene":"",
|
||||
"difficulty":0,
|
||||
"gold":9999,
|
||||
"gold":1000,
|
||||
"health":100,
|
||||
"spirit":999,
|
||||
"map":"map_01",
|
||||
"move_ability":1,
|
||||
"time_unix":0,
|
||||
"card_in_bag":["card_03","card_03","card_02","card_02","card_01","card_01","card_01","card_01"]
|
||||
|
||||
}
|
||||
#获取当前局内NPC数据
|
||||
func get_now_game_npc_data(NPC_id:String):
|
||||
var now_npc_data:Dictionary=now_game_data["NPC_data"]
|
||||
if now_npc_data.has(NPC_id):
|
||||
#这里不进行duplicate副本的原因是trade交易场景要对数据进行操作
|
||||
return now_npc_data[NPC_id]
|
||||
else:
|
||||
#填入npc数据,并实例出售卖的道具()可以通过在get item data上施加影响来实现随机
|
||||
var n_data=get_npc_data(NPC_id)
|
||||
for i in n_data["sold_item"].size():
|
||||
n_data["sold_item"][i]=get_item_data(n_data["sold_item"][i])
|
||||
now_game_data["NPC_data"][NPC_id]=n_data
|
||||
return now_npc_data[NPC_id]
|
||||
#获取当前角色与NPC的好感度
|
||||
func get_now_game_npc_favor(npc_id):
|
||||
return CharacterTool.get_character_with_npc_favor(now_game_data["character_data"],npc_id)
|
||||
#展示和NPC id对应的交易界面
|
||||
func show_trade(npc_id:String):
|
||||
now_game_flow.show_trade(npc_id)
|
||||
|
||||
#游戏内货币改变信号
|
||||
signal game_currency_changed
|
||||
#获取游戏内的“货币”,0:生命,1金钱,2精神
|
||||
@ -448,7 +471,8 @@ var triger:Dictionary={
|
||||
"end_event":func(data):now_game_flow.event_panel.hide(),
|
||||
"flow_time":func (data):flow_time(data),
|
||||
"fight":func (data):fight(data),
|
||||
"add_currency":func (data):change_currency_game(data["ind"],data["value"])
|
||||
"add_currency":func (data):change_currency_game(data["ind"],data["value"]),
|
||||
"trade":func(data): show_trade(data)
|
||||
}
|
||||
#使用事件触发器
|
||||
func call_triger(triger_type:String,data):
|
||||
|
@ -192,3 +192,13 @@ static func get_character_skill_all(character_data:Dictionary):
|
||||
if character_data.has("skill"):
|
||||
var skill_arr:Array=character_data["skill"]
|
||||
return skill_arr.duplicate(true)
|
||||
|
||||
#获取角色与npc之间的关系
|
||||
static func get_character_with_npc_favor(character_data:Dictionary,npc_id:String):
|
||||
var favor_data=character_data["favor"]
|
||||
if favor_data.has(npc_id):
|
||||
return favor_data[npc_id]
|
||||
else:
|
||||
character_data["favor"][npc_id]=Global.get_npc_data(npc_id)["init_favor"]
|
||||
return favor_data[npc_id]
|
||||
pass
|
||||
|
@ -146,4 +146,32 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"event_05":{
|
||||
"name":"测试事件5",
|
||||
"texture":"test_scene",
|
||||
"text":"这是一个测试交易系统的事件",
|
||||
"choice":[
|
||||
{
|
||||
"name":"交易测试01",
|
||||
"triger":[{
|
||||
"type":"trade",
|
||||
"data":"npc_01"
|
||||
},]
|
||||
},
|
||||
{
|
||||
"name":"交易测试02",
|
||||
"triger":[{
|
||||
"type":"trade",
|
||||
"data":"npc_02"
|
||||
},]
|
||||
},
|
||||
{
|
||||
"name":"结束",
|
||||
"triger":[{
|
||||
"type":"end_event",
|
||||
"data":""
|
||||
},]
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
{
|
||||
"测试npc_1":{
|
||||
"basic_attribute":{
|
||||
"CON":100,
|
||||
"AGI":100,
|
||||
"INT":100,
|
||||
"WIS":100,
|
||||
|
||||
"STR":100,
|
||||
"MND":100,
|
||||
"LUC":100,
|
||||
},
|
||||
"npc_01":{
|
||||
"name":"测试NPC1",
|
||||
"sold_item":["item_01","item_02"],
|
||||
"init_favor":50,
|
||||
"gold":9999
|
||||
},
|
||||
"npc_02":{
|
||||
"name":"测试NPC2",
|
||||
"sold_item":["item_03","item_04"],
|
||||
"init_favor":0,
|
||||
"gold":7777
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,10 @@
|
||||
"name":"货币测试",
|
||||
"event":"event_04"
|
||||
},
|
||||
{
|
||||
"name":"交易测试",
|
||||
"event":"event_05"
|
||||
},
|
||||
],
|
||||
"linked_scene":[{
|
||||
"name":"测试场景2",
|
||||
|
@ -112,3 +112,7 @@ func update_game_currency():
|
||||
%jinqian.text=str(Global.get_currency_game(1))
|
||||
%shengming.text=str(Global.get_currency_game(0))
|
||||
%jingshen.text=str(Global.get_currency_game(2))
|
||||
#显示交易
|
||||
func show_trade(NPC_id:String):
|
||||
%trade.set_data(NPC_id)
|
||||
%trade.show()
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=26 format=3 uid="uid://bht5sd88340s5"]
|
||||
[gd_scene load_steps=27 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"]
|
||||
@ -19,6 +19,7 @@
|
||||
[ext_resource type="Shader" path="res://res/shader/change_scene.gdshader" id="18_ubmfk"]
|
||||
[ext_resource type="PackedScene" uid="uid://ccsaeb8hm5lsu" path="res://scene/map.tscn" id="19_fok85"]
|
||||
[ext_resource type="PackedScene" uid="uid://chh7gr3qbkr8u" path="res://scene/basic_message.tscn" id="19_xvka5"]
|
||||
[ext_resource type="PackedScene" uid="uid://cewsjbnll1iol" path="res://scene/trade.tscn" id="20_ql26d"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_4wq1v"]
|
||||
|
||||
@ -447,5 +448,10 @@ visible = false
|
||||
layout_mode = 1
|
||||
is_in_game = true
|
||||
|
||||
[node name="trade" parent="." instance=ExtResource("20_ql26d")]
|
||||
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/TextureRect3/map" to="." method="_on_map_pressed"]
|
||||
|
153
scene/trade.gd
Normal file
153
scene/trade.gd
Normal file
@ -0,0 +1,153 @@
|
||||
extends Control
|
||||
const TRADE_CARD = preload("res://scene/trade_card.tscn")
|
||||
var npc_data:Dictionary
|
||||
var npc_id:String
|
||||
#当前选择的对方背包里的物品的序列
|
||||
var now_select_other_item_ind:int=0
|
||||
#当前选择的自己背包的物品的序列
|
||||
var now_select_self_item_ind:int=0
|
||||
|
||||
var favor:int=0:
|
||||
set(val):
|
||||
favor=val
|
||||
%sold_value.text=str(clamp((200-favor),50,200))+"%"
|
||||
%back_value.text=str(clamp((50+favor),50,150))+"%"
|
||||
#NPC拥有金钱
|
||||
var other_gold:int=0:
|
||||
set(val):
|
||||
%other_gold.text=str(val)
|
||||
other_gold=val
|
||||
func set_data(npc_id:String):
|
||||
npc_data=Global.get_now_game_npc_data(npc_id)
|
||||
favor=Global.get_now_game_npc_favor(npc_id)
|
||||
%trade_name.text=npc_data["name"]
|
||||
fresh()
|
||||
pass
|
||||
func fresh():
|
||||
%self_item_panel.hide()
|
||||
%other_item_panel.hide()
|
||||
other_gold=npc_data["gold"]
|
||||
%self_gold.text=str(Global.get_currency_game(1))
|
||||
for i in %other_bag.get_children():
|
||||
i.queue_free()
|
||||
for i in %self_bag.get_children():
|
||||
i.queue_free()
|
||||
var sold_item:Array=npc_data["sold_item"]
|
||||
for i in sold_item.size():
|
||||
var new_card=TRADE_CARD.instantiate()
|
||||
%other_bag.add_child(new_card)
|
||||
var i_data=sold_item[i]
|
||||
new_card.discount=clamp((2-float(favor)/100),0.5,2)
|
||||
new_card.set_item(i_data)
|
||||
new_card.click.connect(other_bag_card_click.bind([i,i_data]))
|
||||
var self_item=Global.get_all_item_game_data()
|
||||
for i in self_item.size():
|
||||
var new_card=TRADE_CARD.instantiate()
|
||||
%self_bag.add_child(new_card)
|
||||
new_card.discount=clamp(0.5+float(favor)/100,0.5,1.5)
|
||||
new_card.set_item(self_item[i])
|
||||
new_card.click.connect(self_bag_card_click.bind([i,self_item[i]]))
|
||||
|
||||
func other_bag_card_click(arr:Array):
|
||||
var ind:int=arr[0]
|
||||
var data=arr[1]
|
||||
now_select_other_item_ind=ind
|
||||
var item_data=npc_data["sold_item"][ind]
|
||||
%other_item_panel.show()
|
||||
%self_item_panel.hide()
|
||||
%other_item_icon.texture=Global.get_texture(item_data["texture"])
|
||||
%other_item_introduction.text=item_data["introduction"]
|
||||
if int(item_data["price"]*clamp((2-float(favor)/100),0.5,2))>Global.get_currency_game(1):
|
||||
%other_item_accept_btn.disable(true)
|
||||
else:
|
||||
%other_item_accept_btn.disable(false)
|
||||
|
||||
func self_bag_card_click(arr:Array):
|
||||
var ind:int=arr[0]
|
||||
var data=arr[1]
|
||||
now_select_self_item_ind=ind
|
||||
var item_data=data
|
||||
%self_item_panel.show()
|
||||
%other_item_panel.hide()
|
||||
%self_item_icon.texture=Global.get_texture(item_data["texture"])
|
||||
%self_item_introduction.text=item_data["introduction"]
|
||||
if int(item_data["price"]*clamp(0.5+float(favor)/100,0.5,1.5))>npc_data["gold"]:
|
||||
%self_item_accept_btn.disable(true)
|
||||
else:
|
||||
%self_item_accept_btn.disable(false)
|
||||
|
||||
|
||||
|
||||
func _on_other_item_accept_btn_pressed() -> void:
|
||||
var item_data=npc_data["sold_item"][now_select_other_item_ind].duplicate(true)
|
||||
dec_item_from_npc(now_select_other_item_ind)
|
||||
if item_data.has("num"):
|
||||
item_data["num"]=1
|
||||
var price=item_data["price"]
|
||||
|
||||
price=int(price*clamp((2-float(favor)/100),0.5,2)) #计算价格
|
||||
Global.change_currency_game(1,-price)
|
||||
npc_data["gold"]-=price
|
||||
Global.add_item_to_bag(item_data)
|
||||
|
||||
fresh()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_other_item_refuse_btn_pressed() -> void:
|
||||
%other_item_panel.hide()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_self_item_refuse_btn_pressed() -> void:
|
||||
%self_item_panel.hide()
|
||||
pass # Replace with function body.
|
||||
#向NPC背包中添加item
|
||||
func add_item_to_npc(item_data:Dictionary):
|
||||
if item_data["allow_merge"]:
|
||||
for i in npc_data["sold_item"]:
|
||||
if i["id"]==item_data["id"]:
|
||||
if i.has("num"):
|
||||
i["num"]+=item_data["num"]
|
||||
else:
|
||||
i["num"]=2
|
||||
return
|
||||
npc_data["sold_item"].append(item_data)
|
||||
else:
|
||||
npc_data["sold_item"].append(item_data)
|
||||
|
||||
func dec_item_from_npc(ind:int):
|
||||
if npc_data["sold_item"][ind].has("num"):
|
||||
if npc_data["sold_item"]["num"]<=1:
|
||||
npc_data["sold_item"].pop_at(ind)
|
||||
else:
|
||||
npc_data["sold_item"]["num"]-=1
|
||||
pass
|
||||
else:
|
||||
npc_data["sold_item"].pop_at(ind)
|
||||
|
||||
|
||||
|
||||
pass
|
||||
func _on_self_item_accept_btn_pressed() -> void:
|
||||
var item_data=Global.get_all_item_game_data()[now_select_self_item_ind].duplicate(true)
|
||||
if item_data["allow_merge"]:
|
||||
item_data["num"]=1
|
||||
else:
|
||||
item_data.erase("num")
|
||||
|
||||
|
||||
var price=item_data["price"]
|
||||
price=int(price*clamp(0.5+float(favor)/100,0.5,1.5))
|
||||
|
||||
Global.change_currency_game(1,price)
|
||||
npc_data["gold"]-=price
|
||||
Global.decrease_item_num_index(now_select_self_item_ind)
|
||||
add_item_to_npc(item_data)
|
||||
fresh()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_back_pressed() -> void:
|
||||
self.hide()
|
||||
pass # Replace with function body.
|
111
scene/trade.tscn
111
scene/trade.tscn
@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://cewsjbnll1iol"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://cewsjbnll1iol"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bcwud4b8pm6e4" path="res://res/ui/ui_027_single_identification/tuceng384.png" id="1_a6uxr"]
|
||||
[ext_resource type="Script" path="res://scene/trade.gd" id="1_t2yu6"]
|
||||
[ext_resource type="Texture2D" uid="uid://c8383o0fiy1sl" path="res://res/ui/ui_030_trade/juxing6.png" id="2_f8ppp"]
|
||||
[ext_resource type="Texture2D" uid="uid://bp4js1uiutr1f" path="res://res/ui/ui_030_trade/juxing5.png" id="3_8penw"]
|
||||
[ext_resource type="Texture2D" uid="uid://dm88si7behwyq" path="res://res/ui/ui_030_trade/tuceng224.png" id="3_jcx30"]
|
||||
@ -35,6 +36,7 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_t2yu6")
|
||||
|
||||
[node name="bg" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
@ -89,7 +91,8 @@ patch_margin_top = 27
|
||||
patch_margin_right = 38
|
||||
patch_margin_bottom = 29
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/NinePatchRect"]
|
||||
[node name="trade_name" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/NinePatchRect"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@ -129,22 +132,25 @@ anchor_bottom = 0.853994
|
||||
vertical_scroll_mode = 0
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer"]
|
||||
[node name="other_bag" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 30
|
||||
|
||||
[node name="trade_card" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer/HBoxContainer" instance=ExtResource("5_otspc")]
|
||||
[node name="trade_card" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer/other_bag" instance=ExtResource("5_otspc")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="trade_card2" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer/HBoxContainer" instance=ExtResource("5_otspc")]
|
||||
[node name="trade_card2" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer/other_bag" instance=ExtResource("5_otspc")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="trade_card3" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer/HBoxContainer" instance=ExtResource("5_otspc")]
|
||||
[node name="trade_card3" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/ScrollContainer/other_bag" instance=ExtResource("5_otspc")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Panel" type="Panel" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel"]
|
||||
[node name="other_item_panel" type="Panel" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
anchor_left = 0.338907
|
||||
anchor_top = 0.0192837
|
||||
@ -153,7 +159,7 @@ anchor_bottom = 0.933884
|
||||
theme_override_styles/panel = SubResource("StyleBoxTexture_baeen")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel"]
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
@ -164,7 +170,7 @@ grow_horizontal = 0
|
||||
texture = ExtResource("7_44nw7")
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel"]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@ -172,18 +178,20 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel/VBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel/VBoxContainer/HBoxContainer"]
|
||||
[node name="other_item_icon" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 2.0
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel/VBoxContainer/HBoxContainer"]
|
||||
[node name="other_item_introduction" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 3.3
|
||||
@ -192,26 +200,36 @@ theme_override_font_sizes/font_size = 18
|
||||
text = "商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情"
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel/VBoxContainer/HBoxContainer"]
|
||||
[node name="Control" type="Control" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(13.715, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel/VBoxContainer"]
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel/VBoxContainer/HBoxContainer2"]
|
||||
[node name="other_item_refuse" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("8_xo54s")
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/Panel/VBoxContainer/HBoxContainer2"]
|
||||
[node name="other_item_refuse_btn" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer2/other_item_refuse" instance=ExtResource("4_jy8uf")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
|
||||
[node name="other_item_accept" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("9_evq6u")
|
||||
|
||||
[node name="other_item_accept_btn" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer2/other_item_accept" instance=ExtResource("4_jy8uf")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
@ -230,7 +248,8 @@ text = "卖出值:"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/HBoxContainer"]
|
||||
[node name="sold_value" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
theme_override_font_sizes/font_size = 30
|
||||
@ -271,7 +290,8 @@ texture = ExtResource("11_j0iof")
|
||||
expand_mode = 3
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/HBoxContainer/Control2/HBoxContainer"]
|
||||
[node name="other_gold" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/HBoxContainer/Control2/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 34
|
||||
text = "9999"
|
||||
@ -307,22 +327,25 @@ anchor_bottom = 0.853994
|
||||
vertical_scroll_mode = 0
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer"]
|
||||
[node name="self_bag" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 30
|
||||
|
||||
[node name="trade_card" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer/HBoxContainer" instance=ExtResource("5_otspc")]
|
||||
[node name="trade_card" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer/self_bag" instance=ExtResource("5_otspc")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="trade_card2" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer/HBoxContainer" instance=ExtResource("5_otspc")]
|
||||
[node name="trade_card2" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer/self_bag" instance=ExtResource("5_otspc")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="trade_card3" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer/HBoxContainer" instance=ExtResource("5_otspc")]
|
||||
[node name="trade_card3" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/ScrollContainer/self_bag" instance=ExtResource("5_otspc")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Panel" type="Panel" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2"]
|
||||
[node name="self_item_panel" type="Panel" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.338907
|
||||
@ -332,7 +355,7 @@ anchor_bottom = 0.933884
|
||||
theme_override_styles/panel = SubResource("StyleBoxTexture_baeen")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel"]
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
@ -343,7 +366,7 @@ grow_horizontal = 0
|
||||
texture = ExtResource("7_44nw7")
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel"]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@ -351,18 +374,20 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel/VBoxContainer"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel/VBoxContainer/HBoxContainer"]
|
||||
[node name="self_item_icon" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 2.0
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel/VBoxContainer/HBoxContainer"]
|
||||
[node name="self_item_introduction" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 3.3
|
||||
@ -371,26 +396,34 @@ theme_override_font_sizes/font_size = 18
|
||||
text = "商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情商品详情"
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="Control" type="Control" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel/VBoxContainer/HBoxContainer"]
|
||||
[node name="tab" type="Control" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(13.715, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel/VBoxContainer"]
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel/VBoxContainer/HBoxContainer2"]
|
||||
[node name="TextureRect" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("8_xo54s")
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/Panel/VBoxContainer/HBoxContainer2"]
|
||||
[node name="self_item_refuse_btn" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer2/TextureRect" instance=ExtResource("4_jy8uf")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
|
||||
[node name="TextureRect2" type="TextureRect" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 8
|
||||
texture = ExtResource("10_ij1ep")
|
||||
|
||||
[node name="self_item_accept_btn" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer2/TextureRect2" instance=ExtResource("4_jy8uf")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2"]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
@ -409,7 +442,8 @@ text = "返还值:"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/HBoxContainer"]
|
||||
[node name="back_value" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
theme_override_font_sizes/font_size = 30
|
||||
@ -450,7 +484,8 @@ texture = ExtResource("11_j0iof")
|
||||
expand_mode = 3
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/HBoxContainer/Control2/HBoxContainer"]
|
||||
[node name="self_gold" type="Label" parent="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/HBoxContainer/Control2/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 34
|
||||
text = "9999"
|
||||
@ -466,5 +501,11 @@ grow_horizontal = 0
|
||||
texture = ExtResource("3_jcx30")
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="ToolButton" parent="MarginContainer/Panel/TextureRect" instance=ExtResource("4_jy8uf")]
|
||||
[node name="back" parent="MarginContainer/Panel/TextureRect" instance=ExtResource("4_jy8uf")]
|
||||
layout_mode = 1
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer2/other_item_refuse/other_item_refuse_btn" to="." method="_on_other_item_refuse_btn_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel/other_item_panel/VBoxContainer/HBoxContainer2/other_item_accept/other_item_accept_btn" to="." method="_on_other_item_accept_btn_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer2/TextureRect/self_item_refuse_btn" to="." method="_on_self_item_refuse_btn_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/Panel/MarginContainer/VBoxContainer/Panel2/self_item_panel/VBoxContainer/HBoxContainer2/TextureRect2/self_item_accept_btn" to="." method="_on_self_item_accept_btn_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/Panel/TextureRect/back" to="." method="_on_back_pressed"]
|
||||
|
15
scene/trade_card.gd
Normal file
15
scene/trade_card.gd
Normal file
@ -0,0 +1,15 @@
|
||||
extends TextureRect
|
||||
signal click
|
||||
|
||||
var discount:float=0
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
var data:Dictionary
|
||||
func set_item(item_data:Dictionary):
|
||||
data=item_data
|
||||
%face.texture=Global.get_texture(data["texture"])
|
||||
%price.text="价格:"+str(int(data["price"]*discount))
|
||||
|
||||
|
||||
func _on_trade_card_btn_spec_pressed() -> void:
|
||||
click.emit()
|
||||
pass # Replace with function body.
|
@ -1,14 +1,16 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://o88rhxrwmp84"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://o88rhxrwmp84"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c3iird5npbno2" path="res://res/ui/ui_030_trade/tuceng159.png" id="1_yy2dd"]
|
||||
[ext_resource type="Texture2D" uid="uid://c22roiesh6vks" path="res://res/ui/ui_030_trade/tuceng160.png" id="2_jf0t0"]
|
||||
[ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="3_g0onc"]
|
||||
[ext_resource type="Script" path="res://scene/trade_card.gd" id="2_qimuw"]
|
||||
[ext_resource type="Script" path="res://scene/trade_card_btn_spec.gd" id="4_t38hb"]
|
||||
|
||||
[node name="trade_card" type="TextureRect"]
|
||||
offset_right = 131.0
|
||||
offset_bottom = 286.0
|
||||
texture = ExtResource("1_yy2dd")
|
||||
expand_mode = 3
|
||||
script = ExtResource("2_qimuw")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
@ -21,20 +23,47 @@ texture = ExtResource("2_jf0t0")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="TextureRect"]
|
||||
[node name="face" type="TextureRect" parent="TextureRect"]
|
||||
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="ToolButton" parent="." instance=ExtResource("3_g0onc")]
|
||||
layout_mode = 0
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
[node name="price" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -64.8134
|
||||
offset_top = -54.0
|
||||
offset_right = -9.81343
|
||||
offset_bottom = -9.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
theme_override_font_sizes/font_size = 24
|
||||
text = "价格:100"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="trade_card_btn_spec" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
focus_mode = 0
|
||||
flat = true
|
||||
script = ExtResource("4_t38hb")
|
||||
|
||||
[connection signal="button_down" from="trade_card_btn_spec" to="trade_card_btn_spec" method="on_button_down"]
|
||||
[connection signal="button_up" from="trade_card_btn_spec" to="trade_card_btn_spec" method="on_button_up"]
|
||||
[connection signal="pressed" from="trade_card_btn_spec" to="." method="_on_trade_card_btn_spec_pressed"]
|
||||
|
13
scene/trade_card_btn_spec.gd
Normal file
13
scene/trade_card_btn_spec.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends ToolButton
|
||||
const BAG_SIDE_CARD_INTRODUCTION = preload("res://scene/bag_side_card_introduction.tscn")
|
||||
|
||||
func _get_tooltip(at_position: Vector2) -> String:
|
||||
|
||||
return JSON.stringify(get_parent().data)
|
||||
pass
|
||||
|
||||
func _make_custom_tooltip(for_text: String) -> Object:
|
||||
var new_card=BAG_SIDE_CARD_INTRODUCTION.instantiate()
|
||||
new_card.data=JSON.parse_string(for_text)
|
||||
return new_card
|
||||
pass
|
Loading…
Reference in New Issue
Block a user