From 08317b644f012cc5db7dd03c53266ea170100abf Mon Sep 17 00:00:00 2001 From: TsubakiLoL <2789646812@qq.com> Date: Fri, 11 Oct 2024 17:14:54 +0800 Subject: [PATCH] 10.11 --- autoload/global/script/global.gd | 16 ++++++++++-- json/npc.json | 12 +++++++-- scene/ability_to_cards.tscn | 1 + scene/card_state_machine/card_machine.gd | 2 ++ scene/fight.gd | 1 + scene/game_flow.gd | 7 ++++++ scene/game_flow.tscn | 8 +++++- scene/map.gd | 2 +- scene/points_settlement.gd | 18 ++++++++++++++ scene/points_settlement.tscn | 31 ++++++++++++++---------- scene/points_settlement_mono.gd | 6 +++++ scene/points_settlement_mono.tscn | 11 ++++++--- scene/select.gd | 1 + 13 files changed, 94 insertions(+), 22 deletions(-) create mode 100644 scene/points_settlement.gd create mode 100644 scene/points_settlement_mono.gd diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index 1264ae6..b5bab75 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -326,6 +326,7 @@ var now_game_data:Dictionary={ "map":"map_01", "move_ability":1, "time_unix":0, + "finish_unix":0, #背包卡牌(废弃) "card_in_bag":["card_03","card_03","card_02","card_02","card_01","card_01","card_01","card_01"], #互动点触摸随机结果记忆字典 @@ -348,8 +349,12 @@ func get_now_game_npc_data(NPC_id:String): else: #填入npc数据,并实例出售卖的道具()可以通过在get item data上施加影响来实现随机 var n_data=Database.get_npc_data(NPC_id) - for i in n_data["sold_item"].size(): - n_data["sold_item"][i]=Database.get_item_data(n_data["sold_item"][i]) + var sold_item_array:Array=[] + for i in n_data["sold_item"].keys(): + var item_data=Database.get_item_data(i) + item_data["num"]=n_data["sold_item"][i] + sold_item_array.append(item_data) + n_data["sold_item"]=sold_item_array now_game_data["NPC_data"][NPC_id]=n_data return now_npc_data[NPC_id] #获取当前角色与NPC的好感度 @@ -652,6 +657,13 @@ func get_now_character_data(): #设置当前角色(游戏内) func set_now_character(id:String): now_game_data["character_data"]=Database.get_character_data(id) +#设置当前时间和剧本结束时间,用于局内初始化 +func set_now_time(time_dic:Dictionary,finish_time_dic:Dictionary): + now_game_data["time_unix"]=Time.get_unix_time_from_datetime_dict(time_dic) + now_game_data["finish_unix"]=Time.get_unix_time_from_datetime_dict(finish_time_dic) +#当前剧本是否完结 +func is_script_finish()->bool: + return now_game_data["time_unix"]>=now_game_data["finish_unix"] func _ready() -> void: diff --git a/json/npc.json b/json/npc.json index 5463afd..955320c 100644 --- a/json/npc.json +++ b/json/npc.json @@ -1,13 +1,21 @@ { "npc_01":{ "name":"测试NPC1", - "sold_item":["item_01","item_01","item_01","item_02","item_08","item_08","item_08","item_08","item_08","item_08","item_08"], + "sold_item":{ + "item_01":1, + "item_02":1, + "item_08":100 + }, "init_favor":50, "gold":9999 }, "npc_02":{ "name":"测试NPC2", - "sold_item":["item_03","item_04","item_06","item_06","item_06","item_06","item_06","item_06","item_06",], + "sold_item":{ + "item_03":1, + "item_04":1, + "item_06":100 + }, "init_favor":0, "gold":7777 } diff --git a/scene/ability_to_cards.tscn b/scene/ability_to_cards.tscn index e736a54..3aeacc1 100644 --- a/scene/ability_to_cards.tscn +++ b/scene/ability_to_cards.tscn @@ -196,6 +196,7 @@ vertical_alignment = 1 metadata/_edit_use_anchors_ = true [node name="TextureRect" type="TextureRect" parent="."] +layout_mode = 0 size_flags_horizontal = 0 texture = ExtResource("10_ucexl") diff --git a/scene/card_state_machine/card_machine.gd b/scene/card_state_machine/card_machine.gd index 8ee46ee..fb1713c 100644 --- a/scene/card_state_machine/card_machine.gd +++ b/scene/card_state_machine/card_machine.gd @@ -9,6 +9,8 @@ var card_arr:Array[Card]=[] var queue_card:Array[Card]=[] var energy_start:int=3 var energy:int=0 +#当前是否可以出牌,用于不在自己回合的时候锁住手牌 +var could_out_card:bool=true func get_index_position(index:int)->Vector2: var center=size/2 var left=center-Vector2(distance*card_arr.size()/2,0) diff --git a/scene/fight.gd b/scene/fight.gd index cf179e9..3cf4b81 100644 --- a/scene/fight.gd +++ b/scene/fight.gd @@ -107,6 +107,7 @@ func sort(a,b)->bool: pass +#获取全部根据先手排序的单位 func get_sort_all_unit(): var all_unit=get_all_unit() var sort_arr:Array=[] diff --git a/scene/game_flow.gd b/scene/game_flow.gd index e870e85..01ecbbc 100644 --- a/scene/game_flow.gd +++ b/scene/game_flow.gd @@ -18,6 +18,9 @@ const GAME_FLOW_EVENT = preload("res://scene/game_flow_event.tscn") const GAME_FLOW_PLACE = preload("res://scene/game_flow_place.tscn") var scene_data:Dictionary func _ready() -> void: + if Global.is_script_finish(): + %points_settlement.show() + %points_settlement.show_mes({}) set_scene(Global.get_now_scene()) update_date() Global.time_changed.connect(update_date) @@ -61,6 +64,7 @@ func set_scene(id:String): func judge_touch(): for i in touch_add_pos.get_children(): i.judge() +#交互点按下触发,传入交互点的字典数据(暂未实现) func touch_click(data:Dictionary): @@ -72,6 +76,9 @@ func update_date(): var time_dic=Global.get_time_dictionary() date.text=str(time_dic["year"])+"/"+str(time_dic["month"])+"/"+str(time_dic["day"]) judge_touch() + if Global.is_script_finish(): + %points_settlement.show() + %points_settlement.show_mes({}) func place_pressed(data:Dictionary): Global.move_scene(data["id"],data["distance"]) diff --git a/scene/game_flow.tscn b/scene/game_flow.tscn index e72ac4a..b2d09b7 100644 --- a/scene/game_flow.tscn +++ b/scene/game_flow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=34 format=3 uid="uid://bht5sd88340s5"] +[gd_scene load_steps=35 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"] @@ -27,6 +27,7 @@ [ext_resource type="PackedScene" uid="uid://b0xgo1tguum73" path="res://scene/item_level_up.tscn" id="24_7ni35"] [ext_resource type="PackedScene" uid="uid://g38jdt16mvek" path="res://scene/warehouse.tscn" id="25_ep25b"] [ext_resource type="PackedScene" uid="uid://dou3d6026w2ke" path="res://scene/ability_to_cards.tscn" id="27_r2101"] +[ext_resource type="PackedScene" uid="uid://bnlkynji85qgd" path="res://scene/points_settlement.tscn" id="28_87hhx"] [sub_resource type="Gradient" id="Gradient_4wq1v"] @@ -494,6 +495,11 @@ unique_name_in_owner = true visible = false layout_mode = 1 +[node name="points_settlement" parent="." instance=ExtResource("28_87hhx")] +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/map.gd b/scene/map.gd index 7b36360..93c2356 100644 --- a/scene/map.gd +++ b/scene/map.gd @@ -94,7 +94,7 @@ func set_map(id:String): func update_time(): var time_dic:Dictionary=Global.get_time_dictionary() date.text=str(time_dic["year"])+"/"+str(time_dic["month"])+"/"+str(time_dic["day"]) - time.text=str(time_dic["hour"])+":"+str(time_dic["minute"]) + time.text=str(time_dic["hour"])+":"+"%02d"%[time_dic["minute"]] func resize_map(before_rag:float,rag:float,mouse_pos:Vector2,init:Vector2): var l=rag/before_rag var now_pos=Vector2(scroll_container.scroll_horizontal,scroll_container.scroll_vertical)+mouse_pos diff --git a/scene/points_settlement.gd b/scene/points_settlement.gd new file mode 100644 index 0000000..fb29429 --- /dev/null +++ b/scene/points_settlement.gd @@ -0,0 +1,18 @@ +extends Control + +const POINTS_SETTLEMENT_MONO = preload("res://scene/points_settlement_mono.tscn") +# Called when the node enters the scene tree for the first time. + + +func show_mes(data:Dictionary): + for i in %mono_add_pos.get_children(): + i.queue_free() + for i in data.keys(): + var new_mono=POINTS_SETTLEMENT_MONO.instantiate() + %mono_add_pos.add_child(new_mono) + new_mono.set_data(i,str(data[i])) + + +func _on_accept_pressed() -> void: + SceneManager.change_scene_to("res://scene/main.tscn") + pass # Replace with function body. diff --git a/scene/points_settlement.tscn b/scene/points_settlement.tscn index 83cac03..65e3424 100644 --- a/scene/points_settlement.tscn +++ b/scene/points_settlement.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=9 format=3 uid="uid://bnlkynji85qgd"] +[gd_scene load_steps=10 format=3 uid="uid://bnlkynji85qgd"] [ext_resource type="Texture2D" uid="uid://clb456ib4hyjp" path="res://res/ui/ui_023_points_settlement/tuceng2.png" id="1_2frae"] +[ext_resource type="Script" path="res://scene/points_settlement.gd" id="1_ytmab"] [ext_resource type="Texture2D" uid="uid://yiwtqlgwcuss" path="res://res/ui/ui_023_points_settlement/tuceng1.png" id="2_75kye"] [ext_resource type="Texture2D" uid="uid://b2f4rel1x3eqf" path="res://res/ui/ui_023_points_settlement/tuceng322.png" id="3_88lx3"] [ext_resource type="Texture2D" uid="uid://l3sc0abv2m6w" path="res://res/ui/ui_023_points_settlement/tuceng326.png" id="4_2ysq8"] @@ -19,6 +20,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_ytmab") [node name="back" type="TextureRect" parent="."] layout_mode = 1 @@ -72,7 +74,8 @@ text = "积分结算" vertical_alignment = 1 metadata/_edit_use_anchors_ = true -[node name="GridContainer" type="GridContainer" parent="Panel"] +[node name="mono_add_pos" type="GridContainer" parent="Panel"] +unique_name_in_owner = true layout_mode = 0 offset_left = 592.0 offset_top = 106.0 @@ -80,34 +83,34 @@ offset_right = 1700.0 offset_bottom = 397.0 columns = 3 -[node name="points_settlement_mono" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono10" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono10" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono2" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono2" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono3" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono3" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono4" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono4" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono5" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono5" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono6" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono6" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono7" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono7" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono8" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono8" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 -[node name="points_settlement_mono9" parent="Panel/GridContainer" instance=ExtResource("5_3bmwc")] +[node name="points_settlement_mono9" parent="Panel/mono_add_pos" instance=ExtResource("5_3bmwc")] layout_mode = 2 [node name="TextureRect2" type="TextureRect" parent="."] @@ -135,5 +138,7 @@ text = "确定" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ToolButton" parent="TextureRect2" instance=ExtResource("7_u10rb")] +[node name="accept" parent="TextureRect2" instance=ExtResource("7_u10rb")] layout_mode = 1 + +[connection signal="pressed" from="TextureRect2/accept" to="." method="_on_accept_pressed"] diff --git a/scene/points_settlement_mono.gd b/scene/points_settlement_mono.gd new file mode 100644 index 0000000..1656998 --- /dev/null +++ b/scene/points_settlement_mono.gd @@ -0,0 +1,6 @@ +extends HBoxContainer + +func set_data(key:String,value:String): + %key.text=key + %value.text=value + pass diff --git a/scene/points_settlement_mono.tscn b/scene/points_settlement_mono.tscn index 0aa4bef..672e05b 100644 --- a/scene/points_settlement_mono.tscn +++ b/scene/points_settlement_mono.tscn @@ -1,17 +1,22 @@ -[gd_scene format=3 uid="uid://cbfi024gnq3ec"] +[gd_scene load_steps=2 format=3 uid="uid://cbfi024gnq3ec"] + +[ext_resource type="Script" path="res://scene/points_settlement_mono.gd" id="1_im3m7"] [node name="points_settlement_mono" type="HBoxContainer"] offset_right = 40.0 offset_bottom = 40.0 size_flags_horizontal = 3 +script = ExtResource("1_im3m7") -[node name="Label" type="Label" parent="."] +[node name="key" type="Label" parent="."] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 theme_override_font_sizes/font_size = 28 text = "结算详情:" -[node name="Label2" type="Label" parent="."] +[node name="value" type="Label" parent="."] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 theme_override_font_sizes/font_size = 28 diff --git a/scene/select.gd b/scene/select.gd index ef1e684..c44a733 100644 --- a/scene/select.gd +++ b/scene/select.gd @@ -146,6 +146,7 @@ func _on_enter_button_pressed() -> void: if script_data!=null: Global.now_game_data["script_data"]=script_data Global.set_now_scene(script_data["init_scene"]) + Global.set_now_time(script_data["init_date"],script_data["finish_date"]) $DrawerContainer2.change_open(true) pass # Replace with function body.