diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index 6496091..ab677d5 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -59,11 +59,36 @@ func delete_card(card_id:String)->bool: else: now_game_data["card_in_bag"].pop_at(ind) return true -#使用卡牌 -func use_card(card_data:Dictionary,target=null): +#使用卡牌,character为使用者,target为目标,card_data为使用的卡牌数据 +func use_card(card_data:Dictionary,user=null,target=null): print("执行了卡牌:\n"+str(card_data)+"\n目标"+str(target)) - - pass + if card_data.has("triger"): + for funcitem in card_data["triger"]: + var _func=Callable(self,funcitem.func) + var value:Array=funcitem.value.duplicate() + for i in value.size(): + if value[i] is String and value[i]=="user": + value[i]=user + elif value[i] is String and value[i]=="target": + value[i]=target + _func.callv(value) +##下面是例子 +##打击单位 +func hit(target,value): + if target is FightCharacterCard ||target is FightEnermyCard: + target.HP-=value +#打击全部单位 +func hit_all(value): + var all_character=now_fight_scene.get_all_unit() + for i in all_character: + i.HP-=value +#回血 +func recover(target,value): + if target is FightCharacterCard ||target is FightEnermyCard: + target.HP+=value + + + func get_all_card()->Array: return now_game_data["card_in_bag"].duplicate() func get_move_ability(): @@ -301,7 +326,7 @@ func get_character_data(id:String): else: return null #获取全部角色数据 -func get_all_character(id:String)->Dictionary: +func get_all_character()->Dictionary: return character_data.duplicate(true) #获取对应ID的地图数据 func get_map_data(id:String): diff --git a/class/character_tool/character_tool.gd b/class/character_tool/character_tool.gd index 2a754b8..33c6ecd 100644 --- a/class/character_tool/character_tool.gd +++ b/class/character_tool/character_tool.gd @@ -49,7 +49,6 @@ static func cacul_fight_attribute(character_data:Dictionary)->Dictionary: res["SP"]=INT+MND res["VIT"]=120 - pass return res pass @@ -61,8 +60,43 @@ static func get_character_name(character_data:Dictionary)->String: pass static func get_character_star_num(character_data:Dictionary)->int: return int(character_data["character"]["star"]) + +#修饰默认的角色数据,例如选择的皮肤,装备的卡片,选择的开局等 +#(修饰数据存储在玩家数据里,用户通过Global获取的角色数据应是修饰后的数据,更改角色时通过Global添加修饰器) +#"skin":int 改变使用的皮肤 +# + +static func character_embellish(character_data:Dictionary,embellish_data:Dictionary)->Dictionary: + var res_data=character_data.duplicate(true) + if embellish_data.has("skin"): + character_data["character"]["skin_now_use"]=int(embellish_data["skin"]) + - pass + + + return res_data static func get_initiative_value(character_data:Dictionary)->int: var AGI=get_character_attribute(character_data,"AGI") return AGI/2+randi_range(-10,10) +static func get_character_type(character_data:Dictionary)->int: + return int(character_data["basic_mes"]["type"]) +static var attribute_key_to_name_dic:Dictionary={ + "CON":"体质", + "AGI":"敏捷", + "INT":"智力", + "WIS":"感知", + "STR":"力量", + "MND":"意志", + "LUC":"幸运", + "AM":"魅力", + "HP":"生命", + "SP":"精神", + "VIT":"体力" +} +##通过属性的键名获取显示名字 +static func get_name_by_attribute_key(key:String)->String: + if attribute_key_to_name_dic.has(key): + return attribute_key_to_name_dic[key] + else: + return key + diff --git a/json/card.json b/json/card.json index 20da438..dd0917a 100644 --- a/json/card.json +++ b/json/card.json @@ -4,20 +4,20 @@ "icon":"?", "target_queue":0, "cost":0, - "triger":{ - - } + "triger":[{"func":"recover","value":["target",20]}] }, "card_02":{ "name":"测试卡02(不需要目标,所有人掉20)", "icon":"?", - "cost":1 + "cost":1, + "triger":[{"func":"hit_all","value":[20]}] }, "card_03":{ - "name":"测试卡03(敌方目标)", + "name":"测试卡03(敌方目标掉10)", "icon":"?", "target_queue":1, - "cost":2 + "cost":2, + "triger":[{"func":"hit","value":["target",10]}] }, } diff --git a/json/character.json b/json/character.json index 05ba59d..5dc49e7 100644 --- a/json/character.json +++ b/json/character.json @@ -7,6 +7,7 @@ "skin":[ { "name":"皮肤1", + "skin_card_face":"test_character_tsubaki_head", "card_face":"test_character_tsubaki", "character":"test_character_tsubaki" } @@ -79,7 +80,7 @@ "skin_now_use":0 }, "basic_mes":{ - "script_category":"剧本类别", + "type":1, "place":"地点", "sex":0, "race":"种族", @@ -146,7 +147,7 @@ "skin_now_use":0 }, "basic_mes":{ - "script_category":"剧本类别", + "type":2, "place":"地点", "sex":0, "race":"种族", diff --git a/res/shader/stroke.gdshader b/res/shader/stroke.gdshader index 46f6c1c..681e05e 100644 --- a/res/shader/stroke.gdshader +++ b/res/shader/stroke.gdshader @@ -66,7 +66,7 @@ void fragment() { } } else{ - + COLOR.rgb=flashing_color.rgb; } } diff --git a/res/ui/ui_004_character_bag/character_bag_selected.tres b/res/ui/ui_004_character_bag/character_bag_selected.tres new file mode 100644 index 0000000..e2d4b78 --- /dev/null +++ b/res/ui/ui_004_character_bag/character_bag_selected.tres @@ -0,0 +1,10 @@ +[gd_resource type="StyleBoxTexture" load_steps=3 format=3 uid="uid://bwf0mbjhm621"] + +[sub_resource type="Gradient" id="Gradient_ht7bm"] +colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_xx4c2"] +gradient = SubResource("Gradient_ht7bm") + +[resource] +texture = SubResource("GradientTexture1D_xx4c2") diff --git a/res/ui/ui_004_character_bag/tuceng66mask.png b/res/ui/ui_004_character_bag/tuceng66mask.png new file mode 100644 index 0000000..bb36328 Binary files /dev/null and b/res/ui/ui_004_character_bag/tuceng66mask.png differ diff --git a/res/ui/ui_004_character_bag/tuceng66mask.png.import b/res/ui/ui_004_character_bag/tuceng66mask.png.import new file mode 100644 index 0000000..061f492 --- /dev/null +++ b/res/ui/ui_004_character_bag/tuceng66mask.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bupgbmnm0chtk" +path="res://.godot/imported/tuceng66mask.png-6f00536a0964555215b838ab14cf3608.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_004_character_bag/tuceng66mask.png" +dest_files=["res://.godot/imported/tuceng66mask.png-6f00536a0964555215b838ab14cf3608.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/res/ui/ui_005_basic_message/图层100.png b/res/ui/ui_005_basic_message/图层100.png new file mode 100644 index 0000000..ad381e7 Binary files /dev/null and b/res/ui/ui_005_basic_message/图层100.png differ diff --git a/res/ui/ui_005_basic_message/图层100.png.import b/res/ui/ui_005_basic_message/图层100.png.import new file mode 100644 index 0000000..75dfd16 --- /dev/null +++ b/res/ui/ui_005_basic_message/图层100.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cmghc5oc3sqta" +path="res://.godot/imported/图层100.png-af14a0ae7f36fe7562eb20e6a917ea86.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_005_basic_message/图层100.png" +dest_files=["res://.godot/imported/图层100.png-af14a0ae7f36fe7562eb20e6a917ea86.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/res/ui/ui_005_basic_message/图层103.png b/res/ui/ui_005_basic_message/图层103.png new file mode 100644 index 0000000..6441190 Binary files /dev/null and b/res/ui/ui_005_basic_message/图层103.png differ diff --git a/res/ui/ui_005_basic_message/图层103.png.import b/res/ui/ui_005_basic_message/图层103.png.import new file mode 100644 index 0000000..ef6e0b3 --- /dev/null +++ b/res/ui/ui_005_basic_message/图层103.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dxdgwycpw4bta" +path="res://.godot/imported/图层103.png-a51c042a09711cc5cd305db7ebe73d5b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/ui_005_basic_message/图层103.png" +dest_files=["res://.godot/imported/图层103.png-a51c042a09711cc5cd305db7ebe73d5b.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/scene/basic_mes_skin_card.tscn b/scene/basic_mes_skin_card.tscn new file mode 100644 index 0000000..0d32783 --- /dev/null +++ b/scene/basic_mes_skin_card.tscn @@ -0,0 +1,59 @@ +[gd_scene load_steps=6 format=3 uid="uid://c20vbhv7jcv8n"] + +[ext_resource type="Texture2D" uid="uid://b0souut27w2rq" path="res://res/ui/ui_005_basic_message/tuceng100.png" id="1_ilmd5"] +[ext_resource type="Texture2D" uid="uid://bd8ihwl2g1igc" path="res://res/ui/ui_005_basic_message/tuceng101.png" id="2_iqkdj"] +[ext_resource type="Texture2D" uid="uid://da4mwbefqkahf" path="res://test/texture/tsubaki_1.png" id="3_c88qw"] +[ext_resource type="Texture2D" uid="uid://baou8kmprfpwt" path="res://res/ui/ui_005_basic_message/tuceng103.png" id="4_yka8x"] +[ext_resource type="Texture2D" uid="uid://jp6na74ed4yn" path="res://res/ui/ui_005_basic_message/tuceng102.png" id="5_p12ec"] + +[node name="basic_mes_skin_card" type="TextureRect"] +offset_right = 40.0 +offset_bottom = 40.0 +texture = ExtResource("1_ilmd5") + +[node name="back" type="TextureRect" parent="."] +show_behind_parent = true +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_iqkdj") + +[node name="mask2" type="TextureRect" parent="."] +show_behind_parent = true +clip_children = 1 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_iqkdj") + +[node name="skin_head" type="TextureRect" parent="mask2"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_c88qw") +expand_mode = 5 + +[node name="mask" type="TextureRect" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +texture = ExtResource("4_yka8x") + +[node name="lock" 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("5_p12ec") +stretch_mode = 3 diff --git a/scene/basic_message.gd b/scene/basic_message.gd index 31b33da..8f5970b 100644 --- a/scene/basic_message.gd +++ b/scene/basic_message.gd @@ -2,89 +2,8 @@ extends Control const ABILITY_BUTTON = preload("res://scene/ability_button.tscn") const ATTRIBUTE = preload("res://scene/attribute.tscn") const SELECTED = preload("res://res/ui/ui_005_basic_message/selected.tres") -var data={ - "character":{ - "name":"角色名字", - "star":5, - "skin":[ - { - "name":"皮肤1", - "card_face":"卡面图片路径", - "character":"角色图片路径" - } - ], - "skin_now_use":0 - }, - "basic_mes":{ - "script_category":"剧本类别", - "place":"地点", - "sex":0, #0为男,1为女 - "race":"种族", - "birthday":"xxxx-xx-xx", - - "introduction":"这是一个介绍", - "basic_attribute":[ - { - "name":"体质", - "value":100, - }, - { - "name":"敏捷", - "value":100, - }, - { - "name":"智力", - "value":100, - }, - { - "name":"感知", - "value":100, - }, - ], - "fight_attribute":[ - { - "name":"生命", - "value":100, - }, - { - "name":"精神", - "value":100, - }, - { - "name":"物理攻击", - "value":100, - }, - { - "name":"法术强度", - "value":100, - }, - ] - }, - "special":[ - { - "name":"倾国倾城", - "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" - } - ], - "ability":[ - { - "name":"武学 LV3", - "introduction":"鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果鼠标点击显示具体效果" - } - ], - - "favor":[{ - "name":"姐姐", - "value":100 - } - ], - "reputation":[ - { - "name":"某地区", - "value":100 - } - ] -} +const BASIC_MES_SKIN_CARD = preload("res://scene/basic_mes_skin_card.tscn") +var data:Dictionary @onready var button_group:Array[Button]=[$VBoxContainer/TextureRect/HBoxContainer/Button, $VBoxContainer/TextureRect/HBoxContainer/Button2, $VBoxContainer/TextureRect/HBoxContainer/Button3, $VBoxContainer/TextureRect/HBoxContainer/Button4, $VBoxContainer/TextureRect/HBoxContainer/Button5, $VBoxContainer/TextureRect/HBoxContainer/Button6] @onready var now_selected_button:Button=$VBoxContainer/TextureRect/HBoxContainer/Button @@ -93,28 +12,45 @@ func init_from_data(): i.queue_free() for i in %ability_container.get_children(): i.queue_free() - if data.has("basic_mes"): - var basic_data=data["basic_mes"] - %category.text=basic_data["script_category"] - %place.text=basic_data["place"] - #缺少性别 - %race.text=basic_data["race"] - %birthday.text=basic_data["birthday"] - %introduction.text=basic_data["introduction"] - var basic_attribute=basic_data["basic_attribute"] - var fight_attribute=basic_data["fight_attribute"] - for i in %basic_attribute.get_children(): - i.queue_free() - for i in %fight_attribute.get_children(): - i.queue_free() - for i in basic_attribute: - var new_attribute=ATTRIBUTE.instantiate() - new_attribute.data=i - %basic_attribute.add_child(new_attribute) - for i in fight_attribute: - var new_attribute=ATTRIBUTE.instantiate() - new_attribute.data=i - %fight_attribute.add_child(new_attribute) + %character.texture=Global.get_texture(CharacterTool.get_skin_now_use_data(data)["character"]) + var basic_data=data["basic_mes"] + match int(basic_data["type"]): + 0: + %category.text="历史" + 1: + %category.text="奇幻" + 2: + %category.text="现实" + 3: + %category.text="末世" + %place.text=basic_data["place"] + #缺少性别 + %race.text=basic_data["race"] + %birthday.text=basic_data["birthday"] + %introduction.text=basic_data["introduction"] + + var basic_attribute:Dictionary=data["basic_attribute"] + var fight_attribute:Dictionary={} + if data.has("fight_attribute"): + fight_attribute=data["fight_attribute"] + for i in %basic_attribute.get_children(): + i.queue_free() + for i in %fight_attribute.get_children(): + i.queue_free() + for i in basic_attribute.keys(): + var new_attribute=ATTRIBUTE.instantiate() + new_attribute.data={ + "name":CharacterTool.get_name_by_attribute_key(i), + "value":basic_attribute[i] + } + %basic_attribute.add_child(new_attribute) + for i in fight_attribute.keys(): + var new_attribute=ATTRIBUTE.instantiate() + new_attribute.data={ + "name":CharacterTool.get_name_by_attribute_key(i), + "value":basic_attribute[i] + } + %fight_attribute.add_child(new_attribute) pass if data.has("special"): var special_data=data["special"] @@ -156,13 +92,17 @@ func init_from_data(): new_label.text=i["name"]+":"+str(i["value"]) %reputation.add_child(new_label) new_label.add_theme_font_size_override("font_size",26) - - pass func connect_button(): for i in button_group.size(): button_group[i].pressed.connect(selected.bind(i)) - - pass + +#当第几个皮肤卡片被点击时 +func skin_card_click(skin_index:int): + + + + pass + func selected(ind:int): if now_selected_button!=null: var new_st=StyleBoxEmpty.new() @@ -179,5 +119,11 @@ func selected(ind:int): pass func _ready() -> void: + data=Global.get_character_data("test_character_01") init_from_data() connect_button() + + +func _on_back_button_pressed() -> void: + self.hide() + pass # Replace with function body. diff --git a/scene/basic_message.tscn b/scene/basic_message.tscn index 9a9d73d..ffece8b 100644 --- a/scene/basic_message.tscn +++ b/scene/basic_message.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=59 format=3 uid="uid://chh7gr3qbkr8u"] +[gd_scene load_steps=60 format=3 uid="uid://chh7gr3qbkr8u"] [ext_resource type="Script" path="res://scene/basic_message.gd" id="1_0470d"] [ext_resource type="Texture2D" uid="uid://dygka5vk5qdhs" path="res://res/ui/ui_005_basic_message/tuceng2.png" id="1_vhe21"] [ext_resource type="Texture2D" uid="uid://vbtkrk0b8c3u" path="res://res/ui/ui_005_basic_message/tuceng97.png" id="2_u0tfq"] [ext_resource type="Texture2D" uid="uid://drgfs6epv0jqd" path="res://res/ui/ui_005_basic_message/tuceng92.png" id="3_5dvp4"] [ext_resource type="Texture2D" uid="uid://d3meg8ge874u8" path="res://res/ui/ui_004_character_bag/tuceng67.png" id="4_el6g3"] +[ext_resource type="PackedScene" uid="uid://c20vbhv7jcv8n" path="res://scene/basic_mes_skin_card.tscn" id="4_tg3wv"] [ext_resource type="Texture2D" uid="uid://hpogdw4jv6rl" path="res://res/ui/ui_005_basic_message/tuceng177.png" id="5_5lslk"] [ext_resource type="Texture2D" uid="uid://c6ftnvo1gl1o7" path="res://res/ui/ui_005_basic_message/tuceng127.png" id="6_s8ry1"] [ext_resource type="Texture2D" uid="uid://djaebws5opaql" path="res://res/ui/ui_005_basic_message/tuceng95.png" id="7_a1x8x"] @@ -148,11 +149,29 @@ layout_mode = 2 horizontal_scroll_mode = 0 vertical_scroll_mode = 3 -[node name="VBoxContainer" type="VBoxContainer" parent="panel/MarginContainer/ScrollContainer"] +[node name="skin_card_add_pos" type="VBoxContainer" parent="panel/MarginContainer/ScrollContainer"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 +theme_override_constants/separation = 20 + +[node name="basic_mes_skin_card" parent="panel/MarginContainer/ScrollContainer/skin_card_add_pos" instance=ExtResource("4_tg3wv")] +layout_mode = 2 + +[node name="basic_mes_skin_card2" parent="panel/MarginContainer/ScrollContainer/skin_card_add_pos" instance=ExtResource("4_tg3wv")] +layout_mode = 2 + +[node name="basic_mes_skin_card3" parent="panel/MarginContainer/ScrollContainer/skin_card_add_pos" instance=ExtResource("4_tg3wv")] +layout_mode = 2 + +[node name="basic_mes_skin_card4" parent="panel/MarginContainer/ScrollContainer/skin_card_add_pos" instance=ExtResource("4_tg3wv")] +layout_mode = 2 + +[node name="basic_mes_skin_card5" parent="panel/MarginContainer/ScrollContainer/skin_card_add_pos" instance=ExtResource("4_tg3wv")] +layout_mode = 2 [node name="character" type="TextureRect" parent="."] +unique_name_in_owner = true layout_mode = 1 anchors_preset = -1 anchor_left = 0.290417 @@ -336,12 +355,11 @@ layout_mode = 2 size_flags_vertical = 3 size_flags_stretch_ratio = 939.0 theme_override_styles/panel = SubResource("StyleBoxEmpty_81i7t") -current_tab = 4 +current_tab = 0 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 @@ -1622,6 +1640,7 @@ text = "9999" vertical_alignment = 1 [node name="skill_config" type="MarginContainer" parent="VBoxContainer/TabContainer"] +visible = false layout_mode = 2 theme_override_constants/margin_left = 54 theme_override_constants/margin_top = 8 @@ -2110,8 +2129,8 @@ unique_name_in_owner = true layout_mode = 1 anchors_preset = -1 anchor_left = 0.0392927 -anchor_right = 1.0 -anchor_bottom = 1.0 +anchor_right = 1.28684 +anchor_bottom = 0.999999 grow_horizontal = 2 grow_vertical = 2 theme_override_colors/font_color = Color(1, 1, 1, 1) @@ -2132,3 +2151,5 @@ focus_mode = 0 icon = ExtResource("21_boe0q") flat = true metadata/_edit_use_anchors_ = true + +[connection signal="pressed" from="back_button" to="." method="_on_back_button_pressed"] diff --git a/scene/card.gd b/scene/card.gd index a296569..314fdbe 100644 --- a/scene/card.gd +++ b/scene/card.gd @@ -102,7 +102,7 @@ func exe(): await move_finished_sig show_big() await get_tree().create_timer(0.2).timeout - Global.use_card(data,target) + Global.use_card(data,Global.now_fight_scene.user,target) await get_tree().create_timer(0.2).timeout down() print("执行完毕") diff --git a/scene/character_bag.gd b/scene/character_bag.gd index 2020b7b..5d0717e 100644 --- a/scene/character_bag.gd +++ b/scene/character_bag.gd @@ -1,16 +1,64 @@ extends Control const CHARACTER_BAG_CARD = preload("res://scene/character_bag_card.tscn") - +const CHARACTER_BAG_SELECTED:StyleBoxTexture = preload("res://res/ui/ui_004_character_bag/character_bag_selected.tres") +@onready var btn_panel_group:Array[PanelContainer]=[$NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer2, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer3, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer4, $NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer5] +var data:Dictionary +var now_select_index:int=-1: + set(val): + if now_select_index!=val: + select(now_select_index,val) + now_select_index=val func _ready() -> void: - + refresh() + select(-1,-1) pass +func select(before:int,ind:int): + btn_panel_group[before+1].add_theme_stylebox_override("panel",StyleBoxEmpty.new()) + btn_panel_group[ind+1].add_theme_stylebox_override("panel",CHARACTER_BAG_SELECTED) + for i in %card_add_pos.get_children(): + i.queue_free() + for i in data.values(): + if CharacterTool.get_character_type(i)==ind ||ind==-1: + var new_card=CHARACTER_BAG_CARD.instantiate() + new_card.data=i + %card_add_pos.add_child(new_card) + + pass + + + pass func _on_back_btn_pressed() -> void: get_parent().change_open(false) pass # Replace with function body. func refresh(): - + data=Global.get_all_character() pass + + +func _on_all_pressed() -> void: + now_select_index=-1 + pass # Replace with function body. + + +func _on_history_pressed() -> void: + now_select_index=0 + pass # Replace with function body. + + +func _on_fantasy_pressed() -> void: + now_select_index=1 + pass # Replace with function body. + + +func _on_reality_pressed() -> void: + now_select_index=2 + pass # Replace with function body. + + +func _on_eschatological_pressed() -> void: + now_select_index=3 + pass # Replace with function body. diff --git a/scene/character_bag.tscn b/scene/character_bag.tscn index 39438f8..5bef817 100644 --- a/scene/character_bag.tscn +++ b/scene/character_bag.tscn @@ -1,33 +1,24 @@ -[gd_scene load_steps=21 format=3 uid="uid://cgl1vcdusqroq"] +[gd_scene load_steps=18 format=3 uid="uid://cgl1vcdusqroq"] [ext_resource type="Texture2D" uid="uid://bxbwbvgbfntiv" path="res://res/ui/ui_004_character_bag/tuceng1.png" id="1_688g7"] [ext_resource type="Script" path="res://scene/character_bag.gd" id="1_e5f2o"] [ext_resource type="Texture2D" uid="uid://bt5qrcsynsp6j" path="res://res/ui/ui_004_character_bag/tuceng231.png" id="2_bq8dd"] [ext_resource type="Texture2D" uid="uid://bi4qd4hkdm4wb" path="res://res/ui/ui_004_character_bag/tuceng35.png" id="3_m44x5"] -[ext_resource type="PackedScene" uid="uid://dacsn16xvd4dj" path="res://scene/character_bag_card.tscn" id="4_i7p8r"] [ext_resource type="Texture2D" uid="uid://blv4q1cix0hu0" path="res://res/ui/ui_004_character_bag/tuceng42.png" id="4_us8ay"] [ext_resource type="Texture2D" uid="uid://cxo6pmp6bo4nf" path="res://res/ui/ui_004_character_bag/tuceng43.png" id="6_gxmw5"] [ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="7_6v0oc"] [ext_resource type="Texture2D" uid="uid://13ed8w6scsgo" path="res://res/ui/ui_004_character_bag/tuceng38.png" id="7_piio5"] [ext_resource type="Texture2D" uid="uid://ddwgjg72ivkwn" path="res://res/ui/ui_004_character_bag/tuceng39.png" id="8_pn6mv"] [ext_resource type="Texture2D" uid="uid://p68ycyicgxxe" path="res://res/ui/ui_004_character_bag/tuceng40.png" id="9_tg2kw"] +[ext_resource type="StyleBox" uid="uid://bwf0mbjhm621" path="res://res/ui/ui_004_character_bag/character_bag_selected.tres" id="10_642jd"] [ext_resource type="Texture2D" uid="uid://bq23yis2bwf3d" path="res://res/ui/ui_004_character_bag/tuceng41.png" id="10_ijoj6"] [ext_resource type="PackedScene" uid="uid://chh7gr3qbkr8u" path="res://scene/basic_message.tscn" id="13_lbwxs"] -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_3l4tb"] - [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7x5v6"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_yu86v"] -[sub_resource type="Gradient" id="Gradient_ht7bm"] -colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1) - -[sub_resource type="GradientTexture1D" id="GradientTexture1D_xx4c2"] -gradient = SubResource("Gradient_ht7bm") - -[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_26agh"] -texture = SubResource("GradientTexture1D_xx4c2") +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_n7qmw"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_xo627"] @@ -99,39 +90,6 @@ layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 0 -[node name="TextureRect" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect2" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect3" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect4" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect5" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect6" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect7" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect8" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect9" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect10" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - -[node name="TextureRect11" parent="NinePatchRect/MarginContainer/ScrollContainer/card_add_pos" instance=ExtResource("4_i7p8r")] -layout_mode = 2 - [node name="NinePatchRect2" type="NinePatchRect" parent="."] layout_mode = 0 anchor_left = 0.839063 @@ -158,7 +116,7 @@ layout_mode = 2 custom_minimum_size = Vector2(0, 100) layout_mode = 2 size_flags_vertical = 0 -theme_override_styles/panel = SubResource("StyleBoxEmpty_3l4tb") +theme_override_styles/panel = ExtResource("10_642jd") [node name="HBoxContainer" type="HBoxContainer" parent="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer"] layout_mode = 2 @@ -237,7 +195,7 @@ layout_mode = 2 [node name="PanelContainer4" type="PanelContainer" parent="NinePatchRect2/MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(0, 100) layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxTexture_26agh") +theme_override_styles/panel = SubResource("StyleBoxEmpty_n7qmw") [node name="HBoxContainer4" type="HBoxContainer" parent="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer4"] layout_mode = 2 @@ -283,7 +241,7 @@ size_flags_stretch_ratio = 3.0 theme_override_font_sizes/font_size = 34 text = "末世" -[node name="ToolButton" parent="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer5" instance=ExtResource("7_6v0oc")] +[node name="eschatological" parent="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer5" instance=ExtResource("7_6v0oc")] layout_mode = 2 [node name="basic_mes" parent="." instance=ExtResource("13_lbwxs")] @@ -292,3 +250,8 @@ visible = false layout_mode = 1 [connection signal="pressed" from="back_texture/back_btn" to="." method="_on_back_btn_pressed"] +[connection signal="pressed" from="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer/all" to="." method="_on_all_pressed"] +[connection signal="pressed" from="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer2/history" to="." method="_on_history_pressed"] +[connection signal="pressed" from="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer3/fantasy" to="." method="_on_fantasy_pressed"] +[connection signal="pressed" from="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer4/reality" to="." method="_on_reality_pressed"] +[connection signal="pressed" from="NinePatchRect2/MarginContainer/VBoxContainer/PanelContainer5/eschatological" to="." method="_on_eschatological_pressed"] diff --git a/scene/character_bag_card.gd b/scene/character_bag_card.gd index eb0c72c..0d9bf25 100644 --- a/scene/character_bag_card.gd +++ b/scene/character_bag_card.gd @@ -14,17 +14,16 @@ func set_star_num(num:int): star_group[i].hide() pass #设置卡面 -func set_face(path:String): - var new_face=load(path) - if new_face!=null and new_face is Texture2D: - %texture_face.texture=new_face +func set_face(icon): + %texture_face.texture=icon #设置名字 func set_character_name(n:String): %n.text=n pass func _ready() -> void: + data=Global.get_character_data("test_character_01") set_star_num(CharacterTool.get_character_star_num(data)) - set_face(CharacterTool.get_skin_now_use_data(data)["card_face"]) + set_face(Global.get_texture(CharacterTool.get_skin_now_use_data(data)["card_face"])) set_character_name(CharacterTool.get_character_name(data)) diff --git a/scene/character_bag_card.tscn b/scene/character_bag_card.tscn index 970f5e3..a61f455 100644 --- a/scene/character_bag_card.tscn +++ b/scene/character_bag_card.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://dacsn16xvd4dj"] +[gd_scene load_steps=9 format=3 uid="uid://dacsn16xvd4dj"] [ext_resource type="Texture2D" uid="uid://5tl46hgyvw0n" path="res://res/ui/ui_004_character_bag/tuceng71.png" id="1_k4ylg"] [ext_resource type="Script" path="res://scene/character_bag_card.gd" id="2_47isi"] @@ -6,6 +6,7 @@ [ext_resource type="Texture2D" uid="uid://ckbu37n5w8de8" path="res://res/ui/ui_004_character_bag/tuceng3.png" id="3_b4wi7"] [ext_resource type="Texture2D" uid="uid://b2wy134i3get4" path="res://res/ui/ui_004_character_bag/tuceng66.png" id="4_5677t"] [ext_resource type="Texture2D" uid="uid://d3meg8ge874u8" path="res://res/ui/ui_004_character_bag/tuceng67.png" id="5_ahpsw"] +[ext_resource type="Texture2D" uid="uid://bupgbmnm0chtk" path="res://res/ui/ui_004_character_bag/tuceng66mask.png" id="5_vli6j"] [ext_resource type="PackedScene" uid="uid://bdlo2wn4qnygv" path="res://scene/tool/tool_button.tscn" id="7_emrhq"] [node name="TextureRect" type="TextureRect"] @@ -18,29 +19,18 @@ script = ExtResource("2_47isi") metadata/_edit_use_anchors_ = true [node name="mask" type="TextureRect" parent="."] -clip_contents = true layout_mode = 1 anchors_preset = -1 anchor_left = 0.116364 anchor_top = 0.0741525 -anchor_right = 0.865455 -anchor_bottom = 0.891949 -texture = ExtResource("4_5677t") -stretch_mode = 5 -metadata/_edit_use_anchors_ = true - -[node name="texture_face" type="TextureRect" parent="mask"] -unique_name_in_owner = true -show_behind_parent = true -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 +anchor_right = 0.865 +anchor_bottom = 0.908 +offset_right = 0.125107 +offset_bottom = -7.57608 grow_horizontal = 2 grow_vertical = 2 -texture = ExtResource("2_jooco") -expand_mode = 1 -stretch_mode = 6 +texture = ExtResource("4_5677t") +stretch_mode = 5 [node name="TextureRect" type="TextureRect" parent="mask"] show_behind_parent = true @@ -54,6 +44,31 @@ grow_vertical = 2 texture = ExtResource("3_b4wi7") metadata/_edit_use_anchors_ = true +[node name="mask" type="TextureRect" parent="mask"] +show_behind_parent = true +clip_children = 1 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("5_vli6j") +expand_mode = 1 + +[node name="texture_face" type="TextureRect" parent="mask/mask"] +unique_name_in_owner = true +show_behind_parent = true +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_jooco") +expand_mode = 1 +stretch_mode = 6 + [node name="HBoxContainer" type="HBoxContainer" parent="mask"] layout_mode = 1 anchors_preset = -1 @@ -97,10 +112,11 @@ layout_mode = 1 [node name="n" type="Label" parent="."] unique_name_in_owner = true -layout_mode = 0 -anchor_left = 0.327273 +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.116364 anchor_top = 0.894068 -anchor_right = 0.665455 +anchor_right = 0.865455 anchor_bottom = 0.942797 text = "角色名字" horizontal_alignment = 1