diff --git a/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet2.mp3 b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet2.mp3 new file mode 100644 index 0000000..09faa04 --- /dev/null +++ b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet2.mp3 Binary files differ diff --git a/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet2.mp3.import b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet2.mp3.import new file mode 100644 index 0000000..bad57ba --- /dev/null +++ b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet2.mp3.import @@ -0,0 +1,15 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +path="res://.import/ordinaryBullet2.mp3-363566e6f98fe28405c9762713f94f39.mp3str" + +[deps] + +source_file="res://resource/sound/sfx/ordinaryBullet2.mp3" +dest_files=[ "res://.import/ordinaryBullet2.mp3-363566e6f98fe28405c9762713f94f39.mp3str" ] + +[params] + +loop=false +loop_offset=0 diff --git a/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet3.mp3 b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet3.mp3 new file mode 100644 index 0000000..06b18e6 --- /dev/null +++ b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet3.mp3 Binary files differ diff --git a/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet3.mp3.import b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet3.mp3.import new file mode 100644 index 0000000..8ff20f6 --- /dev/null +++ b/DungeonShooting_Godot/resource/sound/sfx/ordinaryBullet3.mp3.import @@ -0,0 +1,15 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +path="res://.import/ordinaryBullet3.mp3-071f70567ddf76a565a2dbe75703e424.mp3str" + +[deps] + +source_file="res://resource/sound/sfx/ordinaryBullet3.mp3" +dest_files=[ "res://.import/ordinaryBullet3.mp3-071f70567ddf76a565a2dbe75703e424.mp3str" ] + +[params] + +loop=false +loop_offset=0 diff --git a/DungeonShooting_Godot/resource/sound/sfx/reloading.mp3 b/DungeonShooting_Godot/resource/sound/sfx/reloading.mp3 new file mode 100644 index 0000000..586e772 --- /dev/null +++ b/DungeonShooting_Godot/resource/sound/sfx/reloading.mp3 Binary files differ diff --git a/DungeonShooting_Godot/resource/sound/sfx/reloading.mp3.import b/DungeonShooting_Godot/resource/sound/sfx/reloading.mp3.import new file mode 100644 index 0000000..d9f86f9 --- /dev/null +++ b/DungeonShooting_Godot/resource/sound/sfx/reloading.mp3.import @@ -0,0 +1,15 @@ +[remap] + +importer="mp3" +type="AudioStreamMP3" +path="res://.import/reloading.mp3-a718918dc3dc57c0c17a3c31a9e33c3f.mp3str" + +[deps] + +source_file="res://resource/sound/sfx/reloading.mp3" +dest_files=[ "res://.import/reloading.mp3-a718918dc3dc57c0c17a3c31a9e33c3f.mp3str" ] + +[params] + +loop=false +loop_offset=0.0 diff --git a/DungeonShooting_Godot/scene/Room.tscn b/DungeonShooting_Godot/scene/Room.tscn index 284fa8c..67cf647 100644 --- a/DungeonShooting_Godot/scene/Room.tscn +++ b/DungeonShooting_Godot/scene/Room.tscn @@ -1,14 +1,9 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://resource/map/dungeon_test.tmx" type="PackedScene" id=2] [ext_resource path="res://src/game/room/RoomManager.cs" type="Script" id=3] [ext_resource path="res://src/game/camera/GameCamera.cs" type="Script" id=5] -[sub_resource type="NavigationPolygon" id=2] -vertices = PoolVector2Array( 531, 412, 588, 411, 587, 588, 342, 588, 525, 412, 343, 520, 344, 508, 393, 265, 587, 263, 586, 345, 531, 345, 343, 201, 341, 67, 588, 68, 376, 201, 283, 508, 284, 520, 284, 588, 53, 589, 53, 411, 108, 412, 115, 413, 55, 71, 283, 69, 282, 200, 249, 200, 56, 199, 232, 200, 109, 348, 53, 347, 55, 264, 232, 265, 114, 348, 249, 265, 524, 345, 376, 265, 587, 201, 393, 201, 345, 412, 280, 412 ) -polygons = [ PoolIntArray( 0, 1, 2, 3 ), PoolIntArray( 4, 0, 3, 5, 6 ), PoolIntArray( 7, 8, 9, 10 ), PoolIntArray( 11, 12, 13, 14 ), PoolIntArray( 15, 16, 17, 18, 19, 20, 21 ), PoolIntArray( 22, 23, 24, 25, 26 ), PoolIntArray( 27, 26, 25 ), PoolIntArray( 28, 29, 30, 31, 32 ), PoolIntArray( 27, 25, 33, 31 ), PoolIntArray( 10, 0, 4, 34 ), PoolIntArray( 7, 10, 34 ), PoolIntArray( 7, 34, 32, 35 ), PoolIntArray( 13, 36, 37 ), PoolIntArray( 14, 13, 37 ), PoolIntArray( 35, 14, 37, 7 ), PoolIntArray( 33, 35, 32 ), PoolIntArray( 31, 33, 32 ), PoolIntArray( 6, 38, 4 ), PoolIntArray( 15, 6, 5, 16 ), PoolIntArray( 28, 32, 21, 20 ), PoolIntArray( 15, 21, 39 ) ] -outlines = [ PoolVector2Array( 55, 71, 56, 199, 232, 200, 232, 265, 55, 264, 53, 347, 109, 348, 108, 412, 53, 411, 53, 589, 284, 588, 284, 520, 343, 520, 342, 588, 587, 588, 588, 411, 531, 412, 531, 345, 586, 345, 587, 263, 393, 265, 393, 201, 587, 201, 588, 68, 341, 67, 343, 201, 376, 201, 376, 265, 249, 265, 249, 200, 282, 200, 283, 69 ), PoolVector2Array( 114, 348, 115, 413, 280, 412, 283, 508, 344, 508, 345, 412, 525, 412, 524, 345 ) ] - [sub_resource type="Environment" id=1] background_mode = 4 glow_enabled = true @@ -16,11 +11,6 @@ [node name="Room" type="Navigation2D"] script = ExtResource( 3 ) -[node name="NavigationPolygonInstance" type="NavigationPolygonInstance" parent="."] -visible = false -navpoly = SubResource( 2 ) -enabled = false - [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource( 1 ) diff --git a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs index 7a394ca..e7834ec 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs @@ -108,7 +108,7 @@ GameCamera.Main.ProcessDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 1.5f); } //播放射击音效 - SoundManager.PlaySoundEffectPosition(ResourcePath.resource_sound_sfx_ordinaryBullet_ogg, GameApplication.Instance.ViewToGlobalPosition(GlobalPosition), 6f); + SoundManager.PlaySoundEffectPosition(ResourcePath.resource_sound_sfx_ordinaryBullet2_mp3, GameApplication.Instance.ViewToGlobalPosition(GlobalPosition), -8); } protected override void OnShoot(float fireRotation) diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 51d66af..2bd3d81 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -30,13 +30,16 @@ public const string resource_effects_KnifeHit1_tres = "res://resource/effects/KnifeHit1.tres"; public const string resource_font_cn_font_12_tres = "res://resource/font/cn_font_12.tres"; public const string resource_font_cn_font_18_tres = "res://resource/font/cn_font_18.tres"; - public const string resource_font_cn_font_35_tres = "res://resource/font/cn_font_35.tres"; + public const string resource_font_cn_font_36_tres = "res://resource/font/cn_font_36.tres"; public const string resource_map_dungeon_test_tmx = "res://resource/map/dungeon_test.tmx"; public const string resource_map_itchioDungeonTileset4_tsx = "res://resource/map/itch-io-DungeonTileset4.tsx"; public const string resource_materlal_Blend_gdshader = "res://resource/materlal/Blend.gdshader"; public const string resource_materlal_Blend_tres = "res://resource/materlal/Blend.tres"; public const string resource_sound_bgm_Intro_ogg = "res://resource/sound/bgm/Intro.ogg"; public const string resource_sound_sfx_ordinaryBullet_ogg = "res://resource/sound/sfx/ordinaryBullet.ogg"; + public const string resource_sound_sfx_ordinaryBullet2_mp3 = "res://resource/sound/sfx/ordinaryBullet2.mp3"; + public const string resource_sound_sfx_ordinaryBullet3_mp3 = "res://resource/sound/sfx/ordinaryBullet3.mp3"; + public const string resource_sound_sfx_reloading_mp3 = "res://resource/sound/sfx/reloading.mp3"; public const string resource_sprite_bullet_arrow_png = "res://resource/sprite/bullet/arrow.png"; public const string resource_sprite_bullet_bullet_png = "res://resource/sprite/bullet/bullet.png"; public const string resource_sprite_bullet_bullet2_png = "res://resource/sprite/bullet/bullet2.png"; @@ -114,6 +117,8 @@ public const string scene_Room_tscn = "res://scene/Room.tscn"; public const string scene_test_TestCommpont_tscn = "res://scene/test/TestCommpont.tscn"; public const string scene_test_TestNavigation_tscn = "res://scene/test/TestNavigation.tscn"; + public const string scene_test_TestNavigation2_tscn = "res://scene/test/TestNavigation2.tscn"; + public const string scene_test_TestNavigationPolygon_tscn = "res://scene/test/TestNavigationPolygon.tscn"; public const string default_bus_layout_tres = "res://default_bus_layout.tres"; public const string default_env_tres = "res://default_env.tres"; public const string icon_png = "res://icon.png"; diff --git a/DungeonShooting_Godot/src/game/role/PathSign.cs b/DungeonShooting_Godot/src/game/role/PathSign.cs index a3487ed..cf8f654 100644 --- a/DungeonShooting_Godot/src/game/role/PathSign.cs +++ b/DungeonShooting_Godot/src/game/role/PathSign.cs @@ -221,3 +221,66 @@ } } } + +#region 备份代码 +/* +第一个绑定在Role身上的点, 需要每一帧更新 +if (Master.PathSign.Enable) +{ + var targetSign = master.PathSign; + var enemyPos = master.GlobalPosition; + if (targetSign.Next == null) + { + var targetPosition = targetSign.TargetPosition; + + if (enemyPos.DistanceSquaredTo(targetPosition) <= + master.Velocity.LengthSquared() * delta) //移动到下一个节点了, 还是没有找到目标, 变为第二状态 + { + StateController.ChangeStateLate(AIStateEnum.AINormal); + } + else //继续移动 + { + master.LookTargetPosition(targetPosition); + master.AnimatedSprite.Animation = AnimatorNames.Run; + master.Velocity = (targetPosition - enemyPos).Normalized() * master.MoveSpeed; + master.CalcMove(delta); + } + } + else + { + var nextPos = targetSign.Next.GlobalPosition; + + if (enemyPos.DistanceSquaredTo(nextPos) <= + master.Velocity.LengthSquared() * delta) //已经移动到下一个节点了, 删除下一个节点, 后面的接上 + { + var nextNext = targetSign.Next.Next; + var tempPos = targetSign.Next.TargetPosition; + targetSign.Next.Next = null; + targetSign.Next.Destroy(); + targetSign.Next = nextNext; + + if (nextNext != null) //下一个点继续移动 + { + nextPos = nextNext.GlobalPosition; + master.LookTargetPosition(nextPos); + master.AnimatedSprite.Animation = AnimatorNames.Run; + master.Velocity = (nextPos - enemyPos).Normalized() * master.MoveSpeed; + master.CalcMove(delta); + } + else + { + targetSign.TargetPosition = tempPos; + } + } + else //继续移动 + { + master.LookTargetPosition(nextPos); + master.AnimatedSprite.Animation = AnimatorNames.Run; + master.Velocity = (nextPos - enemyPos).Normalized() * master.MoveSpeed; + master.CalcMove(delta); + } + } +} + +*/ +#endregion diff --git a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs index 538935d..bd6bf06 100644 --- a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs @@ -41,15 +41,15 @@ //------------------- 寻路相关 --------------------------- - /// - /// 移动目标标记 - /// - public PathSign PathSign { get; } - - /// - /// 寻路标记线段总长度 - /// - public float PathSignLength { get; set; } = 500; + // /// + // /// 移动目标标记 + // /// + // public PathSign PathSign { get; } + // + // /// + // /// 寻路标记线段总长度 + // /// + // public float PathSignLength { get; set; } = 500; //------------------------------------------------------- @@ -75,7 +75,7 @@ _navigationPoint = GetNode("NavigationPoint"); _navigationAgent2D = _navigationPoint.GetNode("NavigationAgent2D"); - PathSign = new PathSign(this, PathSignLength, GameApplication.Instance.Room.Player); + //PathSign = new PathSign(this, PathSignLength, GameApplication.Instance.Room.Player); //注册Ai状态机 StateController.Register(new AINormalState()); @@ -97,7 +97,7 @@ base._Process(delta); if (GameApplication.Instance.Debug) { - PathSign.Scale = new Vector2((int)Face, 1); + // PathSign.Scale = new Vector2((int)Face, 1); Update(); } } @@ -136,10 +136,10 @@ { if (GameApplication.Instance.Debug) { - if (PathSign != null) - { - DrawLine(Vector2.Zero,ToLocal(PathSign.GlobalPosition), Colors.Red); - } + // if (PathSign != null) + // { + // DrawLine(Vector2.Zero,ToLocal(PathSign.GlobalPosition), Colors.Red); + // } } } } diff --git a/DungeonShooting_Godot/src/game/role/enemy/state/AITailAfterState.cs b/DungeonShooting_Godot/src/game/role/enemy/state/AITailAfterState.cs index 0cfa70c..deeb1ad 100644 --- a/DungeonShooting_Godot/src/game/role/enemy/state/AITailAfterState.cs +++ b/DungeonShooting_Godot/src/game/role/enemy/state/AITailAfterState.cs @@ -16,62 +16,7 @@ public void PhysicsProcess(float delta) { var master = Master; - if (Master.PathSign.Enable) - { - var targetSign = master.PathSign; - var enemyPos = master.GlobalPosition; - if (targetSign.Next == null) - { - var targetPosition = targetSign.TargetPosition; - - if (enemyPos.DistanceSquaredTo(targetPosition) <= - master.Velocity.LengthSquared() * delta) //移动到下一个节点了, 还是没有找到目标, 变为第二状态 - { - StateController.ChangeStateLate(AIStateEnum.AINormal); - } - else //继续移动 - { - master.LookTargetPosition(targetPosition); - master.AnimatedSprite.Animation = AnimatorNames.Run; - master.Velocity = (targetPosition - enemyPos).Normalized() * master.MoveSpeed; - master.CalcMove(delta); - } - } - else - { - var nextPos = targetSign.Next.GlobalPosition; - - if (enemyPos.DistanceSquaredTo(nextPos) <= - master.Velocity.LengthSquared() * delta) //已经移动到下一个节点了, 删除下一个节点, 后面的接上 - { - var nextNext = targetSign.Next.Next; - var tempPos = targetSign.Next.TargetPosition; - targetSign.Next.Next = null; - targetSign.Next.Destroy(); - targetSign.Next = nextNext; - - if (nextNext != null) //下一个点继续移动 - { - nextPos = nextNext.GlobalPosition; - master.LookTargetPosition(nextPos); - master.AnimatedSprite.Animation = AnimatorNames.Run; - master.Velocity = (nextPos - enemyPos).Normalized() * master.MoveSpeed; - master.CalcMove(delta); - } - else - { - targetSign.TargetPosition = tempPos; - } - } - else //继续移动 - { - master.LookTargetPosition(nextPos); - master.AnimatedSprite.Animation = AnimatorNames.Run; - master.Velocity = (nextPos - enemyPos).Normalized() * master.MoveSpeed; - master.CalcMove(delta); - } - } - } + } public bool CanChangeState(AIStateEnum next) diff --git a/DungeonShooting_Godot/src/game/room/RoomManager.cs b/DungeonShooting_Godot/src/game/room/RoomManager.cs index 06539e6..10ca35c 100644 --- a/DungeonShooting_Godot/src/game/room/RoomManager.cs +++ b/DungeonShooting_Godot/src/game/room/RoomManager.cs @@ -75,13 +75,13 @@ SoundManager.PlayMusic(ResourcePath.resource_sound_bgm_Intro_ogg, -17f); var enemy1 = new Enemy(); enemy1.Name = "Enemy"; - enemy1.PutDown(new Vector2(150, 150)); + enemy1.PutDown(new Vector2(150, 300)); enemy1.PickUpWeapon(WeaponManager.GetGun("1003")); enemy1.PickUpWeapon(WeaponManager.GetGun("1001")); var enemy2 = new Enemy(); enemy2.Name = "Enemy2"; - enemy2.PutDown(new Vector2(190, 150)); + enemy2.PutDown(new Vector2(540, 100)); enemy2.PickUpWeapon(WeaponManager.GetGun("1002")); enemy2.PickUpWeapon(WeaponManager.GetGun("1004")); enemy2.PickUpWeapon(WeaponManager.GetGun("1003"));