From 319aad8b76b17a98b8b918e39282648f433d115e Mon Sep 17 00:00:00 2001 From: TsubakiLoL <2789646812@qq.com> Date: Thu, 12 Dec 2024 19:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2d_action_choice.gd | 1 + autoload/global/script/global.gd | 7 + .../BlockAction/block_action_attack_normal.gd | 55 ++++++++ class/2dFightBlock/base_block.gd | 7 + class/2dFightBlock/unit_block.gd | 2 + scene/_2d_fight/2d_action_choice.tscn | 15 +++ scene/_2d_fight/2d_fight.gd | 121 ++++++++++++++++- scene/_2d_fight/2d_fight.tscn | 97 ++++++++++++-- scene/_2d_fight/2d_fight_attribute_table.gd | 108 +++++++++++++++ scene/_2d_fight/2d_fight_attribute_table.tscn | 126 ++++++++++++++++++ scene/_2d_fight/block_scene/test_character.gd | 4 + .../_2d_fight/block_scene/test_character.tscn | 44 +++++- scene/_2d_fight/block_scene/wall.tscn | 4 + scene/_2d_fight/block_tag_label.gd | 8 ++ scene/_2d_fight/block_tag_label.tscn | 4 +- scene/gacha3d/node_3d.gd | 1 + scene/gacha3d/node_3d.tscn | 6 + scene/gacha3d/sprite_3d.tscn | 31 +++++ 18 files changed, 628 insertions(+), 13 deletions(-) create mode 100644 2d_action_choice.gd create mode 100644 scene/_2d_fight/2d_action_choice.tscn create mode 100644 scene/_2d_fight/2d_fight_attribute_table.gd create mode 100644 scene/_2d_fight/2d_fight_attribute_table.tscn create mode 100644 scene/_2d_fight/block_tag_label.gd create mode 100644 scene/gacha3d/node_3d.gd create mode 100644 scene/gacha3d/node_3d.tscn create mode 100644 scene/gacha3d/sprite_3d.tscn diff --git a/2d_action_choice.gd b/2d_action_choice.gd new file mode 100644 index 0000000..c75bcb5 --- /dev/null +++ b/2d_action_choice.gd @@ -0,0 +1 @@ +extends Button diff --git a/autoload/global/script/global.gd b/autoload/global/script/global.gd index eff8ef1..c1f1e82 100644 --- a/autoload/global/script/global.gd +++ b/autoload/global/script/global.gd @@ -1031,3 +1031,10 @@ func explore_finish(character_data:Dictionary,round_data:Dictionary): Toast.popup(Database.get_scene_name(now_scene)+"探索度增加"+str(round_data["right_total"])+"!") change_scene_explore(now_scene,round_data["right_total"]) pass + + + + + + +var now_2d_fight_scene:Fight2D diff --git a/class/2dFightBlock/BlockAction/block_action_attack_normal.gd b/class/2dFightBlock/BlockAction/block_action_attack_normal.gd index 2e82758..db3d878 100644 --- a/class/2dFightBlock/BlockAction/block_action_attack_normal.gd +++ b/class/2dFightBlock/BlockAction/block_action_attack_normal.gd @@ -37,5 +37,60 @@ func get_action_could_use_block(_self:UnitBlock,tile_map_area:Rect2i,global_bloc res[ind.x][ind.y]=true attack_cache=res + return res + + + + + + +#展示施法演示 +func draw_action_with_target(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary,target:Vector2i,block_add_pos:TileMapLayer): + var right_pos=tile_map_area.position+tile_map_area.size + if target.xright_pos.x or target.yright_pos.y: + Global.now_2d_fight_scene.close_right_character() + var crood=target-tile_map_area.position + var cache=attack_cache[crood.x][crood.y] + if cache: + Global.now_2d_fight_scene.show_right_character({}) + else: + Global.now_2d_fight_scene.close_right_character() + pass +#释放施法演示 +func del_action_with_target(): + + Global.now_2d_fight_scene.close_right_character() + + pass + + + + +#在_self上使用action动作,返回是否成功 +func block_use_action(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary,target=null)->bool: + if not target is Vector2i: + return false + var character_pos:Vector2i=_self.block_pos + var up:Vector2i=character_pos-Vector2i(0,1) + var down:Vector2i=character_pos+Vector2i(0,1) + var left:Vector2i=character_pos-Vector2i(1,0) + var right:Vector2i=character_pos+Vector2i(1,0) + var pos_arr=[up,down,left,right] + if not target in pos_arr: + return false + if not global_block_data.has(target): + return false + var could_attack=false + var block_arr=global_block_data[target] + for j in block_arr: + if j is BaseBlock: + could_attack =could_attack or j.could_be_used_for_target + if j.could_be_used_for_target: + j.attacked() + if could_attack: + return true + + return false +var draw_line diff --git a/class/2dFightBlock/base_block.gd b/class/2dFightBlock/base_block.gd index 9c65ccb..69d16f6 100644 --- a/class/2dFightBlock/base_block.gd +++ b/class/2dFightBlock/base_block.gd @@ -3,6 +3,13 @@ extends Node2D #基础地块 class_name BaseBlock +@export var block_name:String="default" + + +@export var block_attribute:Dictionary={ + +} + #当地块要求进行移动时发出 signal request_block_move(before_pos:Vector2i,request_pos:Vector2i) #当前地块是否可以行走 diff --git a/class/2dFightBlock/unit_block.gd b/class/2dFightBlock/unit_block.gd index 8f5bed2..dd1b5d9 100644 --- a/class/2dFightBlock/unit_block.gd +++ b/class/2dFightBlock/unit_block.gd @@ -3,6 +3,8 @@ extends BaseBlock class_name UnitBlock + + #单位的数据 var unit_data:Dictionary={} diff --git a/scene/_2d_fight/2d_action_choice.tscn b/scene/_2d_fight/2d_action_choice.tscn new file mode 100644 index 0000000..df5a673 --- /dev/null +++ b/scene/_2d_fight/2d_action_choice.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=2 format=3 uid="uid://b0ctm82e6x7yp"] + +[ext_resource type="Script" path="res://2d_action_choice.gd" id="1_yf2d6"] + +[node name="2d_action_choice" type="Button"] +size_flags_horizontal = 3 +theme_override_colors/font_hover_pressed_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_colors/font_hover_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_colors/font_pressed_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_colors/font_focus_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_font_sizes/font_size = 26 +text = "结束" +flat = true +script = ExtResource("1_yf2d6") +metadata/_edit_use_anchors_ = true diff --git a/scene/_2d_fight/2d_fight.gd b/scene/_2d_fight/2d_fight.gd index 6cdacb9..888ec5c 100644 --- a/scene/_2d_fight/2d_fight.gd +++ b/scene/_2d_fight/2d_fight.gd @@ -1,4 +1,10 @@ extends Node2D +class_name Fight2D +const BLOCK_TAG_LABEL = preload("res://scene/_2d_fight/block_tag_label.tscn") +const _2D_ACTION_CHOICE = preload("res://scene/_2d_fight/2d_action_choice.tscn") + + + #网格寻路系统 var astar:AStarGrid2D=AStarGrid2D.new() @@ -105,7 +111,10 @@ func turn(): j.turn() next() pass +var character_block_tween func next(): + if %left_character_drawer.is_open: + close_left_character() for i in %choice_add_pos.get_children(): i.queue_free() now_index+=1 @@ -115,12 +124,22 @@ func next(): return var now_block:UnitBlock=friendly_side[now_index] now_use_block=now_block + if character_block_tween!=null: + character_block_tween.kill() + character_block_tween=create_tween() + character_block_tween.tween_property(%main_camera,"global_position",now_block.position,0.2) + + show_left_character({}) var choice_arr=now_block.get_all_choice() for i in range(choice_arr.size()): - var new_btn=Button.new() + var new_btn=_2D_ACTION_CHOICE.instantiate() new_btn.pressed.connect(select_choice.bind(i)) new_btn.text=choice_arr[i] %choice_add_pos.add_child(new_btn) + %action.modulate.a=0 + %action.show() + var tween=create_tween() + tween.tween_property(%action,"modulate:a",1,0.2) pass func select_choice(index:int): print(index) @@ -129,6 +148,7 @@ func select_choice(index:int): func _ready() -> void: + Global.now_2d_fight_scene=self astar.default_compute_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN astar.default_estimate_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN astar.diagonal_mode=AStarGrid2D.DIAGONAL_MODE_NEVER @@ -187,10 +207,29 @@ func _process(delta: float) -> void: var res=now_action.block_use_action(now_use_block,Rect2i(tile_map_area_from,tile_map_area_to-tile_map_area_from),global_block_data,crood) if res: now_use_action=-1 + else: + var crood=%block_add_pos.local_to_map(get_global_mouse_position()) + if crood!=before_crood: + before_index=0 + if global_block_data.has(crood): + var arr=global_block_data[crood] + if arr.size()==0: + close_block_mes() + else: + var block:BaseBlock=arr[before_index] + pop_up_block_mes(block.block_name,block.block_attribute) + else: + close_block_mes() + + pass if Input.is_action_just_pressed("esc"): now_use_action=-1 - +#上一次展示的block信息 +var before_crood:Vector2i=Vector2i.ZERO +#上一次弹出地块信息的层级 +var before_index:int=0 + func _input(event: InputEvent) -> void: if event is InputEventMouseMotion: var mouse_pos=get_global_mouse_position() @@ -304,3 +343,81 @@ func _on_pop_4_pressed() -> void: func _on_alert_timer_timeout() -> void: %alert_drawer.change_open(false) pass # Replace with function body. + + + +#弹出地块信息,attribute字典应为String:bool +func pop_up_block_mes(_name:String,attribute:Dictionary): + %block_name.text=_name + for i in %block_label_add_pos.get_children(): + i.queue_free() + for i in attribute.keys(): + var new_tag=BLOCK_TAG_LABEL.instantiate() + %block_label_add_pos.add_child(new_tag) + new_tag.set_mes(i,attribute[i]) + + %block_drawer.change_open(true) + +#收起地块信息 +func close_block_mes(): + if %block_drawer.is_open: + %block_drawer.change_open(false) + pass + +func pop_up_choice(text:String,acc_callback:Callable,ref_callback:Callable): + %choice.modulate.a=0 + %choice_text.text=text + ac_cal=acc_callback + re_cal=ref_callback + %choice.show() + var tween=create_tween() + tween.tween_property(%choice,"modulate:a",1,0.2) + + + pass +var ac_cal +var re_cal + +func _on_action_close_pressed() -> void: + %action.hide() + pop_up_choice("是否结束本角色回合?",next,%action.show) + pass # Replace with function body. + + +func _on_choice_accept_pressed() -> void: + if ac_cal is Callable: + if ac_cal.is_valid(): + ac_cal.call() + %choice.hide() + pass # Replace with function body. + + +func _on_choice_refuse_pressed() -> void: + if re_cal is Callable: + if re_cal.is_valid(): + re_cal.call() + %choice.hide() + pass # Replace with function body. + + + + +#展示左边的角色信息 +func show_left_character(data:Dictionary): + %left_character_drawer.change_open(true) + pass +#展示右边的角色信息 +func show_right_character(data:Dictionary): + %right_character_drawer.change_open(true) + pass + +#关闭左边的角色信息 +func close_left_character(): + if %left_character_drawer.is_open: + %left_character_drawer.change_open(false) + pass +#关闭右边的角色信息 +func close_right_character(): + if %right_character_drawer.is_open: + %right_character_drawer.change_open(false) + pass diff --git a/scene/_2d_fight/2d_fight.tscn b/scene/_2d_fight/2d_fight.tscn index ee73ee3..790d2bb 100644 --- a/scene/_2d_fight/2d_fight.tscn +++ b/scene/_2d_fight/2d_fight.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=50 format=4 uid="uid://du6ct6v45ljtu"] +[gd_scene load_steps=51 format=4 uid="uid://du6ct6v45ljtu"] [ext_resource type="Script" path="res://scene/_2d_fight/2d_fight.gd" id="1_i1eox"] [ext_resource type="Texture2D" uid="uid://wld1fbwto47r" path="res://res/ui/ui_033_2d_fight/icon_color_64x64/black.png" id="2_rfpw5"] @@ -28,6 +28,7 @@ [ext_resource type="Texture2D" uid="uid://baqbhrxe7o1ay" path="res://res/ui/new_ui_005_2d_fight/move.png" id="26_2cd20"] [ext_resource type="Texture2D" uid="uid://dv62ydas2laek" path="res://res/ui/new_ui_005_2d_fight/矩形 100@1x.png" id="27_mopsr"] [ext_resource type="Texture2D" uid="uid://dcmnrhjs332n2" path="res://res/ui/new_ui_005_2d_fight/角色@1x-2.png" id="28_0p1qk"] +[ext_resource type="PackedScene" uid="uid://3r388ypcowro" path="res://scene/_2d_fight/2d_fight_attribute_table.tscn" id="28_57n5y"] [ext_resource type="Texture2D" uid="uid://q3hydkfgphua" path="res://res/ui/new_ui_005_2d_fight/矩形 133@1x.png" id="29_gfcum"] [sub_resource type="Gradient" id="Gradient_qwpaw"] @@ -355,6 +356,7 @@ tile_set = SubResource("TileSet_aef74") [node name="color_block" type="TileMapLayer" parent="tile_map"] unique_name_in_owner = true +visible = false tile_set = SubResource("TileSet_j5hfj") [node name="mouse_block" type="TileMapLayer" parent="tile_map"] @@ -401,7 +403,6 @@ theme_override_constants/margin_bottom = 10 layout_mode = 2 [node name="choice_add_pos" type="VBoxContainer" parent="CanvasLayer/panel_container/Panel/MarginContainer/VBoxContainer"] -unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 theme_override_constants/separation = 30 @@ -452,6 +453,8 @@ script = ExtResource("9_kd3fp") button_model = 3 disable_button = true animation_model = 4 +is_open = false +rag = 1.0 metadata/_edit_use_anchors_ = true [node name="TextureRect" type="TextureRect" parent="CanvasLayer/Control/block_drawer"] @@ -469,7 +472,8 @@ anchor_bottom = 0.291925 texture = ExtResource("10_mh3nh") metadata/_edit_use_anchors_ = true -[node name="Label" type="Label" parent="CanvasLayer/Control/block_drawer/TextureRect/TextureRect"] +[node name="block_name" type="Label" parent="CanvasLayer/Control/block_drawer/TextureRect/TextureRect"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = -1 anchor_left = 0.0454545 @@ -527,6 +531,7 @@ layout_mode = 2 layout_mode = 2 [node name="Control" type="Control" parent="CanvasLayer/Control"] +visible = false layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -743,7 +748,6 @@ offset_bottom = 7.0 grow_vertical = 0 script = ExtResource("9_kd3fp") button_model = 3 -animation_time = 0.2 disable_button = true animation_model = 0 metadata/_edit_use_anchors_ = true @@ -890,6 +894,23 @@ anchor_bottom = 0.719298 texture = ExtResource("27_mopsr") metadata/_edit_use_anchors_ = true +[node name="2d_fight_attribute_table" parent="CanvasLayer/Control/left_character_drawer/Control/TextureRect" instance=ExtResource("28_57n5y")] +layout_mode = 0 +anchor_left = 0.628572 +anchor_top = 0.201756 +anchor_right = 0.815873 +anchor_bottom = 0.719297 +offset_right = 0.0 +offset_bottom = 0.0 +attribute_name_1 = "近战" +attribute_value_1 = 95.0 +attribute_name_2 = "护甲" +attribute_value_2 = 95.0 +attribute_name_3 = "暴击率" +attribute_name_4 = "远程" +attribute_value_4 = 50.0 +metadata/_edit_use_anchors_ = true + [node name="right_character_drawer" type="Container" parent="CanvasLayer/Control"] unique_name_in_owner = true layout_mode = 1 @@ -903,9 +924,10 @@ offset_bottom = 7.0 grow_vertical = 0 script = ExtResource("9_kd3fp") button_model = 2 -animation_time = 0.2 disable_button = true animation_model = 0 +is_open = false +rag = 1.0 metadata/_edit_use_anchors_ = true [node name="Control" type="Control" parent="CanvasLayer/Control/right_character_drawer"] @@ -1055,7 +1077,9 @@ anchor_bottom = 0.75 texture = ExtResource("27_mopsr") metadata/_edit_use_anchors_ = true -[node name="TextureRect" type="TextureRect" parent="CanvasLayer/Control"] +[node name="choice" type="TextureRect" parent="CanvasLayer/Control"] +unique_name_in_owner = true +visible = false layout_mode = 1 anchors_preset = -1 anchor_left = 0.398958 @@ -1065,7 +1089,8 @@ anchor_bottom = 0.992593 texture = ExtResource("29_gfcum") metadata/_edit_use_anchors_ = true -[node name="Label" type="Label" parent="CanvasLayer/Control/TextureRect"] +[node name="choice_text" type="Label" parent="CanvasLayer/Control/choice"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = -1 anchor_left = 0.113503 @@ -1078,7 +1103,7 @@ horizontal_alignment = 1 vertical_alignment = 1 metadata/_edit_use_anchors_ = true -[node name="Button" type="Button" parent="CanvasLayer/Control/TextureRect"] +[node name="choice_accept" type="Button" parent="CanvasLayer/Control/choice"] layout_mode = 1 anchors_preset = -1 anchor_left = 0.18591 @@ -1095,7 +1120,7 @@ text = "确定" flat = true metadata/_edit_use_anchors_ = true -[node name="Button2" type="Button" parent="CanvasLayer/Control/TextureRect"] +[node name="choice_refuse" type="Button" parent="CanvasLayer/Control/choice"] layout_mode = 1 anchors_preset = -1 anchor_left = 0.506849 @@ -1111,9 +1136,63 @@ text = "取消" flat = true metadata/_edit_use_anchors_ = true +[node name="action" type="TextureRect" parent="CanvasLayer/Control"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.336458 +anchor_top = 0.562037 +anchor_right = 0.691146 +anchor_bottom = 1.06944 +texture = ExtResource("29_gfcum") +metadata/_edit_use_anchors_ = true + +[node name="Label" type="Label" parent="CanvasLayer/Control/action"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.13069 +anchor_top = 0.218978 +anchor_right = 0.885463 +anchor_bottom = 0.344891 +offset_left = -1.52588e-05 +offset_top = -1.52588e-05 +theme_override_font_sizes/font_size = 26 +text = "我要做什么?" +horizontal_alignment = 1 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control/action"] +layout_mode = 0 +anchor_left = 0.146843 +anchor_top = 0.344891 +anchor_right = 0.86931 +anchor_bottom = 0.806569 +metadata/_edit_use_anchors_ = true + +[node name="choice_add_pos" type="VBoxContainer" parent="CanvasLayer/Control/action/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 3 + +[node name="action_close" type="Button" parent="CanvasLayer/Control/action/VBoxContainer"] +layout_mode = 2 +theme_override_colors/font_hover_pressed_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_colors/font_hover_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_colors/font_pressed_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_colors/font_focus_color = Color(0.984314, 1, 0.00392157, 1) +theme_override_font_sizes/font_size = 26 +text = "结束" +flat = true +metadata/_edit_use_anchors_ = true + [connection signal="pressed" from="CanvasLayer/panel_container/Panel/MarginContainer/VBoxContainer/next" to="." method="_on_next_pressed"] [connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/pop1" to="." method="_on_pop_1_pressed"] [connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/pop2" to="." method="_on_pop_2_pressed"] [connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/pop3" to="." method="_on_pop_3_pressed"] [connection signal="pressed" from="CanvasLayer/Control/HBoxContainer/pop4" to="." method="_on_pop_4_pressed"] [connection signal="timeout" from="CanvasLayer/Control/alert_drawer/alert_timer" to="." method="_on_alert_timer_timeout"] +[connection signal="pressed" from="CanvasLayer/Control/choice/choice_accept" to="." method="_on_choice_accept_pressed"] +[connection signal="pressed" from="CanvasLayer/Control/choice/choice_refuse" to="." method="_on_choice_refuse_pressed"] +[connection signal="pressed" from="CanvasLayer/Control/action/VBoxContainer/action_close" to="." method="_on_action_close_pressed"] diff --git a/scene/_2d_fight/2d_fight_attribute_table.gd b/scene/_2d_fight/2d_fight_attribute_table.gd new file mode 100644 index 0000000..bdcae1e --- /dev/null +++ b/scene/_2d_fight/2d_fight_attribute_table.gd @@ -0,0 +1,108 @@ +extends TextureRect + + +@export var attribute_name_1:String="": + set(val): + attribute_name_1=val + %attribute_name_1.text=val +@export var attribute_value_1:float=0: + set(val): + attribute_value_1=val + %attribute_value_1.text=str(val) + draw_by_value() +@export var attribute_value_1_max:float=100: + set(val): + attribute_value_1_max=val + draw_by_value() + +@export var attribute_name_2:String="": + set(val): + attribute_name_2=val + %attribute_name_2.text=val +@export var attribute_value_2:float=0: + set(val): + attribute_value_2=val + %attribute_value_2.text=str(val) + draw_by_value() +@export var attribute_value_2_max:float=100: + set(val): + attribute_value_2_max=val + draw_by_value() + +@export var attribute_name_3:String="": + set(val): + attribute_name_3=val + %attribute_name_3.text=val +@export var attribute_value_3:float=0: + set(val): + attribute_value_3=val + %attribute_value_3.text=str(val) + draw_by_value() +@export var attribute_value_3_max:float=100: + set(val): + attribute_value_3_max=val + draw_by_value() + +@export var attribute_name_4:String="": + set(val): + attribute_name_4=val + %attribute_name_4.text=val + +@export var attribute_value_4:float=0: + set(val): + attribute_value_4=val + %attribute_value_4.text=str(val) + draw_by_value() +@export var attribute_value_4_max:float=100: + set(val): + attribute_value_4_max=val + draw_by_value() + + +@export var color:Color=Color("FCE1A3") +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + await get_tree().process_frame + queue_redraw() + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +var points:PackedVector2Array=PackedVector2Array() + + +func draw_by_value(): + print("draw") + var f1=attribute_value_1/attribute_value_1_max + var f2=attribute_value_2/attribute_value_2_max + var f3=attribute_value_3/attribute_value_3_max + var f4=attribute_value_4/attribute_value_4_max + + draw_table(f1,f2,f3,f4) +func draw_table(up:float,right:float,down:float,left:float): + + + points.clear() + points.append(size/2-Vector2(0,size.y*up/2)) + points.append(size/2+Vector2(size.x*right/2,0)) + points.append(size/2+Vector2(0,size.y*down/2)) + points.append(size/2-Vector2(size.x*left/2,0)) + queue_redraw() + pass + + + +func _draw() -> void: + print("_draw") + print(points) + draw_polygon(points,create_packed_color_arr(points.size(),color)) + + pass +func create_packed_color_arr(_size:int,_color:Color): + var new_arr=[] + for i in range(_size): + new_arr.append(color) + return PackedColorArray(new_arr) diff --git a/scene/_2d_fight/2d_fight_attribute_table.tscn b/scene/_2d_fight/2d_fight_attribute_table.tscn new file mode 100644 index 0000000..3ff1268 --- /dev/null +++ b/scene/_2d_fight/2d_fight_attribute_table.tscn @@ -0,0 +1,126 @@ +[gd_scene load_steps=4 format=3 uid="uid://3r388ypcowro"] + +[ext_resource type="Texture2D" uid="uid://dv62ydas2laek" path="res://res/ui/new_ui_005_2d_fight/矩形 100@1x.png" id="1_2iw20"] +[ext_resource type="Script" path="res://scene/_2d_fight/2d_fight_attribute_table.gd" id="2_ae48l"] +[ext_resource type="Texture2D" uid="uid://df3jb4yv1aot" path="res://res/ui/new_ui_005_2d_fight/组 146@1x.png" id="3_71rxy"] + +[node name="2d_fight_attribute_table" type="TextureRect"] +offset_right = 118.0 +offset_bottom = 118.0 +texture = ExtResource("1_2iw20") +script = ExtResource("2_ae48l") + +[node name="TextureRect" 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("3_71rxy") + +[node name="attribute_name_1" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.101695 +anchor_top = -0.330508 +anchor_right = 0.508475 +anchor_bottom = -0.0338983 +theme_override_colors/font_color = Color(0.290196, 0.133333, 0.0235294, 1) +theme_override_font_sizes/font_size = 24 +text = "属性" +metadata/_edit_use_anchors_ = true + +[node name="attribute_value_1" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.567797 +anchor_top = -0.330508 +anchor_right = 0.974576 +anchor_bottom = -0.0338983 +theme_override_colors/font_color = Color(0.133333, 0.32549, 0.964706, 1) +theme_override_font_sizes/font_size = 24 +text = "值" +metadata/_edit_use_anchors_ = true + +[node name="attribute_name_2" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 1.01695 +anchor_top = 0.20339 +anchor_right = 1.42373 +anchor_bottom = 0.5 +theme_override_colors/font_color = Color(0.290196, 0.133333, 0.0235294, 1) +theme_override_font_sizes/font_size = 24 +text = "属性" +metadata/_edit_use_anchors_ = true + +[node name="attribute_value_2" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 1.01695 +anchor_top = 0.5 +anchor_right = 1.42373 +anchor_bottom = 0.79661 +theme_override_colors/font_color = Color(0.133333, 0.32549, 0.964706, 1) +theme_override_font_sizes/font_size = 24 +text = "值" +horizontal_alignment = 1 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="attribute_name_3" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = -0.40678 +anchor_top = 0.20339 +anchor_bottom = 0.5 +theme_override_colors/font_color = Color(0.290196, 0.133333, 0.0235294, 1) +theme_override_font_sizes/font_size = 24 +text = "属性" +metadata/_edit_use_anchors_ = true + +[node name="attribute_value_3" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = -0.40678 +anchor_top = 0.5 +anchor_bottom = 0.79661 +theme_override_colors/font_color = Color(0.133333, 0.32549, 0.964706, 1) +theme_override_font_sizes/font_size = 24 +text = "值" +horizontal_alignment = 1 +vertical_alignment = 1 +metadata/_edit_use_anchors_ = true + +[node name="attribute_name_4" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.101695 +anchor_top = 1.04237 +anchor_right = 0.508475 +anchor_bottom = 1.33898 +theme_override_colors/font_color = Color(0.290196, 0.133333, 0.0235294, 1) +theme_override_font_sizes/font_size = 24 +text = "属性" +metadata/_edit_use_anchors_ = true + +[node name="attribute_value_4" type="Label" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.567797 +anchor_top = 1.04237 +anchor_right = 0.974576 +anchor_bottom = 1.33898 +theme_override_colors/font_color = Color(0.133333, 0.32549, 0.964706, 1) +theme_override_font_sizes/font_size = 24 +text = "值" +metadata/_edit_use_anchors_ = true diff --git a/scene/_2d_fight/block_scene/test_character.gd b/scene/_2d_fight/block_scene/test_character.gd index 727636e..c1d46b0 100644 --- a/scene/_2d_fight/block_scene/test_character.gd +++ b/scene/_2d_fight/block_scene/test_character.gd @@ -4,3 +4,7 @@ func _on_create(): self.could_use_action=[BlockActionMove.new(),BlockActionAttackNormal.new()] super._on_create() pass + +func attacked(): + $AnimationPlayer.play("shake") + pass diff --git a/scene/_2d_fight/block_scene/test_character.tscn b/scene/_2d_fight/block_scene/test_character.tscn index 019bcca..b57c0a2 100644 --- a/scene/_2d_fight/block_scene/test_character.tscn +++ b/scene/_2d_fight/block_scene/test_character.tscn @@ -1,8 +1,45 @@ -[gd_scene load_steps=3 format=3 uid="uid://5vqwfn05i63"] +[gd_scene load_steps=6 format=3 uid="uid://5vqwfn05i63"] [ext_resource type="Script" path="res://scene/_2d_fight/block_scene/test_character.gd" id="1_543qj"] [ext_resource type="Texture2D" uid="uid://u55mv3uq7pod" path="res://res/ui/new_ui_005_2d_fight/蒙版组 18@1x.png" id="2_bnn18"] +[sub_resource type="Animation" id="Animation_olb0q"] +resource_name = "shake" +length = 0.2 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.0333333, 0.0666667, 0.1, 0.133333, 0.166667, 0.2), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1), +"update": 0, +"values": [Vector2(0, 0), Vector2(6, 2), Vector2(-17, -6), Vector2(26, -4), Vector2(-7, -7), Vector2(11, -2), Vector2(0, 0)] +} + +[sub_resource type="Animation" id="Animation_4i1ic"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_7o6we"] +_data = { +"RESET": SubResource("Animation_4i1ic"), +"shake": SubResource("Animation_olb0q") +} + [node name="test_character" type="Node2D"] script = ExtResource("1_543qj") could_be_used_for_target = true @@ -10,3 +47,8 @@ could_be_used_for_target = true [node name="Sprite2D" type="Sprite2D" parent="."] scale = Vector2(0.915, 0.915) texture = ExtResource("2_bnn18") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_7o6we") +} diff --git a/scene/_2d_fight/block_scene/wall.tscn b/scene/_2d_fight/block_scene/wall.tscn index fe688a2..6b17602 100644 --- a/scene/_2d_fight/block_scene/wall.tscn +++ b/scene/_2d_fight/block_scene/wall.tscn @@ -5,6 +5,10 @@ [node name="Wall" type="Node2D"] script = ExtResource("1_vd8gg") +block_name = "墙" +block_attribute = { +"可移动": false +} [node name="Sprite2D" type="Sprite2D" parent="."] texture = ExtResource("2_rhwnk") diff --git a/scene/_2d_fight/block_tag_label.gd b/scene/_2d_fight/block_tag_label.gd new file mode 100644 index 0000000..4bc0589 --- /dev/null +++ b/scene/_2d_fight/block_tag_label.gd @@ -0,0 +1,8 @@ +extends HBoxContainer + +#设置block mes的显示信息 +func set_mes(_name:String,value:bool): + $Label.text=_name + $TextureRect.visible=not value + + pass diff --git a/scene/_2d_fight/block_tag_label.tscn b/scene/_2d_fight/block_tag_label.tscn index acada3d..a198cb3 100644 --- a/scene/_2d_fight/block_tag_label.tscn +++ b/scene/_2d_fight/block_tag_label.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=2 format=3 uid="uid://bv4c1xq4wm2o7"] +[gd_scene load_steps=3 format=3 uid="uid://bv4c1xq4wm2o7"] +[ext_resource type="Script" path="res://scene/_2d_fight/block_tag_label.gd" id="1_orsy7"] [ext_resource type="Texture2D" uid="uid://cxxqhiporcwlp" path="res://res/ui/new_ui_005_2d_fight/组 114@1x.png" id="1_x8c6l"] [node name="block_tag_label" type="HBoxContainer"] offset_right = 84.0 offset_bottom = 32.0 +script = ExtResource("1_orsy7") [node name="Label" type="Label" parent="."] layout_mode = 2 diff --git a/scene/gacha3d/node_3d.gd b/scene/gacha3d/node_3d.gd new file mode 100644 index 0000000..67e954f --- /dev/null +++ b/scene/gacha3d/node_3d.gd @@ -0,0 +1 @@ +extends Node3D diff --git a/scene/gacha3d/node_3d.tscn b/scene/gacha3d/node_3d.tscn new file mode 100644 index 0000000..6ccbfcb --- /dev/null +++ b/scene/gacha3d/node_3d.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://b2rw6p7ov3pti"] + +[ext_resource type="Script" path="res://scene/gacha3d/node_3d.gd" id="1_o4ka8"] + +[node name="Node3D" type="Node3D"] +script = ExtResource("1_o4ka8") diff --git a/scene/gacha3d/sprite_3d.tscn b/scene/gacha3d/sprite_3d.tscn new file mode 100644 index 0000000..fcece75 --- /dev/null +++ b/scene/gacha3d/sprite_3d.tscn @@ -0,0 +1,31 @@ +[gd_scene load_steps=4 format=3 uid="uid://uxqmenk7dwva"] + +[sub_resource type="ViewportTexture" id="ViewportTexture_2gwg3"] +viewport_path = NodePath("SubViewport") + +[sub_resource type="Gradient" id="Gradient_m1mq6"] + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_hrx3e"] +gradient = SubResource("Gradient_m1mq6") +width = 570 +height = 880 + +[node name="Sprite3D" type="Sprite3D"] +double_sided = false +texture = SubResource("ViewportTexture_2gwg3") + +[node name="SubViewport" type="SubViewport" parent="."] +size = Vector2i(570, 880) + +[node name="Control" type="Control" parent="SubViewport"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Sprite3D" type="Sprite3D" parent="."] +transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0) +double_sided = false +texture = SubResource("GradientTexture2D_hrx3e")