diff --git a/autoload/database/script/database.gd b/autoload/database/script/database.gd index 59b91dd..862c832 100644 --- a/autoload/database/script/database.gd +++ b/autoload/database/script/database.gd @@ -349,3 +349,17 @@ func get_special_type(id:String): return special_data[id]["type"] else: return "" + + +static func pre_process_scene_data(dict:Dictionary): + for i in dict.keys(): + dict[i]=load(dict[i]) + return dict +var block_data:Dictionary=pre_process_scene_data(preload("res://json/block.json").data) + +func get_block(n:String): + if block_data.has(n): + return block_data[n] + else: + return null + pass diff --git a/class/2dFightBlock/BlockAction/block_action_attack_distance.gd b/class/2dFightBlock/BlockAction/block_action_attack_distance.gd new file mode 100644 index 0000000..193ee93 --- /dev/null +++ b/class/2dFightBlock/BlockAction/block_action_attack_distance.gd @@ -0,0 +1,144 @@ +extends BlockAction + +class_name BlockActionAttackDistance + + +var attack_distance:int=0 +func _init() -> void: + self.action_name="远程攻击" + self.need_target=true + + pass +#获取动作可以作用于的地块(true or false)二维数组,并建立寻路缓存 +func get_action_could_use_block(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary)->Array: + var astar=AStarGrid2D.new() + print(global_block_data) + astar.default_compute_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.default_estimate_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.diagonal_mode=AStarGrid2D.DIAGONAL_MODE_NEVER + astar.region=Rect2i(tile_map_area.position,tile_map_area.size+Vector2i(1,1)) + astar.update() + var right_pos:Vector2i=tile_map_area.position+tile_map_area.size + for i in range(tile_map_area.position.x,right_pos.x+1): + var res_in:Array[bool]=[] + for j in range(tile_map_area.position.y,right_pos.y+1): + if global_block_data.has(Vector2i(i,j)): + #计算当前地块是否可通行 + var block_arr:Array=global_block_data[Vector2i(i,j)] + var walkable:bool=true + for k in block_arr: + if k is BaseBlock: + walkable=walkable and k.walkable + astar.set_point_solid(Vector2i(i,j),not walkable) + else: + #默认可通行 + astar.set_point_solid(Vector2i(i,j),false) + var res:Array=[] + block_road_cache=[] + for i in range(tile_map_area.position.x,right_pos.x+1): + var res_in:Array[bool]=[] + var block_in:Array=[] + for j in range(tile_map_area.position.y,right_pos.y+1): + var road_find_result=is_move_able(astar,_self.block_pos,Vector2i(i,j),_self.action_num,tile_map_area) + block_in.append(road_find_result) + res_in.append(road_find_result[0]) + res.append(res_in) + block_road_cache.append(block_in) + pass + return res + + +#区域是否可达 +func is_move_able(astar:AStarGrid2D,from:Vector2i,to:Vector2i,move_distance:int,tile_map_area:Rect2i): + var res=get_walkable_path(astar,from,to,tile_map_area) + if not res[0]: + return [false,0,null] + var distance=res[1] + if move_distance>=distance: + return [true,res[1],res[2]] + else: + return [false,0,null] + + + + +#获取两点之间的最短可达路径,返回一个数组,0下标未是否可达,1下标为距离,2下标为途径点数组 +func get_walkable_path(astar:AStarGrid2D,from:Vector2i,to:Vector2i,tile_map_area:Rect2i)->Array: + var right_pos=tile_map_area.position+tile_map_area.size + #如果不在要求的tilemap范围内,则返回不可达 + if to.xright_pos.x or to.yright_pos.y: + return [false,0,null] + var arr=astar.get_id_path(from,to) + if arr==null or (arr is Array and arr.size()<=0): + return [false,0,null] + return [true,arr.size()-1,arr] +#寻路缓存 +var block_road_cache:Array=[] +#在_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 astar=AStarGrid2D.new() + astar.default_compute_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.default_estimate_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.diagonal_mode=AStarGrid2D.DIAGONAL_MODE_NEVER + astar.region=Rect2i(tile_map_area.position,tile_map_area.size+Vector2i(1,1)) + astar.update() + var right_pos:Vector2i=tile_map_area.position+tile_map_area.size + for i in range(tile_map_area.position.x,right_pos.x+1): + var res_in:Array[bool]=[] + for j in range(tile_map_area.position.y,right_pos.y+1): + if global_block_data.has(Vector2i(i,j)): + #计算当前地块是否可通行 + var block_arr:Array=global_block_data[Vector2i(i,j)] + var walkable:bool=true + for k in block_arr: + if k is BaseBlock: + walkable=walkable and k.walkable + astar.set_point_solid(Vector2i(i,j),not walkable) + else: + #默认可通行 + astar.set_point_solid(Vector2i(i,j),false) + var res=is_move_able(astar,_self.block_pos,target,_self.action_num,tile_map_area) + if res[0]: + _self.action_num-=res[1] + _self.request_move(res[2],global_block_data) + return true + return false +var draw_line +#展示施法演示 +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: + if draw_line!=null: + draw_line.queue_free() + draw_line=null + return + var crood=target-tile_map_area.position + var cache=block_road_cache[crood.x][crood.y] + if not cache[0]: + if draw_line!=null: + draw_line.queue_free() + draw_line=null + return + var point_arr:Array=cache[2] + if draw_line!=null: + draw_line.queue_free() + draw_line=null + var new_line=Line2D.new() + block_add_pos.add_child(new_line) + draw_line=new_line + draw_line.default_color=Color.RED + for i in point_arr: + draw_line.add_point(block_add_pos.map_to_local(i)) + + + pass +#释放施法演示 +func del_action_with_target(): + block_road_cache.clear() + if draw_line!=null: + draw_line.queue_free() + draw_line=null + pass diff --git a/class/2dFightBlock/BlockAction/block_action_attack_normal.gd b/class/2dFightBlock/BlockAction/block_action_attack_normal.gd new file mode 100644 index 0000000..2e82758 --- /dev/null +++ b/class/2dFightBlock/BlockAction/block_action_attack_normal.gd @@ -0,0 +1,41 @@ +extends BlockAction + + +#基础近战攻击行动 +class_name BlockActionAttackNormal + +func _init() -> void: + self.action_name="近战攻击" + self.need_target=true + + pass +var attack_cache:Array=[] +#获取动作可以作用于的地块(true or false)二维数组,并建立攻击缓存 +func get_action_could_use_block(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary)->Array: + var res:Array=[] + var right_pos:Vector2i=tile_map_area.position+tile_map_area.size + for i in range(tile_map_area.position.x,right_pos.x+1): + var res_in:Array[bool]=[] + for j in range(tile_map_area.position.y,right_pos.y+1): + res_in.append(false) + res.append(res_in) + 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] + for i in pos_arr: + if global_block_data.has(i): + var could_attack=false + var block_arr=global_block_data[i] + for j in block_arr: + if j is BaseBlock: + could_attack =could_attack or j.could_be_used_for_target + if could_attack: + var ind:Vector2i=i-tile_map_area.position + res[ind.x][ind.y]=true + attack_cache=res + + return res + diff --git a/class/2dFightBlock/BlockAction/block_action_move.gd b/class/2dFightBlock/BlockAction/block_action_move.gd new file mode 100644 index 0000000..f3fe633 --- /dev/null +++ b/class/2dFightBlock/BlockAction/block_action_move.gd @@ -0,0 +1,142 @@ +extends BlockAction +class_name BlockActionMove + + +func _init() -> void: + self.action_name="移动" + self.need_target=true + + pass +#获取动作可以作用于的地块(true or false)二维数组,并建立寻路缓存 +func get_action_could_use_block(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary)->Array: + var astar=AStarGrid2D.new() + print(global_block_data) + astar.default_compute_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.default_estimate_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.diagonal_mode=AStarGrid2D.DIAGONAL_MODE_NEVER + astar.region=Rect2i(tile_map_area.position,tile_map_area.size+Vector2i(1,1)) + astar.update() + var right_pos:Vector2i=tile_map_area.position+tile_map_area.size + for i in range(tile_map_area.position.x,right_pos.x+1): + var res_in:Array[bool]=[] + for j in range(tile_map_area.position.y,right_pos.y+1): + if global_block_data.has(Vector2i(i,j)): + #计算当前地块是否可通行 + var block_arr:Array=global_block_data[Vector2i(i,j)] + var walkable:bool=true + for k in block_arr: + if k is BaseBlock: + walkable=walkable and k.walkable + astar.set_point_solid(Vector2i(i,j),not walkable) + else: + #默认可通行 + astar.set_point_solid(Vector2i(i,j),false) + var res:Array=[] + block_road_cache=[] + for i in range(tile_map_area.position.x,right_pos.x+1): + var res_in:Array[bool]=[] + var block_in:Array=[] + for j in range(tile_map_area.position.y,right_pos.y+1): + var road_find_result=is_move_able(astar,_self.block_pos,Vector2i(i,j),_self.action_num,tile_map_area) + block_in.append(road_find_result) + res_in.append(road_find_result[0]) + res.append(res_in) + block_road_cache.append(block_in) + pass + return res + + +#区域是否可达 +func is_move_able(astar:AStarGrid2D,from:Vector2i,to:Vector2i,move_distance:int,tile_map_area:Rect2i): + var res=get_walkable_path(astar,from,to,tile_map_area) + if not res[0]: + return [false,0,null] + var distance=res[1] + if move_distance>=distance: + return [true,res[1],res[2]] + else: + return [false,0,null] + + + + +#获取两点之间的最短可达路径,返回一个数组,0下标未是否可达,1下标为距离,2下标为途径点数组 +func get_walkable_path(astar:AStarGrid2D,from:Vector2i,to:Vector2i,tile_map_area:Rect2i)->Array: + var right_pos=tile_map_area.position+tile_map_area.size + #如果不在要求的tilemap范围内,则返回不可达 + if to.xright_pos.x or to.yright_pos.y: + return [false,0,null] + var arr=astar.get_id_path(from,to) + if arr==null or (arr is Array and arr.size()<=0): + return [false,0,null] + return [true,arr.size()-1,arr] +#寻路缓存 +var block_road_cache:Array=[] +#在_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 astar=AStarGrid2D.new() + astar.default_compute_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.default_estimate_heuristic=AStarGrid2D.HEURISTIC_MANHATTAN + astar.diagonal_mode=AStarGrid2D.DIAGONAL_MODE_NEVER + astar.region=Rect2i(tile_map_area.position,tile_map_area.size+Vector2i(1,1)) + astar.update() + var right_pos:Vector2i=tile_map_area.position+tile_map_area.size + for i in range(tile_map_area.position.x,right_pos.x+1): + var res_in:Array[bool]=[] + for j in range(tile_map_area.position.y,right_pos.y+1): + if global_block_data.has(Vector2i(i,j)): + #计算当前地块是否可通行 + var block_arr:Array=global_block_data[Vector2i(i,j)] + var walkable:bool=true + for k in block_arr: + if k is BaseBlock: + walkable=walkable and k.walkable + astar.set_point_solid(Vector2i(i,j),not walkable) + else: + #默认可通行 + astar.set_point_solid(Vector2i(i,j),false) + var res=is_move_able(astar,_self.block_pos,target,_self.action_num,tile_map_area) + if res[0]: + _self.action_num-=res[1] + _self.request_move(res[2],global_block_data) + return true + return false +var draw_line +#展示施法演示 +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: + if draw_line!=null: + draw_line.queue_free() + draw_line=null + return + var crood=target-tile_map_area.position + var cache=block_road_cache[crood.x][crood.y] + if not cache[0]: + if draw_line!=null: + draw_line.queue_free() + draw_line=null + return + var point_arr:Array=cache[2] + if draw_line!=null: + draw_line.queue_free() + draw_line=null + var new_line=Line2D.new() + block_add_pos.add_child(new_line) + draw_line=new_line + draw_line.default_color=Color.RED + for i in point_arr: + draw_line.add_point(block_add_pos.map_to_local(i)) + + + pass +#释放施法演示 +func del_action_with_target(): + block_road_cache.clear() + if draw_line!=null: + draw_line.queue_free() + draw_line=null + pass diff --git a/class/2dFightBlock/base_block.gd b/class/2dFightBlock/base_block.gd new file mode 100644 index 0000000..9c65ccb --- /dev/null +++ b/class/2dFightBlock/base_block.gd @@ -0,0 +1,85 @@ +@tool +extends Node2D +#基础地块 +class_name BaseBlock + +#当地块要求进行移动时发出 +signal request_block_move(before_pos:Vector2i,request_pos:Vector2i) +#当前地块是否可以行走 +@export var walkable:bool=false +#当前块是否可以被用作施法(攻击目标) +@export var could_be_used_for_target:bool=false +#当前地块的坐标 +@export var block_pos:Vector2i=Vector2i.ZERO: + set(val): + block_pos=val + var parent=get_parent() + if parent is TileMapLayer: + self.position=parent.map_to_local(block_pos) + + pass + +#实例化地块来源场景库 +static var BlockClassDictionary:Dictionary={ + +} + + +func _ready() -> void: + var parent=get_parent() + if parent is TileMapLayer: + self.position=parent.map_to_local(block_pos) + _on_create() + pass +#地块被创建时发出 +func _on_create(): + + + pass +#当地块删除时发出 +func _on_delete(): + + + + pass + + +#当其他地块进入自己的地块时触发 +func blocker_enter(block:BaseBlock): + + pass +#当其他地块退出自己的区域时触发 +func blocker_out(block:BaseBlock): + + + pass +#当其他地块在自己的地块上等待一回合时触发 +func blocker_turn(blocker:BaseBlock): + + + + pass +#要求地块移动 +func request_move(move_path_point_arr:Array,global_blocker_data:Dictionary): + + if move_path_point_arr.size()<2: + return + self.block_pos=move_path_point_arr.back() + if global_blocker_data.has(move_path_point_arr[0]): + var arr:Array=global_blocker_data[move_path_point_arr[0]] + for i in arr: + if i is BaseBlock: + i.blocker_out(self) + for i in range(1,move_path_point_arr.size()-1): + if global_blocker_data.has(move_path_point_arr[i]): + var arr:Array=global_blocker_data[move_path_point_arr[0]] + for j in arr: + if j is BaseBlock: + j.blocker_enter(self) + j.blocker_out(self) + request_block_move.emit(move_path_point_arr[0],move_path_point_arr.back()) + pass + +func turn(): + + pass diff --git a/class/2dFightBlock/block_action.gd b/class/2dFightBlock/block_action.gd new file mode 100644 index 0000000..1ebf1cc --- /dev/null +++ b/class/2dFightBlock/block_action.gd @@ -0,0 +1,33 @@ +extends Object +#地块使用行动信息的基础类 +class_name BlockAction + +#行动名字 +var action_name:String="未命名行动名字" + +#是否需要目标 +var need_target:bool=false +#选择目标时显示的作用范围 +var target_area:Rect2i=Rect2i() +#获取动作可以作用于的地块(true or false)二维数组 +func get_action_could_use_block(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary): + + + + + pass +#在_self上使用action动作,返回是否成功 +func block_use_action(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary,target=null)->bool: + + + return false + +#展示施法演示 +func draw_action_with_target(_self:UnitBlock,tile_map_area:Rect2i,global_block_data:Dictionary,target:Vector2i,block_add_pos:TileMapLayer): + + + pass +#释放施法演示 +func del_action_with_target(): + + pass diff --git a/class/2dFightBlock/unit_block.gd b/class/2dFightBlock/unit_block.gd new file mode 100644 index 0000000..8f5bed2 --- /dev/null +++ b/class/2dFightBlock/unit_block.gd @@ -0,0 +1,28 @@ +extends BaseBlock + + +class_name UnitBlock + +#单位的数据 +var unit_data:Dictionary={} + +#行动点数 +var action_num:int=5 +#可以使用的动作 +var could_use_action:Array[BlockAction] +#被创建时重定义数据 +func _on_create(): + self.walkable=false + self.could_be_used_for_target=true + super._on_create() + +func get_all_choice()->Array: + var res=[] + for i in could_use_action: + res.append(i.action_name) + return res + +func turn(): + action_num=5 + + pass diff --git a/json/block.json b/json/block.json new file mode 100644 index 0000000..4233bbc --- /dev/null +++ b/json/block.json @@ -0,0 +1,4 @@ +{ + "wall":"res://scene/_2d_fight/block_scene/wall.tscn", + "test_character":"res://scene/_2d_fight/block_scene/test_character.tscn" +} diff --git a/project.godot b/project.godot index 70609b1..2d88032 100644 --- a/project.godot +++ b/project.godot @@ -82,6 +82,11 @@ d={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null) ] } +esc={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [layer_names] diff --git a/res/ui/new_ui_001_main/banner.png b/res/ui/new_ui_001_main/banner.png new file mode 100644 index 0000000..f1e07ac Binary files /dev/null and b/res/ui/new_ui_001_main/banner.png differ diff --git a/res/ui/new_ui_001_main/banner.png.import b/res/ui/new_ui_001_main/banner.png.import new file mode 100644 index 0000000..f0996bc --- /dev/null +++ b/res/ui/new_ui_001_main/banner.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cyvpsjsou3xuh" +path="res://.godot/imported/banner.png-1c9c2ff42713f8cb20305f8aea90f37f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://res/ui/new_ui_001_main/banner.png" +dest_files=["res://.godot/imported/banner.png-1c9c2ff42713f8cb20305f8aea90f37f.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/_2d_fight/2d_fight.gd b/scene/_2d_fight/2d_fight.gd index 1d608f4..a90e93d 100644 --- a/scene/_2d_fight/2d_fight.gd +++ b/scene/_2d_fight/2d_fight.gd @@ -39,7 +39,7 @@ enum CameraMode{ if camera_focus_mode_focus_tween!=null: camera_focus_mode_focus_tween.kill() camera_focus_mode_focus_tween=create_tween() - camera_focus_mode_focus_tween.tween_property(%main_camera,"globla_position",val.global_position,camera_focus_mode_focus_time) + camera_focus_mode_focus_tween.tween_property(%main_camera,"global_position",val.global_position,camera_focus_mode_focus_time) camera_focus_mode_focus_tween.set_parallel() camera_focus_mode_focus_tween.tween_property(%main_camera,"zoom",camera_base_zoom_scale*camera_focus_mode_focus_scale,camera_focus_mode_focus_time) camera_focusmode_focus_target=val @@ -55,42 +55,76 @@ var camera_focus_mode_focus_scale:float=1.5 -#测试部分 -#测试的角色移动力 -var test_character_move_distance:int=5 -func update_moveable(): - for i in get_children(): - if i is Label: - i.queue_free() - %color_block.clear() - var character_crood:Vector2i=%walkable.local_to_map(%test_character.global_position) - for i in range(tile_map_area_from.x,tile_map_area_to.x): - for j in range(tile_map_area_from.y,tile_map_area_to.y): - var crood=Vector2i(i,j) - var res=is_move_able(character_crood,crood,test_character_move_distance) - if res[0]: - %color_block.set_cell(crood,ColorBlockSetColor.GREEN,Vector2i(0,0)) - else: - %color_block.set_cell(crood,ColorBlockSetColor.RED,Vector2i(0,0)) - var new_label=Label.new() - new_label.text=str(res[1]) - new_label.global_position=%walkable.map_to_local(crood) - add_child(new_label) +##地块Block部分 +#全局地块数据引用 +#Vector2i:Array[BaseBlock] +var global_block_data:Dictionary={ + +} +#友方单位(需要自己做出行动选择的) +var friendly_side:Array[UnitBlock]=[] + +#敌方单位(自动进行行动选择的) +var enermy_side:Array[UnitBlock]=[] + +var now_use_block:UnitBlock + +var now_use_action:int=-1: + set(val): + if now_use_action!=val: + match val: + -1: + %color_block.clear() + %panel_container.change_open(true) + var block_action:BlockAction=now_use_block.could_use_action[now_use_action] + block_action.del_action_with_target() + _: + print("尝试进行行动") + var block_action:BlockAction=now_use_block.could_use_action[val] + print(block_action.need_target) + if block_action.need_target: + + var res=block_action.get_action_could_use_block(now_use_block,Rect2i(tile_map_area_from,tile_map_area_to-tile_map_area_from),global_block_data) + print(res) + show_color_block(res) + %panel_container.change_open(false) + pass + now_use_action=val -#区域是否可达 -func is_move_able(from:Vector2i,to:Vector2i,move_distance:int): - var res=get_walkable_path(from,to) - if not res[0]: - return [false,0,null] - var distance=res[1] - if move_distance>=distance: - return [true,res[1],res[2]] - else: - return [false,0,null] - - + pass +var now_index:int=0 +func turn(): + now_index=-1 + for i in global_block_data.keys(): + var arr=global_block_data[i] + for j in arr: + if j is BaseBlock: + j.turn() + next() + pass +func next(): + for i in %choice_add_pos.get_children(): + i.queue_free() + now_index+=1 + now_use_action=-1 + if now_index>=friendly_side.size(): + turn() + return + var now_block:UnitBlock=friendly_side[now_index] + now_use_block=now_block + var choice_arr=now_block.get_all_choice() + for i in range(choice_arr.size()): + var new_btn=Button.new() + new_btn.pressed.connect(select_choice.bind(i)) + new_btn.text=choice_arr[i] + %choice_add_pos.add_child(new_btn) + pass +func select_choice(index:int): + print(index) + now_use_action=index + pass func _ready() -> void: @@ -100,7 +134,15 @@ func _ready() -> void: astar.region=Rect2i(tile_map_area_from,tile_map_area_to-tile_map_area_from) astar.update() update_astar_from_walkable_map() - update_moveable() + + + for i in range(10): + add_block(Vector2i(i,i),Database.get_block("wall"),2) + for i in range(10): + add_block(Vector2i(i,i+1),Database.get_block("test_character"),0) + #for i in range(10): + #add_block(Vector2i(i,i+2),Database.get_block("test_character"),1) + turn() #从可行走tilemap图中同步到astar寻路中 func update_astar_from_walkable_map(): for i in range(tile_map_area_from.x,tile_map_area_to.x): @@ -122,7 +164,10 @@ func get_walkable_path(from:Vector2i,to:Vector2i)->Array: return [false,0,null] return [true,arr.size()-1,arr] - pass + + +#上一帧的缓存 +var before_mouse_block:Vector2i=Vector2i.ZERO func _process(delta: float) -> void: match camera_mode: @@ -131,12 +176,98 @@ func _process(delta: float) -> void: %main_camera.position+=input*delta*camera_speed CameraMode.FOCUS: pass + #测试角色移动 if Input.is_action_just_pressed("mouse_left"): print("click") - var from_crood=%walkable.local_to_map(%test_character.global_position) - var crood=%walkable.local_to_map(get_global_mouse_position()) - var res=is_move_able(from_crood,crood,test_character_move_distance) - print(res) - if res[0]: - %test_character.global_position=%walkable.map_to_local(crood) - update_moveable() + if now_use_action!=-1: + + var crood=%block_add_pos.local_to_map(get_global_mouse_position()) + var now_action:BlockAction=now_use_block.could_use_action[now_use_action] + 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 + + if Input.is_action_just_pressed("esc"): + now_use_action=-1 + +func _input(event: InputEvent) -> void: + if event is InputEventMouseMotion: + var mouse_pos=get_global_mouse_position() + var crood=%mouse_block.local_to_map(mouse_pos) + update_mouse_block(crood) + if before_mouse_block!=crood: + + before_mouse_block=crood + draw_action(crood) + +func draw_action(target:Vector2i): + if now_use_action==-1: + return + if not now_use_block is UnitBlock: + return + var block_action:BlockAction=now_use_block.could_use_action[now_use_action] + print(block_action.need_target) + if block_action.need_target: + block_action.draw_action_with_target(now_use_block,Rect2i(tile_map_area_from,tile_map_area_to-tile_map_area_from),global_block_data,target,%block_add_pos) + +#更新鼠标显示 +func update_mouse_block(pos:Vector2i,area:Rect2i=Rect2i(0,0,0,0)): + %mouse_block.clear() + var area_right=area.position+area.size + for i in range(area.position.x,area_right.x+1): + for j in range(area.position.y,area_right.y+1): + var offset=Vector2i(i,j) + %mouse_block.set_cell(pos+offset,0,Vector2i(0,0)) + + pass + +func add_block(pos:Vector2i,scene:PackedScene,queue): + var instance:BaseBlock=scene.instantiate() + instance.block_pos=pos + instance.request_block_move.connect(move_block.bind(instance)) + %block_add_pos.add_child(instance) + match queue: + 0: + friendly_side.append(instance) + 1: + enermy_side.append(instance) + add_block_to_data(instance,pos) +#移动block实例到指定位置 +func move_block(from_pos:Vector2i,to_pos:Vector2i,block_instance:BaseBlock): + if not global_block_data.has(from_pos): + return + var arr:Array=global_block_data[from_pos] + if not block_instance in arr: + return + arr.pop_at(arr.find(block_instance)) + if not global_block_data.has(to_pos): + global_block_data[to_pos]=[block_instance] + else: + global_block_data[to_pos].append(block_instance) + + pass +#将block的引用添加到全局字典中 +func add_block_to_data(block:BaseBlock,pos:Vector2i): + if not global_block_data.has(pos): + global_block_data[pos]=[block] + else: + global_block_data[pos].append(block) + pass + + + pass + +func show_color_block(arr:Array): + for i in range((tile_map_area_to-tile_map_area_from).x+1): + for j in range((tile_map_area_to-tile_map_area_from).y+1): + var offset=Vector2i(i,j) + if arr[i][j]: + %color_block.set_cell(tile_map_area_from+offset,ColorBlockSetColor.GREEN,Vector2i(0,0)) + else: + %color_block.set_cell(tile_map_area_from+offset,ColorBlockSetColor.RED,Vector2i(0,0)) + pass + + +func _on_next_pressed() -> void: + next() + pass # Replace with function body. diff --git a/scene/_2d_fight/2d_fight.tscn b/scene/_2d_fight/2d_fight.tscn index ff201b0..57e2298 100644 --- a/scene/_2d_fight/2d_fight.tscn +++ b/scene/_2d_fight/2d_fight.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=4 uid="uid://du6ct6v45ljtu"] +[gd_scene load_steps=23 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"] @@ -7,7 +7,7 @@ [ext_resource type="Texture2D" uid="uid://dkecwuix7ykv4" path="res://res/ui/ui_033_2d_fight/icon_color_64x64/red.png" id="5_3fku7"] [ext_resource type="Texture2D" uid="uid://bi25ys30tbg5s" path="res://res/ui/ui_033_2d_fight/icon_color_64x64/white.png" id="6_xautx"] [ext_resource type="Texture2D" uid="uid://cq0wc2267qtc4" path="res://res/ui/ui_033_2d_fight/icon_color_64x64/yellow.png" id="7_3sowm"] -[ext_resource type="Texture2D" uid="uid://be3n1b7s2o4mm" path="res://icon.svg" id="8_m63x5"] +[ext_resource type="Script" path="res://class/tool/DrawerContainer.gd" id="9_kd3fp"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_bd2vv"] texture = ExtResource("2_rfpw5") @@ -27,6 +27,9 @@ custom_data_layer_0/type = 1 sources/0 = SubResource("TileSetAtlasSource_bd2vv") sources/1 = SubResource("TileSetAtlasSource_brwow") +[sub_resource type="TileSet" id="TileSet_aef74"] +tile_size = Vector2i(64, 64) + [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_oi4sk"] texture = ExtResource("2_rfpw5") texture_region_size = Vector2i(64, 64) @@ -66,9 +69,27 @@ sources/3 = SubResource("TileSetAtlasSource_l0dlq") sources/4 = SubResource("TileSetAtlasSource_2x2wq") sources/5 = SubResource("TileSetAtlasSource_grorl") +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_0a8fi"] +texture = ExtResource("6_xautx") +texture_region_size = Vector2i(64, 64) +0:0/0 = 0 + +[sub_resource type="TileSet" id="TileSet_efupx"] +tile_size = Vector2i(64, 64) +sources/0 = SubResource("TileSetAtlasSource_0a8fi") + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_srekj"] +bg_color = Color(0.355314, 0.355314, 0.355313, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 +shadow_size = 13 + [node name="2DFight" type="Node2D"] script = ExtResource("1_i1eox") tile_map_area_to = Vector2i(29, 16) +camera_base_zoom_scale = Vector2(1, 1) [node name="main_camera" type="Camera2D" parent="."] unique_name_in_owner = true @@ -80,14 +101,63 @@ unique_name_in_owner = true [node name="walkable" type="TileMapLayer" parent="tile_map"] unique_name_in_owner = true +visible = false tile_map_data = PackedByteArray("AAAAAAAAAQAAAAAAAAAAAAEAAQAAAAAAAAAAAAIAAQAAAAAAAAAAAAMAAQAAAAAAAAAAAAQAAQAAAAAAAAAAAAUAAQAAAAAAAAAAAAYAAQAAAAAAAAAAAAcAAQAAAAAAAAAAAAgAAQAAAAAAAAAAAAkAAQAAAAAAAAAAAAoAAQAAAAAAAAAAAAsAAQAAAAAAAAAAAAwAAQAAAAAAAAAAAA0AAQAAAAAAAAAAAA4AAQAAAAAAAAAAAA8AAQAAAAAAAAAAABAAAQAAAAAAAAABAAAAAQAAAAAAAAABAAEAAQAAAAAAAAABAAIAAQAAAAAAAAABAAMAAQAAAAAAAAABAAQAAQAAAAAAAAABAAUAAQAAAAAAAAABAAYAAQAAAAAAAAABAAcAAQAAAAAAAAABAAgAAQAAAAAAAAABAAkAAQAAAAAAAAABAAoAAQAAAAAAAAABAAsAAQAAAAAAAAABAAwAAQAAAAAAAAABAA0AAQAAAAAAAAABAA4AAQAAAAAAAAABAA8AAQAAAAAAAAABABAAAQAAAAAAAAACAAAAAQAAAAAAAAACAAEAAQAAAAAAAAACAAIAAQAAAAAAAAACAAMAAQAAAAAAAAACAAQAAQAAAAAAAAACAAUAAQAAAAAAA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AAAAAAdAAUAAQAAAAAAAAAdAAYAAQAAAAAAAAAdAAcAAQAAAAAAAAAdAAgAAQAAAAAAAAAdAAkAAQAAAAAAAAAdAAoAAQAAAAAAAAAdAAsAAQAAAAAAAAAdAAwAAQAAAAAAAAAdAA0AAQAAAAAAAAAdAA4AAQAAAAAAAAAdAA8AAQAAAAAAAAAdABAAAQAAAAAAAAAaAAQAAQAAAAAAAAA=") tile_set = SubResource("TileSet_u4wdi") -[node name="test_character" type="Sprite2D" parent="tile_map"] +[node name="block_add_pos" type="TileMapLayer" parent="tile_map"] unique_name_in_owner = true -scale = Vector2(0.5, 0.5) -texture = ExtResource("8_m63x5") +tile_set = SubResource("TileSet_aef74") [node name="color_block" type="TileMapLayer" parent="tile_map"] unique_name_in_owner = true tile_set = SubResource("TileSet_j5hfj") + +[node name="mouse_block" type="TileMapLayer" parent="tile_map"] +unique_name_in_owner = true +tile_set = SubResource("TileSet_efupx") + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="panel_container" type="Container" parent="CanvasLayer"] +unique_name_in_owner = true +anchors_preset = -1 +anchor_left = 0.765104 +anchor_top = 0.0277778 +anchor_right = 0.998958 +anchor_bottom = 0.592593 +script = ExtResource("9_kd3fp") +button_model = 2 +disable_button = true +metadata/_edit_use_anchors_ = true + +[node name="Panel" type="Panel" parent="CanvasLayer/panel_container"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_srekj") + +[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/panel_container/Panel"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/panel_container/Panel/MarginContainer"] +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 + +[node name="next" type="Button" parent="CanvasLayer/panel_container/Panel/MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "下一个" + +[connection signal="pressed" from="CanvasLayer/panel_container/Panel/MarginContainer/VBoxContainer/next" to="." method="_on_next_pressed"] diff --git a/scene/_2d_fight/block_scene/test_character.gd b/scene/_2d_fight/block_scene/test_character.gd new file mode 100644 index 0000000..727636e --- /dev/null +++ b/scene/_2d_fight/block_scene/test_character.gd @@ -0,0 +1,6 @@ +extends UnitBlock +func _on_create(): + + self.could_use_action=[BlockActionMove.new(),BlockActionAttackNormal.new()] + super._on_create() + pass diff --git a/scene/_2d_fight/block_scene/test_character.tscn b/scene/_2d_fight/block_scene/test_character.tscn new file mode 100644 index 0000000..b7850be --- /dev/null +++ b/scene/_2d_fight/block_scene/test_character.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 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://be3n1b7s2o4mm" path="res://icon.svg" id="2_eh4u5"] + +[node name="test_character" type="Node2D"] +script = ExtResource("1_543qj") +could_be_used_for_target = true + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.5, 0.5) +texture = ExtResource("2_eh4u5") diff --git a/scene/_2d_fight/block_scene/wall.tscn b/scene/_2d_fight/block_scene/wall.tscn new file mode 100644 index 0000000..fe688a2 --- /dev/null +++ b/scene/_2d_fight/block_scene/wall.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://c8ho6swdmdbi5"] + +[ext_resource type="Script" path="res://class/2dFightBlock/base_block.gd" id="1_vd8gg"] +[ext_resource type="Texture2D" uid="uid://wld1fbwto47r" path="res://res/ui/ui_033_2d_fight/icon_color_64x64/black.png" id="2_rhwnk"] + +[node name="Wall" type="Node2D"] +script = ExtResource("1_vd8gg") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_rhwnk") diff --git a/scene/new_scene/main.tscn b/scene/new_scene/main.tscn index f431ea0..f9046f8 100644 --- a/scene/new_scene/main.tscn +++ b/scene/new_scene/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=45 format=3 uid="uid://di6kh2u1u1p05"] +[gd_scene load_steps=46 format=3 uid="uid://di6kh2u1u1p05"] [ext_resource type="Script" path="res://class/tool/DrawerContainer.gd" id="1_8qmlu"] [ext_resource type="Texture2D" uid="uid://q2bnirkndyhu" path="res://res/ui/new_ui_001_main/设置@1x.png" id="1_gpofm"] @@ -10,6 +10,7 @@ [ext_resource type="Script" path="res://class/ButtonOffsetTrigerResource/NodeOffsetArrayResouce.gd" id="3_wycq3"] [ext_resource type="Texture2D" uid="uid://dox5f407o8k2h" path="res://res/ui/new_ui_001_main/遮罩@1x@1x.png" id="4_322ac"] [ext_resource type="Texture2D" uid="uid://bpxe3rop6ldrt" path="res://res/ui/new_ui_001_main/成就表@1x.png" id="4_u0q3a"] +[ext_resource type="Texture2D" uid="uid://cyvpsjsou3xuh" path="res://res/ui/new_ui_001_main/banner.png" id="4_wro2c"] [ext_resource type="Texture2D" uid="uid://dnjolo3ihf77u" path="res://res/ui/new_ui_001_main/角色@1x@1x.png" id="4_ynrl2"] [ext_resource type="Texture2D" uid="uid://dvlwj6mj6hy1v" path="res://res/ui/new_ui_001_main/日历@1x.png" id="5_jvaox"] [ext_resource type="Texture2D" uid="uid://dtu5u6mrbgmee" path="res://res/ui/new_ui_001_main/成就@1x@1x.png" id="8_8v04f"] @@ -89,10 +90,11 @@ layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_top = 4.0 -offset_bottom = 4.0 grow_horizontal = 2 grow_vertical = 2 +texture = ExtResource("4_wro2c") +expand_mode = 1 +stretch_mode = 6 [node name="TextureRect2" type="TextureRect" parent="."] layout_mode = 1