diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index 1338c07..5476158 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -272,7 +272,7 @@ func get_texture(id:String): func get_script_data(id:String): if script_data.has(id): var dictionary:Dictionary=script_data[id] - return dictionary.duplicate() + return dictionary.duplicate(true) else: return null func get_all_script_data(): @@ -280,38 +280,38 @@ func get_all_script_data(): func get_event_data(id:String): if event_data.has(id): var dictionary:Dictionary=event_data[id] - return dictionary.duplicate() + return dictionary.duplicate(true) else: return null func get_scene_data(id:String): if scene_data.has(id): var dictionary:Dictionary=scene_data[id] - return dictionary.duplicate() + return dictionary.duplicate(true) else: return null func get_character_data(id:String): if character_data.has(id): var dictionary:Dictionary=character_data[id] - return dictionary.duplicate() + return dictionary.duplicate(true) else: return null func get_map_data(id:String): if map_data.has(id): var dictionary:Dictionary=map_data[id] - return dictionary.duplicate() + return dictionary.duplicate(true) else: return null pass func get_npc_data(id:String): if npc_data.has(id): var dictionary:Dictionary=npc_data[id] - return dictionary.duplicate() + return dictionary.duplicate(true) else: return null pass func get_card_data(id:String): if card_data.has(id): var dictionary:Dictionary=card_data[id] - return dictionary.duplicate() + return dictionary.duplicate(true) else: return null diff --git a/class/character_tool/character_tool.gd b/class/character_tool/character_tool.gd new file mode 100644 index 0000000..fc6c69e --- /dev/null +++ b/class/character_tool/character_tool.gd @@ -0,0 +1,64 @@ +class_name CharacterTool +static func get_character_attribute(character_data:Dictionary,attribute_name:String): + + var arr=has_attribute(character_data) + if arr[0]: + var attribute_data=arr[1] + if attribute_data.has(attribute_name): + return attribute_data[attribute_name] + else: + return null + else: + return null + + + pass +static func has_attribute(character_data:Dictionary): + if character_data.has("basic_attribute"): + return [true,character_data["basic_attribute"]] + else: + return [false,null] + +func get_head(character_data:Dictionary): + + + pass +static func cacul_fight_attribute(character_data:Dictionary)->Dictionary: + var res={} + var arr=has_attribute(character_data) + if arr[0]: + var attribute_data=arr[1] + #"CON":100,体质 + #"AGI":100,敏捷 + #"INT":100,智力 + #"WIS":100,感知 + #"STR":100,力量 + #"MND":100,意志 + #"LUC":100,幸运 + #"AM":100,魅力 + #体质 + var CON=attribute_data["CON"] + var AGI=attribute_data["AGI"] + var INT=attribute_data["INT"] + var WIS=attribute_data["WIS"] + var STR=attribute_data["STR"] + var MND=attribute_data["MND"] + var LUC=attribute_data["LUC"] + var AM=attribute_data["AM"] + res["HP"]=CON*5 + res["SP"]=INT+MND + res["VIT"]=120 + + pass + + return res + pass + +static func get_skin_now_use_data(character_data:Dictionary)->Dictionary: + return character_data["character"]["skin"][character_data["character"]["skin_now_use"]] +static func get_character_name(character_data:Dictionary)->String: + return character_data["character"]["name"] + pass +static func get_initiative_value(character_data:Dictionary)->int: + var AGI=get_character_attribute(character_data,"AGI") + return AGI/2+randi_range(-10,10) diff --git a/json/card.json b/json/card.json index 8cdb5fd..20da438 100644 --- a/json/card.json +++ b/json/card.json @@ -1,12 +1,15 @@ { "card_01":{ - "name":"测试卡01(友方目标)", + "name":"测试卡01(友方目标回血10)", "icon":"?", "target_queue":0, - "cost":0 + "cost":0, + "triger":{ + + } }, "card_02":{ - "name":"测试卡02(不需要目标)", + "name":"测试卡02(不需要目标,所有人掉20)", "icon":"?", "cost":1 diff --git a/json/character.json b/json/character.json index 1cf6b54..6b4eece 100644 --- a/json/character.json +++ b/json/character.json @@ -1,15 +1,14 @@ { "test_character_01":{ "character":{ - "name":"朱雀院椿(测试1)", + "name":"朱雀院椿(测试1,敏捷100)", "head":"test_character_tsubaki_head", "star":3, - "skin":[ { "name":"皮肤1", "card_face":"test_character_tsubaki", - "character":"角色图片路径" + "character":"test_character_tsubaki" } ], "skin_now_use":0 @@ -20,45 +19,19 @@ "sex":0, "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, - }, - ] }, + "basic_attribute":{ + "CON":100, + "AGI":100, + "INT":100, + "WIS":100, + "STR":100, + "MND":100, + "LUC":100, + "AM":100 + }, + "special":[ { "name":"倾国倾城", @@ -82,18 +55,25 @@ "name":"某地区", "value":100 } - ] + ], + + "card_as_NPC":[] }, + + + + + "test_character_02":{ "character":{ - "name":"朱雀院椿(测试2)", - "star":3, + "name":"朱雀院椿(测试2,敏捷50)", "head":"test_character_tsubaki_head", + "star":3, "skin":[ { "name":"皮肤1", "card_face":"test_character_tsubaki", - "character":"角色图片路径" + "character":"test_character_tsubaki" } ], "skin_now_use":0 @@ -104,45 +84,19 @@ "sex":0, "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, - }, - ] }, + "basic_attribute":{ + "CON":100, + "AGI":50, + "INT":100, + "WIS":100, + "STR":100, + "MND":100, + "LUC":100, + "AM":100 + }, + "special":[ { "name":"倾国倾城", @@ -166,7 +120,9 @@ "name":"某地区", "value":100 } - ] + ], + + "card_as_NPC":[] }, @@ -175,13 +131,11 @@ - - "test_character_03":{ "character":{ - "name":"朱雀院椿(NPC)", + "name":"朱雀院椿(测试3)", + "head":"test_character_tsubaki_head", "star":3, - "skin":[ { "name":"皮肤1", @@ -197,45 +151,18 @@ "sex":0, "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, - }, - ] }, + "basic_attribute":{ + "CON":100, + "AGI":100, + "INT":100, + "WIS":100, + "STR":100, + "MND":100, + "LUC":100, + }, + "special":[ { "name":"倾国倾城", @@ -261,87 +188,4 @@ } ] }, - "test_character_04":{ - "character":{ - "name":"朱雀院椿(测试)", - "star":3, - "skin":[ - { - "name":"皮肤1", - "card_face":"test_character_tsubaki", - "character":"角色图片路径" - } - ], - "skin_now_use":0 - }, - "basic_mes":{ - "script_category":"剧本类别", - "place":"地点", - "sex":0, - "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 - } - ] - } } diff --git a/json/npc.json b/json/npc.json index 7ae0445..3b676e7 100644 --- a/json/npc.json +++ b/json/npc.json @@ -1,5 +1,14 @@ { "测试npc_1":{ - + "basic_attribute":{ + "CON":100, + "AGI":100, + "INT":100, + "WIS":100, + + "STR":100, + "MND":100, + "LUC":100, + }, } } diff --git a/scene/card.gd b/scene/card.gd index 9409e42..a296569 100644 --- a/scene/card.gd +++ b/scene/card.gd @@ -51,16 +51,21 @@ func move_finished(): state_machine.send_message("move_finished") move_finished_sig.emit() pass -func up(): - z_index=1 - scale_to(scale_multiple) +func up(): + z_index=basic_index+10 + scale_to(scale_multiple) +var basic_index:int=0: + set(val): + basic_index=val + down() + pass func down(): - z_index=0 + z_index=basic_index scale_to(1) func show_big(): - z_index=1 + z_index=basic_index+10 scale_to(1.5) var last_scale_tween:Tween func scale_to(sc:float): diff --git a/scene/card.tscn b/scene/card.tscn index 62ff223..d678497 100644 --- a/scene/card.tscn +++ b/scene/card.tscn @@ -20,6 +20,9 @@ layout_mode = 3 anchors_preset = 0 script = ExtResource("1_wc0x3") +[node name="arrow" parent="." instance=ExtResource("11_gjfgy")] +texture_num = 20 + [node name="fight_card" parent="." instance=ExtResource("1_nmkht")] layout_direction = 1 layout_mode = 0 @@ -62,8 +65,5 @@ script = ExtResource("9_40m88") [node name="discard" type="Node" parent="state_machine"] script = ExtResource("12_sl7jh") -[node name="arrow" parent="." instance=ExtResource("11_gjfgy")] -texture_num = 20 - [connection signal="mouse_entered" from="fight_card" to="." method="_on_fight_card_mouse_entered"] [connection signal="mouse_exited" from="fight_card" to="." method="_on_fight_card_mouse_exited"] diff --git a/scene/card_state_machine/card_machine.gd b/scene/card_state_machine/card_machine.gd index 4e3f4cc..8ee46ee 100644 --- a/scene/card_state_machine/card_machine.gd +++ b/scene/card_state_machine/card_machine.gd @@ -3,6 +3,7 @@ class_name CardMachine const CARD = preload("res://scene/card.tscn") var rand_release:float=20 @export var release_card_pos:Control +@export var queue_card_distance:float=50 var distance:float=100 var card_arr:Array[Card]=[] var queue_card:Array[Card]=[] @@ -40,6 +41,7 @@ func get_card_index(card:Card): return 0 func card_queue(card:Card): queue_card.append(card) + card.basic_index=queue_card.size() pass #获取释放位置 func get_queue_pos()->Vector2: @@ -48,8 +50,8 @@ func get_queue_pos()->Vector2: pos=release_card_pos.global_position -self.global_position else: pos=Vector2.ZERO - var rand:Vector2=Vector2(randf_range(-rand_release,rand_release),randf_range(-rand_release,rand_release)) - return pos+rand + #var rand:Vector2=Vector2(randf_range(-rand_release,rand_release),randf_range(-rand_release,rand_release)) + return pos+Vector2(queue_card_distance*queue_card.size(),0) @export var exe_card_pos:Control func get_exe_position(): var pos:Vector2 diff --git a/scene/card_state_machine/queue.gd b/scene/card_state_machine/queue.gd index a681849..daa0cfb 100644 --- a/scene/card_state_machine/queue.gd +++ b/scene/card_state_machine/queue.gd @@ -16,3 +16,10 @@ func exit_state(): func time_out(): pass +func process_message(type:String,n): + match type: + "mouse_enter": + get_player().up() + "mouse_exit": + get_player().down() + pass diff --git a/scene/card_state_machine/select_target.gd b/scene/card_state_machine/select_target.gd index 00803c2..fd202c2 100644 --- a/scene/card_state_machine/select_target.gd +++ b/scene/card_state_machine/select_target.gd @@ -6,6 +6,7 @@ func enter_state(n): player.move_to(player.position,player.get_queue_position()) init_position=n get_player().open_arrow() + get_player().up() func update_state(delta): if Input.is_action_just_released("mouse_left"): var target=get_player().get_select_result() @@ -28,6 +29,7 @@ func update_state_phy(delta): pass func exit_state(): get_player().close_arrow() + get_player().down() pass func time_out(): diff --git a/scene/card_state_machine/selected.gd b/scene/card_state_machine/selected.gd index 3577740..379c975 100644 --- a/scene/card_state_machine/selected.gd +++ b/scene/card_state_machine/selected.gd @@ -30,7 +30,7 @@ func update_state(delta): func update_state_phy(delta): pass func exit_state(): - + get_player().down() pass func time_out(): diff --git a/scene/fight.gd b/scene/fight.gd index 6861e5b..7af86aa 100644 --- a/scene/fight.gd +++ b/scene/fight.gd @@ -1,18 +1,26 @@ extends Control class_name FightScene +var user:FightCharacterCard ##角色节点的引用队列 - var character_arr:Array[FightCharacterCard]=[] var enermy_arr:Array[FightEnermyCard]=[] var extract_card_arr:Array=[] var hand_card_arr:Array=[] var left_card_arr:Array=[] var extract_num:int=5 +const FIGHT_CHARACTER_CARD = preload("res://scene/fight_character_card.tscn") +const FIGHT_ENERMY_CARD = preload("res://scene/fight_enermy_card.tscn") # Called when the node enters the scene tree for the first time. func _ready() -> void: + Global.now_fight_scene=self extract_card_arr=Global.get_all_card() extract_card(extract_num) + add_user(Global.get_character_data("test_character_01")) + add_character(Global.get_character_data("test_character_01")) + add_enermy(Global.get_character_data("test_character_01")) + add_enermy(Global.get_character_data("test_character_02")) pass # Replace with function body. +##抽牌 func extract_card(num:int): if extract_card_arr.size() void: pass +##释放队列决定后开始回合 func start_turn(): left_card_arr.append_array(hand_card_arr.duplicate()) hand_card_arr.clear() - - await %card_machine.exe_queue() + var sort_unit=get_sort_all_unit() + for i in sort_unit: + if i[0]!=user: + await i[0].atk() + else: + await %card_machine.exe_queue() extract_card(extract_num) %end_select.show() pass +##添加友方角色(非玩家) +func add_character(character_data:Dictionary): + var new_character=FIGHT_CHARACTER_CARD.instantiate() + %character_card_add_pos.add_child(new_character) + new_character.set_data(character_data) + character_arr.append(new_character) + pass +##添加敌方角色 +func add_enermy(character_data:Dictionary): + var new_character=FIGHT_ENERMY_CARD.instantiate() + %enermy_card_add_pos.add_child(new_character) + new_character.set_data(character_data) + enermy_arr.append(new_character) + pass +##设置玩家 +func add_user(character_data:Dictionary): + if user!=null: + if is_instance_valid(user): + user.queue_free() + user=null + var new_character=FIGHT_CHARACTER_CARD.instantiate() + %character_card_add_pos.add_child(new_character) + new_character.set_data(character_data) + user=new_character func _on_tool_button_pressed() -> void: pass # Replace with function body. @@ -49,3 +87,32 @@ func _on_end_select_pressed() -> void: %end_select.hide() start_turn() pass # Replace with function body. + +func get_all_character(): + return character_arr.duplicate() +func get_all_enermy(): + return enermy_arr.duplicate() +func get_all_unit(): + var unit_arr:Array=[] + unit_arr.append_array(get_all_character()) + unit_arr.append_array(get_all_enermy()) + unit_arr.append(user) + return unit_arr +func sort(a,b)->bool: + if a[1] void: + set_data(Global.get_character_data("test_character_01")) +func set_data(_data:Dictionary): + data=_data + icon.texture=Global.get_texture(CharacterTool.get_skin_now_use_data(data)["card_face"]) + n.text=CharacterTool.get_character_name(data) + fight_data=CharacterTool.cacul_fight_attribute(data) + HP_max=fight_data["HP"] + HP=HP_max + SP_max=fight_data["SP"] + SP=SP_max + VIT_max=fight_data["VIT"] + VIT=VIT_max + pass func _on_area_2d_area_entered(area: Area2D) -> void: material.set_shader_parameter("width",10) @@ -12,3 +58,10 @@ func _on_area_2d_area_entered(area: Area2D) -> void: func _on_area_2d_area_exited(area: Area2D) -> void: material.set_shader_parameter("width",0) pass # Replace with function body. +func cacul_initiative_value()->int: + return CharacterTool.get_initiative_value(data) +func atk(): + %turn_flag.show() + await get_tree().create_timer(1).timeout + %turn_flag.hide() + diff --git a/scene/fight_character_card.tscn b/scene/fight_character_card.tscn index 246bb49..a16db1d 100644 --- a/scene/fight_character_card.tscn +++ b/scene/fight_character_card.tscn @@ -98,7 +98,8 @@ horizontal_alignment = 1 vertical_alignment = 1 justification_flags = 162 -[node name="TextureProgressBar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer"] +[node name="HP_bar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer"] +unique_name_in_owner = true custom_minimum_size = Vector2(176, 32) layout_mode = 2 size_flags_horizontal = 0 @@ -107,7 +108,8 @@ value = 100.0 nine_patch_stretch = true texture_progress = ExtResource("5_mey8u") -[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/TextureProgressBar"] +[node name="HP_label" type="Label" parent="VBoxContainer/HBoxContainer/HP_bar"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -118,6 +120,17 @@ text = "999/999" horizontal_alignment = 1 vertical_alignment = 1 +[node name="back" type="TextureRect" parent="VBoxContainer/HBoxContainer/HP_bar"] +modulate = Color(0, 0, 0, 1) +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("7_wx32q") + [node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 @@ -131,7 +144,8 @@ horizontal_alignment = 1 vertical_alignment = 1 justification_flags = 162 -[node name="TextureProgressBar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer2"] +[node name="SP_bar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer2"] +unique_name_in_owner = true custom_minimum_size = Vector2(176, 32) layout_mode = 2 size_flags_horizontal = 0 @@ -140,7 +154,19 @@ value = 100.0 nine_patch_stretch = true texture_progress = ExtResource("6_j0vci") -[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2/TextureProgressBar"] +[node name="back" type="TextureRect" parent="VBoxContainer/HBoxContainer2/SP_bar"] +modulate = Color(0, 0, 0, 1) +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("7_wx32q") + +[node name="SP_label" type="Label" parent="VBoxContainer/HBoxContainer2/SP_bar"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -164,7 +190,8 @@ horizontal_alignment = 1 vertical_alignment = 1 justification_flags = 162 -[node name="TextureProgressBar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer3"] +[node name="VIT_bar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer3"] +unique_name_in_owner = true custom_minimum_size = Vector2(176, 32) layout_mode = 2 size_flags_horizontal = 0 @@ -173,7 +200,19 @@ value = 100.0 nine_patch_stretch = true texture_progress = ExtResource("7_wx32q") -[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3/TextureProgressBar"] +[node name="back" type="TextureRect" parent="VBoxContainer/HBoxContainer3/VIT_bar"] +modulate = Color(0, 0, 0, 1) +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("7_wx32q") + +[node name="VIT_label" type="Label" parent="VBoxContainer/HBoxContainer3/VIT_bar"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -190,5 +229,20 @@ vertical_alignment = 1 position = Vector2(224.5, 124) shape = SubResource("RectangleShape2D_oitb8") +[node name="turn_flag" type="Label" parent="."] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 100 +text = "回合中" +horizontal_alignment = 1 +vertical_alignment = 1 + [connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] [connection signal="area_exited" from="Area2D" to="." method="_on_area_2d_area_exited"] diff --git a/scene/fight_enermy_card.gd b/scene/fight_enermy_card.gd index dd31d92..4233728 100644 --- a/scene/fight_enermy_card.gd +++ b/scene/fight_enermy_card.gd @@ -1,13 +1,54 @@ extends TextureRect class_name FightEnermyCard -# Called when the node enters the scene tree for the first time. +@onready var icon: TextureRect = $TextureRect/TextureRect2/icon +@onready var n: Label = $TextureRect/n +var data:Dictionary +var fight_data:Dictionary +var HP_max:int=100: + set(val): + HP_max=val + %HP_bar.max_value=val + %HP_label.text=str(HP)+"/"+str(val) +var HP:int=100: + set(val): + HP=val + %HP_bar.value=val + %HP_label.text=str(val)+"/"+str(HP_max) +var SP_max:int=100: + set(val): + SP_max=val + %SP_bar.max_value=val + %SP_label.text=str(SP)+"/"+str(val) +var SP:int=100: + set(val): + SP=val + %SP_bar.value=val + %SP_label.text=str(val)+"/"+str(SP_max) +var VIT_max:int=100: + set(val): + VIT_max=val + %VIT_bar.max_value=val + %VIT_label.text=str(VIT)+"/"+str(val) +var VIT:int=100: + set(val): + VIT=val + %VIT_bar.value=val + %VIT_label.text=str(val)+"/"+str(VIT_max) func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: + set_data(Global.get_character_data("test_character_01")) + +func set_data(_data:Dictionary): + data=_data + icon.texture=Global.get_texture(CharacterTool.get_skin_now_use_data(data)["card_face"]) + n.text=CharacterTool.get_character_name(data) + fight_data=CharacterTool.cacul_fight_attribute(data) + HP_max=fight_data["HP"] + HP=HP_max + SP_max=fight_data["SP"] + SP=SP_max + VIT_max=fight_data["VIT"] + VIT=VIT_max pass func _on_area_2d_area_entered(area: Area2D) -> void: @@ -18,3 +59,9 @@ func _on_area_2d_area_entered(area: Area2D) -> void: func _on_area_2d_area_exited(area: Area2D) -> void: material.set_shader_parameter("width",0) pass # Replace with function body. +func cacul_initiative_value()->int: + return CharacterTool.get_initiative_value(data) +func atk(): + %turn_flag.show() + await get_tree().create_timer(1).timeout + %turn_flag.hide() diff --git a/scene/fight_enermy_card.tscn b/scene/fight_enermy_card.tscn index 2f8e774..564a9ac 100644 --- a/scene/fight_enermy_card.tscn +++ b/scene/fight_enermy_card.tscn @@ -58,7 +58,7 @@ grow_vertical = 2 texture = ExtResource("3_s8rrj") flip_h = true -[node name="TextureRect" type="TextureRect" parent="TextureRect/TextureRect2"] +[node name="icon" type="TextureRect" parent="TextureRect/TextureRect2"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -69,7 +69,7 @@ texture = ExtResource("4_u7od8") expand_mode = 1 stretch_mode = 6 -[node name="Label" type="Label" parent="TextureRect"] +[node name="n" type="Label" parent="TextureRect"] layout_mode = 0 anchor_top = 0.884 anchor_right = 1.0 @@ -100,7 +100,8 @@ horizontal_alignment = 1 vertical_alignment = 1 justification_flags = 162 -[node name="TextureProgressBar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer"] +[node name="HP_bar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer"] +unique_name_in_owner = true custom_minimum_size = Vector2(176, 32) layout_mode = 2 size_flags_horizontal = 0 @@ -109,7 +110,8 @@ value = 100.0 nine_patch_stretch = true texture_progress = ExtResource("5_0j5x7") -[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/TextureProgressBar"] +[node name="HP_label" type="Label" parent="VBoxContainer/HBoxContainer/HP_bar"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -120,6 +122,17 @@ text = "999/999" horizontal_alignment = 1 vertical_alignment = 1 +[node name="back" type="TextureRect" parent="VBoxContainer/HBoxContainer/HP_bar"] +modulate = Color(0, 0, 0, 1) +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("7_4wsqq") + [node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 @@ -133,7 +146,8 @@ horizontal_alignment = 1 vertical_alignment = 1 justification_flags = 162 -[node name="TextureProgressBar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer2"] +[node name="SP_bar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer2"] +unique_name_in_owner = true custom_minimum_size = Vector2(176, 32) layout_mode = 2 size_flags_horizontal = 0 @@ -142,7 +156,8 @@ value = 100.0 nine_patch_stretch = true texture_progress = ExtResource("6_x31v6") -[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2/TextureProgressBar"] +[node name="SP_label" type="Label" parent="VBoxContainer/HBoxContainer2/SP_bar"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -153,6 +168,17 @@ text = "999/999" horizontal_alignment = 1 vertical_alignment = 1 +[node name="back" type="TextureRect" parent="VBoxContainer/HBoxContainer2/SP_bar"] +modulate = Color(0, 0, 0, 1) +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("7_4wsqq") + [node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 @@ -166,7 +192,8 @@ horizontal_alignment = 1 vertical_alignment = 1 justification_flags = 162 -[node name="TextureProgressBar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer3"] +[node name="VIT_bar" type="TextureProgressBar" parent="VBoxContainer/HBoxContainer3"] +unique_name_in_owner = true custom_minimum_size = Vector2(176, 32) layout_mode = 2 size_flags_horizontal = 0 @@ -175,7 +202,8 @@ value = 100.0 nine_patch_stretch = true texture_progress = ExtResource("7_4wsqq") -[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3/TextureProgressBar"] +[node name="VIT_label" type="Label" parent="VBoxContainer/HBoxContainer3/VIT_bar"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -186,6 +214,17 @@ text = "999/999" horizontal_alignment = 1 vertical_alignment = 1 +[node name="back" type="TextureRect" parent="VBoxContainer/HBoxContainer3/VIT_bar"] +modulate = Color(0, 0, 0, 1) +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("7_4wsqq") + [node name="Area2D" type="Area2D" parent="."] collision_layer = 2 collision_mask = 2 @@ -194,5 +233,20 @@ collision_mask = 2 position = Vector2(226.5, 125.5) shape = SubResource("RectangleShape2D_ut4q5") +[node name="turn_flag" type="Label" parent="."] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 100 +text = "回合中" +horizontal_alignment = 1 +vertical_alignment = 1 + [connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] [connection signal="area_exited" from="Area2D" to="." method="_on_area_2d_area_exited"]