diff --git a/DungeonShooting_Art/effect/Collision.png b/DungeonShooting_Art/effect/Collision.png index e408f5b..f15c822 100644 --- a/DungeonShooting_Art/effect/Collision.png +++ b/DungeonShooting_Art/effect/Collision.png Binary files differ diff --git a/DungeonShooting_Art/effect/ShotFire.png b/DungeonShooting_Art/effect/ShotFire.png index 7617b4d..5c6d63a 100644 --- a/DungeonShooting_Art/effect/ShotFire.png +++ b/DungeonShooting_Art/effect/ShotFire.png Binary files differ diff --git a/DungeonShooting_Godot/prefab/effect/ShotFire.tscn b/DungeonShooting_Godot/prefab/effect/ShotFire.tscn index c63d83b..4b39762 100644 --- a/DungeonShooting_Godot/prefab/effect/ShotFire.tscn +++ b/DungeonShooting_Godot/prefab/effect/ShotFire.tscn @@ -19,7 +19,7 @@ [sub_resource type="Animation" id=1] resource_name = "ShotFire" -length = 0.15 +length = 0.2 step = 0.05 tracks/0/type = "value" tracks/0/path = NodePath(".:frame") @@ -28,10 +28,10 @@ tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 0.05, 0.1 ), -"transitions": PoolRealArray( 1, 1, 1 ), +"times": PoolRealArray( 0, 0.05, 0.1, 0.15 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), "update": 1, -"values": [ 0, 1, 2 ] +"values": [ 0, 1, 2, 3 ] } tracks/1/type = "method" tracks/1/path = NodePath(".") @@ -40,7 +40,7 @@ tracks/1/imported = false tracks/1/enabled = true tracks/1/keys = { -"times": PoolRealArray( 0.15 ), +"times": PoolRealArray( 0.2 ), "transitions": PoolRealArray( 1 ), "values": [ { "args": [ ], @@ -52,7 +52,7 @@ modulate = Color( 1.6, 1.6, 1.6, 1 ) texture = ExtResource( 1 ) offset = Vector2( 8, 0 ) -hframes = 3 +hframes = 4 [node name="AnimationPlayer" type="AnimationPlayer" parent="."] autoplay = "ShotFire" diff --git a/DungeonShooting_Godot/resource/effects/Collision.png b/DungeonShooting_Godot/resource/effects/Collision.png index e408f5b..f15c822 100644 --- a/DungeonShooting_Godot/resource/effects/Collision.png +++ b/DungeonShooting_Godot/resource/effects/Collision.png Binary files differ diff --git a/DungeonShooting_Godot/resource/effects/ShotFire.png b/DungeonShooting_Godot/resource/effects/ShotFire.png index 7617b4d..5c6d63a 100644 --- a/DungeonShooting_Godot/resource/effects/ShotFire.png +++ b/DungeonShooting_Godot/resource/effects/ShotFire.png Binary files differ diff --git a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs index 8340f17..dd070fc 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs @@ -14,18 +14,19 @@ private float MaxDistance; // 子弹飞行速度 - private float FlySpeed = 350; + private float FlySpeed; //当前子弹已经飞行的距离 private float CurrFlyDistance = 0; - public Bullet(string scenePath, float maxDistance, Vector2 position, float rotation, uint targetLayer) : + public Bullet(string scenePath, float speed, float maxDistance, Vector2 position, float rotation, uint targetLayer) : base(scenePath) { CollisionArea = GetNode("CollisionArea"); CollisionArea.CollisionMask = targetLayer; CollisionArea.Connect("area_entered", this, nameof(OnArea2dEntered)); + FlySpeed = speed; MaxDistance = maxDistance; Position = position; Rotation = rotation; diff --git a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs index 2d1724f..4d9fa2a 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs @@ -41,8 +41,8 @@ MaxFireBulletCount = 1; //抬起角度 UpliftAngle = 10; - //枪身长度 - FirePosition = new Vector2(16, 1.5f); + //开火位置 + FirePosition = new Vector2(16, 2); } } @@ -81,8 +81,8 @@ MaxFireBulletCount = 1; //抬起角度 UpliftAngle = 30; - //枪身长度 - FirePosition = new Vector2(10, 1.5f); + //开火位置 + FirePosition = new Vector2(10, 2); } } @@ -105,9 +105,10 @@ if (Master == GameApplication.Instance.Room.Player) { //创建抖动 - GameCamera.Main.ProcessDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 2.5f); + GameCamera.Main.ProcessDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 2f); } + //创建开火特效 var packedScene = ResourceManager.Load(ResourcePath.prefab_effect_ShotFire_tscn); var sprite = packedScene.Instance(); sprite.GlobalPosition = FirePoint.GlobalPosition; @@ -124,6 +125,7 @@ //CreateBullet(BulletPack, FirePoint.GlobalPosition, fireRotation); var bullet = new Bullet( ResourcePath.prefab_weapon_bullet_Bullet_tscn, + 350, Utils.RandRange(Attribute.MinDistance, Attribute.MaxDistance), FirePoint.GlobalPosition, fireRotation, diff --git a/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs b/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs index 4763747..ca60708 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/gun/Shotgun.cs @@ -40,8 +40,8 @@ UpliftAngle = 15; MaxBacklash = 6; MinBacklash = 5; - //枪身长度 - FirePosition = new Vector2(16, 1.5f); + //开火位置 + FirePosition = new Vector2(18, 4); } } @@ -70,8 +70,16 @@ if (Master == GameApplication.Instance.Room.Player) { //创建抖动 - GameCamera.Main.ProcessDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 1.5f); + GameCamera.Main.ProcessDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 2f); } + + //创建开火特效 + var packedScene = ResourceManager.Load(ResourcePath.prefab_effect_ShotFire_tscn); + var sprite = packedScene.Instance(); + sprite.GlobalPosition = FirePoint.GlobalPosition; + sprite.GlobalRotation = FirePoint.GlobalRotation; + GameApplication.Instance.Room.GetRoot(true).AddChild(sprite); + //播放射击音效 SoundManager.PlaySoundEffectPosition(ResourcePath.resource_sound_sfx_ordinaryBullet_ogg, GameApplication.Instance.ViewToGlobalPosition(GlobalPosition), 6f); } @@ -82,9 +90,10 @@ { //创建子弹 //CreateBullet(BulletPack, FirePoint.GlobalPosition, fireRotation + MathUtils.RandRange(-20 / 180f * Mathf.Pi, 20 / 180f * Mathf.Pi)); - + var bullet = new Bullet( ResourcePath.prefab_weapon_bullet_Bullet_tscn, + Utils.RandRangeInt(280, 380), Utils.RandRange(Attribute.MinDistance, Attribute.MaxDistance), FirePoint.GlobalPosition, fireRotation + Utils.RandRange(-20 / 180f * Mathf.Pi, 20 / 180f * Mathf.Pi),