diff --git a/addons/popupwindow/pop_up_window.gd b/addons/popupwindow/pop_up_window.gd index 75d6111..cc5c2b2 100644 --- a/addons/popupwindow/pop_up_window.gd +++ b/addons/popupwindow/pop_up_window.gd @@ -13,5 +13,6 @@ func pop_up_text(text:String,pos:Vector2,H_limit:float,label_settings:LabelSetti new_text.custom_minimum_size.x=H_limit pop_up_control(new_text,pos) new_text.set_label(label_settings) + new_text.set_mes(text) %Container.show() pass diff --git a/autoload/database/script/database.gd b/autoload/database/script/database.gd index 2b4fb0b..59b91dd 100644 --- a/autoload/database/script/database.gd +++ b/autoload/database/script/database.gd @@ -31,6 +31,11 @@ var identifation_data:Dictionary var type_json_path:String="res://json/type.json" var type_data:Dictionary + +#特质数据 +var special_json_path:String="res://json/special.json" +var special_data:Dictionary + #角色修饰数据的存储路径 var character_embellish_data_path:String="user://emblish.data" var character_embellish_data:Dictionary={ @@ -78,6 +83,7 @@ func _ready() -> void: load_word_data() load_identifation_data() load_type_data() + load_special_data() #加载当前图片数据 func load_texture_data(): var file=FileAccess.open(texture_json_path,FileAccess.READ) @@ -185,6 +191,16 @@ func load_type_data(): var dictionary:Dictionary=JSON.parse_string(str) type_data=dictionary pass + +func load_special_data(): + var file=FileAccess.open(special_json_path,FileAccess.READ) + var str=file.get_as_text() + var dictionary:Dictionary=JSON.parse_string(str) + for i in dictionary.keys(): + #排除注释 + if i !="#": + dictionary[i]["id"]=i + special_data=dictionary #获取图标 func get_texture(id:String): if texture_data.has(id): @@ -319,3 +335,17 @@ func get_type_name(type:int)->String: #获取全部主要类型字典 func get_all_main_type(): return type_data["main"].duplicate() + +#获取特质数据 +func get_special_data(id:String): + if special_data.has(id): + return special_data[id].duplicate(true) + else: + return null + +#获取特质类型 +func get_special_type(id:String): + if special_data.has(id): + return special_data[id]["type"] + else: + return "" diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index b5bab75..e210873 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -83,7 +83,7 @@ var system_config_data:Dictionary={ var system_game_data_path:String="user://system_game.data" #局外游戏数据 var system_game_data:Dictionary={ - "unlock_character":["test_character_01","test_character_02"], + "unlock_character":["test_character_01","test_character_02","Rolland"], #全局物品 "item":[], "jifen":100, @@ -337,6 +337,24 @@ var now_game_data:Dictionary={ "item_could_make":["item_06"] } +#当前是否应该展示开始事件 +func should_show_init_event()->bool: + var now_script_data=now_game_data["script_data"] + if not now_script_data.has("init_event"): + return false + if not now_script_data.has("init_finished"): + return true + return false +#获取初始事件 +func get_init_event(): + var now_script_data=now_game_data["script_data"] + return now_script_data["init_event"] +#执行完初始事件后使用 +func shown_init_event(): + var now_script_data=now_game_data["script_data"] + now_script_data["init_finished"]=true + + #返回当前可以制作的物品ID func get_now_game_item_could_make(): return now_game_data["item_could_make"].duplicate() @@ -491,14 +509,26 @@ var triger:Dictionary={ #装备升级界面展示触发器 "show_level_up":func (data):now_game_flow.show_item_level_up(), "show_warehouse":func(data):now_game_flow.show_warehouse(), - "make_card":func(data):now_game_flow.show_make_card() + "make_card":func(data):now_game_flow.show_make_card(), + #人类特质触发器,触发为当前游戏人物属性随机加一 + "human":func(data):human_triger() } + #使用事件触发器 func call_triger(triger_type:String,data): if triger.has(triger_type): return triger[triger_type].call(data) else: return null +#人类特质触发器 +func human_triger(): + var character_data:Dictionary=now_game_data["character_data"] + var basic_attribute_dic:Dictionary=character_data["basic_attribute"] + var size=basic_attribute_dic.size() + var rand:int=randi_range(0,size-1) + var key:String=basic_attribute_dic.keys()[rand] + basic_attribute_dic[key]+=1 + pass #条件触发器(用于返回是否的条件判定结果) var condition_triger:Dictionary={ "date_limit":func (data:Dictionary):return TimeTool.is_in_date(data,get_time_dictionary()), diff --git a/class/character_tool/character_tool.gd b/class/character_tool/character_tool.gd index ad57257..2d6d01f 100644 --- a/class/character_tool/character_tool.gd +++ b/class/character_tool/character_tool.gd @@ -118,8 +118,12 @@ static var attribute_key_to_name_dic:Dictionary={ "MND":"意志", "LUC":"幸运", "AM":"魅力", + "MOR":"道德", + "LAF":"守序", + "HP":"生命", "SP":"精神", + "VIT":"体力", "AD":"物理伤害", "AP":"法术强度", @@ -248,3 +252,31 @@ static func get_character_use_identification_card(character_data:Dictionary,item #计算白值 basic_attribute[j]+=add_attribute[j] return res + +#获取一个角色身上对应类型的特质 +static func get_all_special_type(character_data:Dictionary,target_type:String)->Array[CharacterSpecial]: + var special_all=character_data["special"] + var res:Array[CharacterSpecial]=[] + for i in special_all: + if Database.get_special_type(i)==target_type: + var target_data=Database.get_special_data(i) + var new_special:CharacterSpecial=CharacterSpecial.new() + new_special.data=target_data + res.append(new_special) + + return res + + + + pass +#特质工具类 +class CharacterSpecial: + var data:Dictionary + + #触发特质 + func call_triger(): + if data.has("triger") and data["triger"] is Array: + var triget_arr:Array=data["triger"] + for i in triget_arr: + Global.call_triger(i["type"],i["data"]) + diff --git a/json/character.json b/json/character.json index 3aaa330..a624bf4 100644 --- a/json/character.json +++ b/json/character.json @@ -45,10 +45,7 @@ }, "special":[ - { - "name":"倾国倾城", - "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" - } + ], "ability":[ { @@ -138,10 +135,7 @@ }, "special":[ - { - "name":"倾国倾城", - "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" - } + ], "ability":[ { @@ -233,10 +227,7 @@ }, "special":[ - { - "name":"倾国倾城", - "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" - } + ], "ability":[ { @@ -275,4 +266,68 @@ "card_as_NPC":[] }, + "Rolland":{ + "name":"罗兰", + "head":"?", + "star":3, + "skin":[ + { + "name":"皮肤1", + "skin_card_face":"?", + "card_face":"?", + "character":"?" + }, + { + "name":"皮肤2", + "skin_card_face":"?", + "card_face":"?", + "character":"?" + }, + { + "name":"皮肤3", + "skin_card_face":"?", + "card_face":"?", + "character":"?" + } + ], + "skin_now_use":0, + "unlocked_skin":[0,1,2], + "basic_mes":{ + "type":0, + "place":"地点", + "sex":0, + "race":"种族", + "birthday":"1982-02-06", + "introduction":"这是一个介绍", + }, + "basic_attribute":{ + "CON":70, + "AGI":72, + "INT":68, + "WIS":77, + "STR":69, + "MND":51, + "LUC":46, + "AM":40, + "MOR":50, + "LAF":50 + }, + "start":[ + { + "name":"穷困潦倒的侦探", + "introduction":"罗兰是一位不知名的侦探,尽管他有着一定出色的能力却不懂得如何经营从而住在一个破旧的出租屋浑浑噩噩的过着日子,如何他才能走出这恶性循环,他需要静静思考。", + "add_buff":[], + "del_buff":[] + }, + { + "name":"一场噩梦?!", + "introduction":"罗兰在自己的出租屋中惊醒,刚刚做了一个奇怪的噩梦,一直怪异的触手吞噬了整个房间,诡异的低吟传遍整个房间,这是怎么回事?罗兰抽着烟静静地思考着,他可以把这一切视作一次偶然,还是说没那么简单?", + "add_buff":[], + "del_buff":[] + }, + ], + "special":["human"], + "unclocked_start":[0,1], + "start_now_use":0, + } } diff --git a/json/event.json b/json/event.json index f2163b9..5456672 100644 --- a/json/event.json +++ b/json/event.json @@ -333,5 +333,19 @@ ] } ] + }, + "paoxiao1920start":{ + "name":"《贡比涅森林停战协定》", + "texture":"paoxiao1920gongbinietingzhan", + "text":"11月11日法国时间凌晨5时,福煦代表协约国与德国代表在法国东北部贡比涅森林雷道车站的福煦车厢里签订了停战协定,(一译《康边停战协定》),亦称《协约国对德停战协定》。协定签订当日即生效。", + "choice":[ + { + "name":"战争终于结束了...", + "triger":[{ + "type":"end_event", + "data":"" + }] + } + ] } } diff --git a/json/scene.json b/json/scene.json index fe3b991..6711c90 100644 --- a/json/scene.json +++ b/json/scene.json @@ -47,6 +47,10 @@ { "name":"社交", "event":"event_socialize" + }, + { + "name":"咆哮开局", + "event":"paoxiao1920start" } ], "linked_scene":[{ diff --git a/json/script.json b/json/script.json index 3922d09..6a3fac1 100644 --- a/json/script.json +++ b/json/script.json @@ -1,22 +1,24 @@ { "script_001":{ - "name":"测试剧本001", - "texture":"test_scene", - "side_texture":"texture_test", - "introduction":"这是一个测试剧本", + "name":"咆哮的1920年代", + "texture":"paoxiao1920title", + "side_texture":"paoxiao1920title", + "introduction":"1920 年代是经济增长与繁荣的年代,一个经济和文化的新时代在向人们招手。世界大战的恐怖被拋诸脑后。爵士乐兴起,大众的艺术追求得到满足,人们对更好生活的向往也能够实现。从北美洲的纽约、芝加哥、新奥尔良,到欧洲的伦敦、巴黎、柏林这样的大都市,在这个时代告别过去的传统成为了现实。从世界大战中诞生的现代化正在召唤着人们。汽车、电影和收音机就是生动的例子,这些新技术开始影响人们的日常生活。同时禁酒令和反英雄的崛起、大量的罢工、暴力骚乱甚至谋杀、女性获得新的权力、战后经济短暂的繁荣背后隐藏着许多危机。", "type":0, "init_date":{ - "year":1860, + "year":1918, + "month":11, + "day":11, + "hour":9 + }, + "finish_date":{ + "year":1930, "month":1, "day":1, }, - "finish_date":{ - "year":1860, - "month":2, - "day":1, - }, "init_scene":"scene_01", + "init_event":"paoxiao1920start", }, "script_002":{ diff --git a/json/special.json b/json/special.json new file mode 100644 index 0000000..da6a9ad --- /dev/null +++ b/json/special.json @@ -0,0 +1,15 @@ +{ + "#":"特质json字典", + + "human":{ + "name":"人类", + "introduction":"开局:随机能力等级+1", + "type":"start_game", + "triger":[{ + "type":"human", + "data":"" + }], + } + + +} diff --git a/json/texture.json b/json/texture.json index 81009fd..a2bbb09 100644 --- a/json/texture.json +++ b/json/texture.json @@ -16,5 +16,7 @@ "fish_preview":"res://test/texture/fish_preview.jpg", "fish_success":"res://test/texture/fish_success.jpg", "fish_fail":"res://test/texture/fish_fail.jpg", - "rod":"res://test/texture/rod.jpg" + "rod":"res://test/texture/rod.jpg", + "paoxiao1920title":"res://test/texture/paoxiao1920_demo_title.jpg", + "paoxiao1920gongbinietingzhan":"res://test/texture/paoxiao1920gongbinietingzhan.png" } diff --git a/scene/basic_message.gd b/scene/basic_message.gd index c580b94..f4cdb5c 100644 --- a/scene/basic_message.gd +++ b/scene/basic_message.gd @@ -71,9 +71,13 @@ func init_from_data(): if data.has("special"): var special_data=data["special"] for i in special_data: + var charactr_special_data=Database.get_special_data(i) + if charactr_special_data==null: + continue + var new_button=ABILITY_BUTTON.instantiate() - new_button.show_mes=i["introduction"] - new_button.text=i["name"] + new_button.show_mes=charactr_special_data["introduction"] + new_button.text=charactr_special_data["name"] %special_container.add_child(new_button) if data.has("ability"): var ability_data=data["ability"] @@ -283,9 +287,10 @@ func _ready() -> void: for i in equipment_group: i.fresh.connect(fresh) - Global.set_now_character("test_character_01") - data=Global.get_now_character_data() - init_from_data() + #Global.set_now_character("test_character_01") + if is_in_game: + data=Global.get_now_character_data() + init_from_data() connect_button() diff --git a/scene/basic_message.tscn b/scene/basic_message.tscn index fd1dc12..8f58c19 100644 --- a/scene/basic_message.tscn +++ b/scene/basic_message.tscn @@ -346,11 +346,12 @@ layout_mode = 2 size_flags_vertical = 3 size_flags_stretch_ratio = 939.0 theme_override_styles/panel = SubResource("StyleBoxEmpty_81i7t") -current_tab = 0 +current_tab = 1 clip_tabs = false tabs_visible = false [node name="basic_mes" type="MarginContainer" parent="VBoxContainer/TabContainer"] +visible = false layout_mode = 2 theme_override_constants/margin_right = 19 theme_override_constants/margin_bottom = 43 @@ -1166,7 +1167,6 @@ vertical_alignment = 1 metadata/_edit_use_anchors_ = true [node name="special_ability" type="MarginContainer" parent="VBoxContainer/TabContainer"] -visible = false layout_mode = 2 theme_override_constants/margin_left = 54 theme_override_constants/margin_top = 8 diff --git a/scene/character_select.gd b/scene/character_select.gd index 7efaa0b..ecf61b1 100644 --- a/scene/character_select.gd +++ b/scene/character_select.gd @@ -23,6 +23,7 @@ func fresh(): for i in character_add_pos.get_children(): i.queue_free() for i in Global.system_game_data["unlock_character"]: + print(i) var new_character=CHARACTER_SELECT_CARD.instantiate() character_add_pos.add_child(new_character) new_character.set_data(Database.get_character_data(i)) @@ -33,6 +34,7 @@ func _ready() -> void: func pressed(data,node,is_select): if is_select: + print(data) now_select_data=data now_select_node=node else: @@ -44,6 +46,12 @@ func pressed(data,node,is_select): func _on_start_pressed() -> void: + print(now_select_data) Global.now_game_data.character_data=now_select_data + SceneManager.change_scene_to("res://scene/game_flow.tscn") + + var all_special:Array[CharacterTool.CharacterSpecial]=CharacterTool.get_all_special_type(Global.now_game_data.character_data,"start_game") + for i in all_special: + i.call_triger() pass # Replace with function body. diff --git a/scene/event.tscn b/scene/event.tscn index 5023b16..0a461ab 100644 --- a/scene/event.tscn +++ b/scene/event.tscn @@ -156,9 +156,9 @@ texture = ExtResource("4_tkp1l") [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/NinePatchRect"] layout_mode = 1 anchors_preset = -1 -anchor_left = 0.0322052 -anchor_top = 0.127872 -anchor_right = 0.465065 +anchor_left = 0.0319767 +anchor_top = 0.152273 +anchor_right = 0.465116 anchor_bottom = 1.0 metadata/_edit_use_anchors_ = true diff --git a/scene/game_flow.gd b/scene/game_flow.gd index 7b89232..f4c9694 100644 --- a/scene/game_flow.gd +++ b/scene/game_flow.gd @@ -60,7 +60,7 @@ func set_scene(id:String): touch_data[i]["name"]=i new_touch.set_data(touch_data[i]) new_touch.judge() - + try_init_event() func judge_touch(): for i in touch_add_pos.get_children(): @@ -171,3 +171,9 @@ func show_make_card(): pass +#检测当前是否应该展示初始事件,如果是,则展示事件并记录 +func try_init_event(): + if Global.should_show_init_event(): + var init_event=Global.get_init_event() + show_event(init_event) + Global.shown_init_event() diff --git a/scene/select.tscn b/scene/select.tscn index 661a1d0..7afc6a8 100644 --- a/scene/select.tscn +++ b/scene/select.tscn @@ -430,16 +430,21 @@ patch_margin_right = 90 patch_margin_bottom = 56 metadata/_edit_use_anchors_ = true -[node name="script_introduction" type="Label" parent="NinePatchRect"] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.0976744 +[node name="ScrollContainer" type="ScrollContainer" parent="NinePatchRect"] +layout_mode = 0 +anchor_left = 0.116279 anchor_top = 0.137931 -anchor_right = 0.809302 -anchor_bottom = 0.901996 +anchor_right = 0.797672 +anchor_bottom = 0.907441 +horizontal_scroll_mode = 0 +metadata/_edit_use_anchors_ = true + +[node name="script_introduction" type="Label" parent="NinePatchRect/ScrollContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 theme_override_colors/font_color = Color(0, 0, 0, 1) -theme_override_font_sizes/font_size = 34 +theme_override_font_sizes/font_size = 30 text = "剧本介绍剧本介绍 剧本介绍剧本介绍 剧本介绍剧本介绍 diff --git a/test/texture/paoxiao1920_demo_title.jpg b/test/texture/paoxiao1920_demo_title.jpg new file mode 100644 index 0000000..af6b4a6 Binary files /dev/null and b/test/texture/paoxiao1920_demo_title.jpg differ diff --git a/test/texture/paoxiao1920_demo_title.jpg.import b/test/texture/paoxiao1920_demo_title.jpg.import new file mode 100644 index 0000000..c05f6bf --- /dev/null +++ b/test/texture/paoxiao1920_demo_title.jpg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cfwhr6xjfpseu" +path="res://.godot/imported/paoxiao1920_demo_title.jpg-01950cc867d4ad6eb3e46d8591be20ba.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://test/texture/paoxiao1920_demo_title.jpg" +dest_files=["res://.godot/imported/paoxiao1920_demo_title.jpg-01950cc867d4ad6eb3e46d8591be20ba.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +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=1 diff --git a/test/texture/paoxiao1920gongbinietingzhan.png b/test/texture/paoxiao1920gongbinietingzhan.png new file mode 100644 index 0000000..a4364be Binary files /dev/null and b/test/texture/paoxiao1920gongbinietingzhan.png differ diff --git a/test/texture/paoxiao1920gongbinietingzhan.png.import b/test/texture/paoxiao1920gongbinietingzhan.png.import new file mode 100644 index 0000000..559ffca --- /dev/null +++ b/test/texture/paoxiao1920gongbinietingzhan.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://jyorl3y2jemo" +path="res://.godot/imported/paoxiao1920gongbinietingzhan.png-b1f561041c6d3c68ca9bee61aab8362e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://test/texture/paoxiao1920gongbinietingzhan.png" +dest_files=["res://.godot/imported/paoxiao1920gongbinietingzhan.png-b1f561041c6d3c68ca9bee61aab8362e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +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=1