From f0a8bffb85ef5ba3d123883e060f0ff4ff12c6e2 Mon Sep 17 00:00:00 2001 From: chendian <-> Date: Tue, 19 Dec 2023 03:00:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8C=89=E9=94=AE/=E5=AD=90?= =?UTF-8?q?=E5=BC=B9=E5=AE=9E=E4=BD=93/AI=E7=BB=93=E6=9E=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/character/bullet01.tres | 22 ++++ config/character_move/fast.tres | 9 ++ config/character_stun/none.tres | 11 ++ .../hero01_long_air_attack01.tres | 1 - project.godot | 5 + .../character/bullet01_move.aseprite | Bin 0 -> 2610 bytes .../character/bullet01_move.aseprite.import | 25 ++++ .../animation/character/bullet01_move.png | Bin 0 -> 443 bytes .../character/bullet01_move.png.import | 34 +++++ resource/mesh_library/mesh_library.tres | 124 +++++++++--------- .../hero01_short_attack01.tres | 2 +- scene/ai/action/find_target.tscn | 6 - scene/ai/action/move_to_target.tscn | 6 - scene/character/bullet.tscn | 29 ++++ scene/character/character.tscn | 6 +- scene/character/monster.tscn | 21 ++- script/ai/action/action_find_target.gd | 1 + script/ai/action/action_print.gd | 8 ++ script/ai/action/action_wait.gd | 12 ++ .../action_move_to_target.gd | 1 + script/character/{monster => ai}/ai.gd | 0 script/character/ai/bullet_ai.gd | 5 + script/character/ai/monster_ai.gd | 5 + script/character/player/player_action.gd | 4 + script/character/skill.gd | 7 +- script/character/view.gd | 2 + script/manager/camera_manager.gd | 4 +- script/manager/character_manager.gd | 15 ++- script/manager/resource_manager.gd | 1 + script/ui/hud/headbar_page.gd | 4 +- 30 files changed, 267 insertions(+), 103 deletions(-) create mode 100644 config/character/bullet01.tres create mode 100644 config/character_move/fast.tres create mode 100644 config/character_stun/none.tres create mode 100644 resource/animation/character/bullet01_move.aseprite create mode 100644 resource/animation/character/bullet01_move.aseprite.import create mode 100644 resource/animation/character/bullet01_move.png create mode 100644 resource/animation/character/bullet01_move.png.import delete mode 100644 scene/ai/action/find_target.tscn delete mode 100644 scene/ai/action/move_to_target.tscn create mode 100644 scene/character/bullet.tscn create mode 100644 script/ai/action/action_print.gd create mode 100644 script/ai/action/action_wait.gd rename script/character/{monster => ai}/ai.gd (100%) create mode 100644 script/character/ai/bullet_ai.gd create mode 100644 script/character/ai/monster_ai.gd diff --git a/config/character/bullet01.tres b/config/character/bullet01.tres new file mode 100644 index 0000000..e80851d --- /dev/null +++ b/config/character/bullet01.tres @@ -0,0 +1,22 @@ +[gd_resource type="Resource" script_class="CharacterCfg" load_steps=7 format=3 uid="uid://efaynwj7143w"] + +[ext_resource type="Resource" uid="uid://dfyg6ye7n3wgj" path="res://config/character_move/fast.tres" id="1_b02yl"] +[ext_resource type="Resource" uid="uid://dpajmgrlaytah" path="res://config/character_mp/normal.tres" id="2_hrxfp"] +[ext_resource type="Script" path="res://script/config/character_cfg.gd" id="3_p63bn"] +[ext_resource type="Resource" uid="uid://h1curvk64vm3" path="res://config/character_shield/none.tres" id="4_qnn3b"] +[ext_resource type="SpriteFrames" uid="uid://i01jiylcqat" path="res://resource/animation/character/bullet01_move.aseprite" id="4_x87ux"] +[ext_resource type="Resource" uid="uid://5jes0p152akr" path="res://config/character_stun/none.tres" id="6_y4hsh"] + +[resource] +script = ExtResource("3_p63bn") +name = "hero01" +type = 2 +sprite_frames = ExtResource("4_x87ux") +sprite_harf_height = 8 +sprite_width = 16 +move = ExtResource("1_b02yl") +shield = ExtResource("4_qnn3b") +stun = ExtResource("6_y4hsh") +mp = ExtResource("2_hrxfp") +hp_max = 100.0 +attack = 10.0 diff --git a/config/character_move/fast.tres b/config/character_move/fast.tres new file mode 100644 index 0000000..06fc9b1 --- /dev/null +++ b/config/character_move/fast.tres @@ -0,0 +1,9 @@ +[gd_resource type="Resource" script_class="CharacterMoveCfg" load_steps=2 format=3 uid="uid://dfyg6ye7n3wgj"] + +[ext_resource type="Script" path="res://script/config/character_move_cfg.gd" id="1_vw5kv"] + +[resource] +script = ExtResource("1_vw5kv") +speed = 5.0 +gravity_scale = 1.0 +jump_velocity = 6.0 diff --git a/config/character_stun/none.tres b/config/character_stun/none.tres new file mode 100644 index 0000000..b3e784d --- /dev/null +++ b/config/character_stun/none.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="StunCfg" load_steps=2 format=3 uid="uid://5jes0p152akr"] + +[ext_resource type="Script" path="res://script/config/stun_cfg.gd" id="1_8rl8l"] + +[resource] +script = ExtResource("1_8rl8l") +stun_max = 100.0 +recover_speed = 10.0 +recover_cd = 2.0 +recover_break_speed = 20.0 +recover_break_cd = 2.0 diff --git a/config/player_skill/hero01_long_air_attack01.tres b/config/player_skill/hero01_long_air_attack01.tres index ddfbdda..4426645 100644 --- a/config/player_skill/hero01_long_air_attack01.tres +++ b/config/player_skill/hero01_long_air_attack01.tres @@ -16,7 +16,6 @@ action = "attack_light" name = "" skill_animation = ExtResource("3_3pp8a") attack_list = Array[Resource("res://script/config/attack_cfg.gd")]([ExtResource("1_mxlqc")]) -attack_particle_list = Array[PackedScene]([]) free_lock = false refresh_animation = false sprite_frames = ExtResource("4_q0bln") diff --git a/project.godot b/project.godot index 4acc651..b7909ab 100644 --- a/project.godot +++ b/project.godot @@ -158,6 +158,11 @@ weapon_next={ "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":69,"key_label":0,"unicode":101,"echo":false,"script":null) ] } +test_1={ +"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":49,"key_label":0,"unicode":49,"echo":false,"script":null) +] +} [memory] diff --git a/resource/animation/character/bullet01_move.aseprite b/resource/animation/character/bullet01_move.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..2e56a446982d39b094e9864f0a008e70c8658f2c GIT binary patch literal 2610 zcmXrwVqkc%l#4+D2ss!S85kH+fEWodGJ*sdSb&fgU=h&RUmv-^wgR2PAO^(j3ScXd ztm9$^xd0@}$jGdutnTdLmzYt|+&yjC+U@5r-TeObM^bcXQ(4xWp4zqZx({rebN0}h zN4Jju|M)P(SS#1jq9fRKcAWRdf{@F-nP1n}eLAy(Pfdft%7@t}o{#!)`BuRB4~_5s zb6dISI9eI`Tbd`@+Ln5_cSfeHZCG)7mAfcUv#j)1JBxdX(Vyz-|IS?efA_`zx87Om zn!9`W#>b?W6*acBPG7s}=&oZ|UcUcrZDfoS)AOX;-r=0V^Epu(_a<6VRH7V)uqo*wEuswAw)!^P{nM5 zi^uB3h<(+G=V#e! zeH66gTlL}3p58?@(PcA>+P8E~xwvAZ)8~s`@@&Baa|7T(Ue^>MZ^MHf`D?D#7GBCl}Ucb#6C`W|Hi-k%B%quzA5epW0@MNj z$>qrdO<_?0=5RRp4`i`3_#{@Q7AY7u06DA*3=GUb_#f_BDF!KqiaBd9Ir1G);BW~n zi|cJ;c~?K%PdYjDh0d&hOY;{uo$#0_vQln^!5rx(RfA%d%d&Tv4~p$lSfqHv$9&5@ zAMP_-4mxwP?e$`u`){g#xw5|Me&@O=K8-$oKC^Q;ZfbeXu3*|^9+*1;X#cN|jNlRq XR01^s@u+)7!)G-8jOMSASpEP2xDRIP literal 0 HcmV?d00001 diff --git a/resource/animation/character/bullet01_move.aseprite.import b/resource/animation/character/bullet01_move.aseprite.import new file mode 100644 index 0000000..39431ba --- /dev/null +++ b/resource/animation/character/bullet01_move.aseprite.import @@ -0,0 +1,25 @@ +[remap] + +importer="Aseprite SpriteFrames Import" +type="SpriteFrames" +uid="uid://i01jiylcqat" +path="res://.godot/imported/bullet01_move.aseprite-8423d8194ac2a1deb36e21fbe45fc8a3.res" + +[deps] + +source_file="res://resource/animation/character/bullet01_move.aseprite" +dest_files=["res://.godot/imported/bullet01_move.aseprite-8423d8194ac2a1deb36e21fbe45fc8a3.res"] + +[params] + +spritesheet/layout=0 +spritesheet/fixed_rows_count=1 +spritesheet/fixed_columns_count=1 +spritesheet/border_type=0 +spritesheet/trim=false +spritesheet/ignore_empty=false +spritesheet/merge_duplicates=false +animation/default/name="default" +animation/default/direction=0 +animation/default/repeat_count=0 +animation/autoplay="" diff --git a/resource/animation/character/bullet01_move.png b/resource/animation/character/bullet01_move.png new file mode 100644 index 0000000000000000000000000000000000000000..1c2e07382a9a8f624c9e545aa7c04501fad5dc44 GIT binary patch literal 443 zcmV;s0Yv_ZP)Px$bxA})R7i>4);n&(KoADtfBZm(NJL0Zg-nzKaDx;nB65fL9;u<_9&iXmL6K_^ z1jrHvjfJo+VdONdu`%me0;0&@c^~?A3TuXlbf~6dSCj1bXdRO3UE>nq)q2ct*ho}C z7V6m5L;&vlTYhsqNkI-Pg#;pim(Q={WYwe)fUB`GBnMrCaYz9w!;HyTh0!FU1}#|9_*Pn!7>09Zr{ox^})E1wPf0Kg)p&?yFFW`siqhjk7C08*LjWaHL% l int: var player_id = Global.character_mgr.get_player_id() diff --git a/script/ai/action/action_print.gd b/script/ai/action/action_print.gd new file mode 100644 index 0000000..bef4fd2 --- /dev/null +++ b/script/ai/action/action_print.gd @@ -0,0 +1,8 @@ +extends Action +class_name ActionPrint + +@export var context : String + +func run(character: Character) -> int: + print(context) + return SUCCESS diff --git a/script/ai/action/action_wait.gd b/script/ai/action/action_wait.gd new file mode 100644 index 0000000..47fd60a --- /dev/null +++ b/script/ai/action/action_wait.gd @@ -0,0 +1,12 @@ +extends Action +class_name ActionWait + +@export var wait_time : float +var wait_time_left : float + +func run(character: Character) -> int: + wait_time_left += get_physics_process_delta_time() + if wait_time_left >= wait_time: + wait_time_left = 0 + return SUCCESS + return RUNNING diff --git a/script/ai/action_with_target/action_move_to_target.gd b/script/ai/action_with_target/action_move_to_target.gd index 3cfc556..2893a78 100644 --- a/script/ai/action_with_target/action_move_to_target.gd +++ b/script/ai/action_with_target/action_move_to_target.gd @@ -1,4 +1,5 @@ extends ActionWithTarget +class_name ActionMoveToTarget func execute(character: Character, target: Character) -> int: var dir = target.pos2D() - character.pos2D() diff --git a/script/character/monster/ai.gd b/script/character/ai/ai.gd similarity index 100% rename from script/character/monster/ai.gd rename to script/character/ai/ai.gd diff --git a/script/character/ai/bullet_ai.gd b/script/character/ai/bullet_ai.gd new file mode 100644 index 0000000..9626b93 --- /dev/null +++ b/script/character/ai/bullet_ai.gd @@ -0,0 +1,5 @@ +extends AI +class_name BulletAI + +func _ready(): + pass diff --git a/script/character/ai/monster_ai.gd b/script/character/ai/monster_ai.gd new file mode 100644 index 0000000..2474452 --- /dev/null +++ b/script/character/ai/monster_ai.gd @@ -0,0 +1,5 @@ +extends AI +class_name MonsterAI + +func _ready(): + pass diff --git a/script/character/player/player_action.gd b/script/character/player/player_action.gd index 750f589..7239795 100644 --- a/script/character/player/player_action.gd +++ b/script/character/player/player_action.gd @@ -1,6 +1,8 @@ extends Node3D class_name PlayerAction +@onready var test_bullet = load("res://config/character/bullet01.tres") + @onready var character = (get_owner() as Character) @onready var status = (%Status as Status) @onready var combo = (%Combo as Combo) @@ -17,6 +19,8 @@ func check_action_pressed(key:String) -> bool: match key: "weapon_pre":combo.weapon_index_change(-1) "weapon_next":combo.weapon_index_change(1) + "test_1": + Global.character_mgr.create_character(test_bullet,character.team(),character.pos()) _:return false return true diff --git a/script/character/skill.gd b/script/character/skill.gd index 88b801f..36f0e3d 100644 --- a/script/character/skill.gd +++ b/script/character/skill.gd @@ -15,7 +15,7 @@ func _process(delta): else:play(); func cast_skill(cfg:SkillCfg,cast_dir:Vector2): - cancel_skill() + break_skill() if cast_dir.length() == 0: cast_dir = Vector2.RIGHT if status.is_right else Vector2.LEFT if !cfg.free_lock and status.target: @@ -41,7 +41,7 @@ func cast_skill(cfg:SkillCfg,cast_dir:Vector2): else: print("技能animation不存在",animation_name) -func cancel_skill(): +func break_skill(): stop() status.speed_up_rate = 0 status.skill_move_speed = 0 @@ -54,6 +54,9 @@ func cancel_skill(): status.skill_attack_index = 0 status.skill_attack_effect_index = 0 effect.release_effect() + +func cancel_skill(): + break_skill() view.reset() func on_attack_miss(): diff --git a/script/character/view.gd b/script/character/view.gd index 7a02949..f310997 100644 --- a/script/character/view.gd +++ b/script/character/view.gd @@ -171,6 +171,8 @@ func clone(target:AnimatedSprite3D): target.scale.x = scale.x func play_animation(animation_name:String): + if not sprite_frames.has_animation(animation_name): + return if animation_name == animation: frame = 0 frame_progress = 0 diff --git a/script/manager/camera_manager.gd b/script/manager/camera_manager.gd index 440fe23..d28da07 100644 --- a/script/manager/camera_manager.gd +++ b/script/manager/camera_manager.gd @@ -43,8 +43,8 @@ func target_pos_lerp(index:int,delta:float,delta_scale:float): var weight = max(delta * delta_scale,weight_min) target_pos_now[index] = lerp(target_pos_now[index], target_pos[index], weight) -func on_character_create(id:int,team:Enum.ETeam,pos:Vector3): - if team == Enum.ETeam.Player: +func on_character_create(id:int,is_player:bool,pos:Vector3): + if is_player: target = id on_character_pos_changed(id,pos) on_character_hit_floor(id,pos) diff --git a/script/manager/character_manager.gd b/script/manager/character_manager.gd index 18011d1..81b124b 100644 --- a/script/manager/character_manager.gd +++ b/script/manager/character_manager.gd @@ -22,13 +22,12 @@ func on_level_loading_end(): var player = get_player() if player:player.remove_buff("freeze") -func create_character(cfg:CharacterCfg,team:Enum.ETeam,pos:Vector3): +func create_character(cfg:CharacterCfg,team:Enum.ETeam,pos:Vector3)->Character: var characterNode:Node match cfg.type: - Enum.ECharacterType.Player: - characterNode = ResourceManager.scene_player.instantiate() - Enum.ECharacterType.Monster: - characterNode = ResourceManager.scene_monster.instantiate() + Enum.ECharacterType.Player:characterNode = ResourceManager.scene_player.instantiate() + Enum.ECharacterType.Monster:characterNode = ResourceManager.scene_monster.instantiate() + Enum.ECharacterType.Bullet:characterNode = ResourceManager.scene_bullet.instantiate() add_child(characterNode) characterNode.name = cfg.name var character = characterNode as Character @@ -37,9 +36,11 @@ func create_character(cfg:CharacterCfg,team:Enum.ETeam,pos:Vector3): character.init(character_idx,cfg,team) character.set_material(ResourceManager.material_character.duplicate(),ResourceManager.material_character_sub.duplicate()) character.set_pos(pos) - SignalManager.character_create.emit(character_idx,team,character.ui_pos()) - if cfg.type == Enum.ECharacterType.Player:player_id = character_idx + var is_player = cfg.type == Enum.ECharacterType.Player + SignalManager.character_create.emit(character_idx,is_player,character.ui_pos()) + if is_player:player_id = character_idx character.init_after() + return character func destroy_character(id:int): if not id in character_map: diff --git a/script/manager/resource_manager.gd b/script/manager/resource_manager.gd index c2005e7..2f355c5 100644 --- a/script/manager/resource_manager.gd +++ b/script/manager/resource_manager.gd @@ -3,6 +3,7 @@ extends Node3D #==scene== var scene_player = load("res://scene/character/player.tscn") var scene_monster = load("res://scene/character/monster.tscn") +var scene_bullet = load("res://scene/character/bullet.tscn") #==material== var material_character = load("res://render/material/character.tres") diff --git a/script/ui/hud/headbar_page.gd b/script/ui/hud/headbar_page.gd index e04135d..e7f865c 100644 --- a/script/ui/hud/headbar_page.gd +++ b/script/ui/hud/headbar_page.gd @@ -24,8 +24,8 @@ func _process(delta): var headbar_meta = headbar_map[k] as HeadbarMeta headbar_meta.headbar.position = camera.get_screen_pos(headbar_meta.pos) -func on_character_create(id:int,team:Enum.ETeam,pos:Vector3): - if team == Enum.ETeam.Player: +func on_character_create(id:int,is_player:bool,pos:Vector3): + if not is_player: return var new_headbar_meta = HeadbarMeta.new() new_headbar_meta.pos = pos