diff --git a/DungeonShooting_Godot/prefab/weapon/Weapon0002.tscn b/DungeonShooting_Godot/prefab/weapon/Weapon0002.tscn index c31221e..543177a 100644 --- a/DungeonShooting_Godot/prefab/weapon/Weapon0002.tscn +++ b/DungeonShooting_Godot/prefab/weapon/Weapon0002.tscn @@ -75,6 +75,7 @@ [node name="AnimatedSprite" type="AnimatedSprite2D" parent="."] material = SubResource("ShaderMaterial_o36tv") sprite_frames = ExtResource("3_4h3je") +animation = &"equip" [node name="ShellPoint" type="Marker2D" parent="AnimatedSprite"] position = Vector2(-3, -2) diff --git a/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002.png b/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002.png index 69e6b4d..68a0336 100644 --- a/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002.png +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002_reloading.png b/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002_reloading.png new file mode 100644 index 0000000..90b10e7 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002_reloading.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002_reloading.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002_reloading.png.import new file mode 100644 index 0000000..cf29671 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0002/Weapon0002_reloading.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cog4u2dr46anc" +path="res://.godot/imported/Weapon0002_reloading.png-92d56562c66b85ad28fe76e3f2ed0752.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0002/Weapon0002_reloading.png" +dest_files=["res://.godot/imported/Weapon0002_reloading.png-92d56562c66b85ad28fe76e3f2ed0752.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/DungeonShooting_Godot/resource/spriteFrames/Weapon0002.tres b/DungeonShooting_Godot/resource/spriteFrames/Weapon0002.tres index 9a55286..c3e68b2 100644 --- a/DungeonShooting_Godot/resource/spriteFrames/Weapon0002.tres +++ b/DungeonShooting_Godot/resource/spriteFrames/Weapon0002.tres @@ -1,6 +1,31 @@ -[gd_resource type="SpriteFrames" load_steps=2 format=3 uid="uid://domhmo4flmlt0"] +[gd_resource type="SpriteFrames" load_steps=9 format=3 uid="uid://domhmo4flmlt0"] [ext_resource type="Texture2D" uid="uid://b53kofmyan42g" path="res://resource/sprite/weapon/weapon0002/Weapon0002.png" id="1_2tglc"] +[ext_resource type="Texture2D" uid="uid://cog4u2dr46anc" path="res://resource/sprite/weapon/weapon0002/Weapon0002_reloading.png" id="2_kr54x"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_b4jme"] +atlas = ExtResource("2_kr54x") +region = Rect2(0, 0, 36, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_hhpo6"] +atlas = ExtResource("2_kr54x") +region = Rect2(36, 0, 36, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vicgs"] +atlas = ExtResource("2_kr54x") +region = Rect2(72, 0, 36, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_addwe"] +atlas = ExtResource("2_kr54x") +region = Rect2(108, 0, 36, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_6nxvp"] +atlas = ExtResource("2_kr54x") +region = Rect2(144, 0, 36, 15) + +[sub_resource type="AtlasTexture" id="AtlasTexture_p0dy6"] +atlas = ExtResource("2_kr54x") +region = Rect2(180, 0, 36, 15) [resource] animations = [{ @@ -11,4 +36,27 @@ "loop": true, "name": &"default", "speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_b4jme") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_hhpo6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vicgs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_addwe") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_6nxvp") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_p0dy6") +}], +"loop": false, +"name": &"equip", +"speed": 10.0 }] diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index 2116d08..49d6b0c 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -851,7 +851,7 @@ MoveController.ScaleAllForce(BounceSpeed); //如果落地高度不够低, 再抛一次 - if (Bounce && (!_hasResilienceVerticalSpeed || _resilienceVerticalSpeed > 1)) + if (Bounce && (!_hasResilienceVerticalSpeed || _resilienceVerticalSpeed > 5)) { if (!_hasResilienceVerticalSpeed) { @@ -860,7 +860,14 @@ } else { - _resilienceVerticalSpeed = _resilienceVerticalSpeed * BounceStrength; + if (_resilienceVerticalSpeed < 25) + { + _resilienceVerticalSpeed = _resilienceVerticalSpeed * BounceStrength * 0.4f; + } + else + { + _resilienceVerticalSpeed = _resilienceVerticalSpeed * BounceStrength; + } } _verticalSpeed = _resilienceVerticalSpeed; ThrowRotationDegreesSpeed = ThrowRotationDegreesSpeed * BounceStrength; @@ -1335,4 +1342,60 @@ { ProxyCoroutineHandler.ProxyStopAllCoroutine(ref _coroutineList); } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void DelayCall(float delayTime, Action cb) + { + StartCoroutine(_DelayCall(delayTime, cb)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void DelayCall(float delayTime, Action cb, T1 arg1) + { + StartCoroutine(_DelayCall(delayTime, cb, arg1)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void DelayCall(float delayTime, Action cb, T1 arg1, T2 arg2) + { + StartCoroutine(_DelayCall(delayTime, cb, arg1, arg2)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public void DelayCall(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) + { + StartCoroutine(_DelayCall(delayTime, cb, arg1, arg2, arg3)); + } + + private IEnumerator _DelayCall(float delayTime, Action cb) + { + yield return new WaitForSeconds(delayTime); + cb(); + } + + private IEnumerator _DelayCall(float delayTime, Action cb, T1 arg1) + { + yield return new WaitForSeconds(delayTime); + cb(arg1); + } + + private IEnumerator _DelayCall(float delayTime, Action cb, T1 arg1, T2 arg2) + { + yield return new WaitForSeconds(delayTime); + cb(arg1, arg2); + } + + private IEnumerator _DelayCall(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) + { + yield return new WaitForSeconds(delayTime); + cb(arg1,arg2, arg3); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/AnimatorNames.cs b/DungeonShooting_Godot/src/game/AnimatorNames.cs index 42e0b18..b26f934 100644 --- a/DungeonShooting_Godot/src/game/AnimatorNames.cs +++ b/DungeonShooting_Godot/src/game/AnimatorNames.cs @@ -43,5 +43,9 @@ /// /// 换弹 /// - public const string Reload = "reload"; + public const string Reloading = "reloading"; + /// + /// 子弹上膛 + /// + public const string Equip = "equip"; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs index 87cd398..23caa70 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs @@ -243,6 +243,7 @@ public override void OnInit() { InitWeapon(_GetWeaponAttribute(ItemId)); + AnimatedSprite.AnimationFinished += OnAnimationFinished; } /// @@ -821,7 +822,20 @@ //触发开火函数 OnFire(); - + + //播放上膛动画 + if (IsAutoPlaySpriteFrames) + { + if (Attribute.EquipSoundDelayTime <= 0) + { + PlaySpriteAnimation(AnimatorNames.Equip); + } + else + { + DelayCall(Attribute.EquipSoundDelayTime, PlaySpriteAnimation, AnimatorNames.Equip); + } + } + //播放上膛音效 PlayEquipSound(); @@ -1083,7 +1097,7 @@ //播放换弹动画 if (IsAutoPlaySpriteFrames) { - PlaySpriteAnimation(AnimatorNames.Reload); + PlaySpriteAnimation(AnimatorNames.Reloading); } //播放换弹音效 @@ -1184,6 +1198,13 @@ } } + //帧动画播放结束 + private void OnAnimationFinished() + { + GD.Print("帧动画播放结束..."); + AnimatedSprite.Play(AnimatorNames.Default); + } + public override CheckInteractiveResult CheckInteractive(ActivityObject master) { var result = new CheckInteractiveResult(this);