mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:15:45 +00:00
Weapon sounds
This commit is contained in:
parent
22a1ec5ba2
commit
3c531bbe04
14 changed files with 174 additions and 52 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_resource type="Resource" script_class="CreditsCollection" load_steps=22 format=3 uid="uid://cojsc1rtf41i1"]
|
[gd_resource type="Resource" script_class="CreditsCollection" load_steps=23 format=3 uid="uid://cojsc1rtf41i1"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://buq8eurx510ps" path="res://Scripts/Resources/CreditsCollection.cs" id="1_0bwsf"]
|
[ext_resource type="Script" uid="uid://buq8eurx510ps" path="res://Scripts/Resources/CreditsCollection.cs" id="1_0bwsf"]
|
||||||
[ext_resource type="Script" uid="uid://bc4f4ggvk3ktf" path="res://Scripts/Resources/CreditsEntry.cs" id="1_aaqha"]
|
[ext_resource type="Script" uid="uid://bc4f4ggvk3ktf" path="res://Scripts/Resources/CreditsEntry.cs" id="1_aaqha"]
|
||||||
|
|
@ -117,7 +117,13 @@ Name = "Poppy Works"
|
||||||
Contribution = "Silver Font"
|
Contribution = "Silver Font"
|
||||||
metadata/_custom_type_script = "uid://bc4f4ggvk3ktf"
|
metadata/_custom_type_script = "uid://bc4f4ggvk3ktf"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_2niq1"]
|
||||||
|
script = ExtResource("1_aaqha")
|
||||||
|
Name = "S_Dij"
|
||||||
|
Contribution = "SFX"
|
||||||
|
metadata/_custom_type_script = "uid://bc4f4ggvk3ktf"
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_0bwsf")
|
script = ExtResource("1_0bwsf")
|
||||||
Credits = Array[ExtResource("1_aaqha")]([SubResource("Resource_ep84i"), SubResource("Resource_ianh3"), SubResource("Resource_m7fsk"), SubResource("Resource_ans3w"), SubResource("Resource_1cmaw"), SubResource("Resource_vda0h"), SubResource("Resource_daaek"), SubResource("Resource_8vv0q"), SubResource("Resource_321dv"), SubResource("Resource_j7pkh"), SubResource("Resource_aaqha"), SubResource("Resource_gr2tg"), SubResource("Resource_b8hlh"), SubResource("Resource_gbaov"), SubResource("Resource_jkmrk"), SubResource("Resource_ivgyk"), SubResource("Resource_n6vk1"), SubResource("Resource_k4ucw")])
|
Credits = Array[ExtResource("1_aaqha")]([SubResource("Resource_ep84i"), SubResource("Resource_ianh3"), SubResource("Resource_m7fsk"), SubResource("Resource_ans3w"), SubResource("Resource_1cmaw"), SubResource("Resource_vda0h"), SubResource("Resource_daaek"), SubResource("Resource_8vv0q"), SubResource("Resource_321dv"), SubResource("Resource_j7pkh"), SubResource("Resource_aaqha"), SubResource("Resource_gr2tg"), SubResource("Resource_b8hlh"), SubResource("Resource_gbaov"), SubResource("Resource_jkmrk"), SubResource("Resource_ivgyk"), SubResource("Resource_n6vk1"), SubResource("Resource_k4ucw"), SubResource("Resource_2niq1")])
|
||||||
metadata/_custom_type_script = "uid://buq8eurx510ps"
|
metadata/_custom_type_script = "uid://buq8eurx510ps"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://b8apu0l5fm4k"]
|
[gd_resource type="Resource" script_class="WeaponResource" load_steps=5 format=3 uid="uid://b8apu0l5fm4k"]
|
||||||
|
|
||||||
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_85ef1"]
|
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_85ef1"]
|
||||||
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="2_m8dps"]
|
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="2_m8dps"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://cjg8r7bthkfsy" path="res://SFX/Laser_shoot 11.wav" id="2_r2tre"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://jsv3yjluv1au" path="res://SFX/Weapons/Reload_01.wav" id="2_sd6j2"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_m8dps")
|
script = ExtResource("2_m8dps")
|
||||||
|
|
@ -12,9 +14,11 @@ BulletCapacity = 4
|
||||||
ReloadTime = 0.6
|
ReloadTime = 0.6
|
||||||
AutoReload = true
|
AutoReload = true
|
||||||
InfiniteAmmo = true
|
InfiniteAmmo = true
|
||||||
|
ItemKey = &"ICICLE_GUN"
|
||||||
|
AmmoKey = null
|
||||||
BulletsPerShot = 1
|
BulletsPerShot = 1
|
||||||
SpreadAngle = 0.0
|
SpreadAngle = 0.0
|
||||||
RandomSpread = 0.0
|
RandomSpread = 0.0
|
||||||
ItemKey = &"ICICLE_GUN"
|
|
||||||
AmmoKey = null
|
|
||||||
_rotationOffset = 0.0
|
_rotationOffset = 0.0
|
||||||
|
ReloadSound = ExtResource("2_sd6j2")
|
||||||
|
ShootSound = ExtResource("2_r2tre")
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://yuc0v7gojgep"]
|
[gd_resource type="Resource" script_class="WeaponResource" load_steps=5 format=3 uid="uid://yuc0v7gojgep"]
|
||||||
|
|
||||||
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_lg8jo"]
|
[ext_resource type="Resource" uid="uid://eu6n6c5175y8" path="res://Resources/Bullets/simple_ice_bullet.tres" id="1_lg8jo"]
|
||||||
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="2_f4135"]
|
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="2_f4135"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://jsv3yjluv1au" path="res://SFX/Weapons/Reload_01.wav" id="2_j27q6"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://cjg8r7bthkfsy" path="res://SFX/Laser_shoot 11.wav" id="3_nbc7n"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_f4135")
|
script = ExtResource("2_f4135")
|
||||||
|
|
@ -12,9 +14,11 @@ BulletCapacity = 8
|
||||||
ReloadTime = 0.5
|
ReloadTime = 0.5
|
||||||
AutoReload = true
|
AutoReload = true
|
||||||
InfiniteAmmo = false
|
InfiniteAmmo = false
|
||||||
|
ItemKey = &"ICICLE_REPEATER"
|
||||||
|
AmmoKey = &"ICE_AMMO"
|
||||||
BulletsPerShot = 1
|
BulletsPerShot = 1
|
||||||
SpreadAngle = 0.0
|
SpreadAngle = 0.0
|
||||||
RandomSpread = 0.0
|
RandomSpread = 0.0
|
||||||
ItemKey = &"ICICLE_REPEATER"
|
|
||||||
AmmoKey = &"ICE_AMMO"
|
|
||||||
_rotationOffset = 0.0
|
_rotationOffset = 0.0
|
||||||
|
ReloadSound = ExtResource("2_j27q6")
|
||||||
|
ShootSound = ExtResource("3_nbc7n")
|
||||||
|
|
|
||||||
BIN
SFX/Weapons/Reload_01.wav
(Stored with Git LFS)
Normal file
BIN
SFX/Weapons/Reload_01.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
24
SFX/Weapons/Reload_01.wav.import
Normal file
24
SFX/Weapons/Reload_01.wav.import
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://jsv3yjluv1au"
|
||||||
|
path="res://.godot/imported/Reload_01.wav-c4c46f1f50e796d8c1436431b4e3634c.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://SFX/Weapons/Reload_01.wav"
|
||||||
|
dest_files=["res://.godot/imported/Reload_01.wav-c4c46f1f50e796d8c1436431b4e3634c.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://crry0rgk7a8sm"]
|
[gd_scene load_steps=3 format=3 uid="uid://crry0rgk7a8sm"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://2ji3nxqbq577" path="res://Scripts/Weapon.cs" id="1_f5iec"]
|
[ext_resource type="Script" uid="uid://2ji3nxqbq577" path="res://Scripts/Weapon.cs" id="1_f5iec"]
|
||||||
|
[ext_resource type="Script" uid="uid://dw7nwfbws3op4" path="res://Scripts/Weapons/WeaponSoundModule.cs" id="2_uwnyl"]
|
||||||
|
|
||||||
[node name="Weapon" type="Sprite2D" node_paths=PackedStringArray("Muzzle")]
|
[node name="Weapon" type="Sprite2D" node_paths=PackedStringArray("Muzzle")]
|
||||||
script = ExtResource("1_f5iec")
|
script = ExtResource("1_f5iec")
|
||||||
|
|
@ -10,3 +11,22 @@ Muzzle = NodePath("Muzzle")
|
||||||
|
|
||||||
[node name="ShootTimer" type="Timer" parent="."]
|
[node name="ShootTimer" type="Timer" parent="."]
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="SoundModule" type="Node2D" parent="." node_paths=PackedStringArray("Weapon", "ShootSound", "ReloadSound", "EmptySound")]
|
||||||
|
script = ExtResource("2_uwnyl")
|
||||||
|
Weapon = NodePath("..")
|
||||||
|
ShootSound = NodePath("ShootSound")
|
||||||
|
ReloadSound = NodePath("ReloadSound")
|
||||||
|
EmptySound = NodePath("EmptySound")
|
||||||
|
|
||||||
|
[node name="ShootSound" type="AudioStreamPlayer2D" parent="SoundModule"]
|
||||||
|
bus = &"Effects"
|
||||||
|
area_mask = 2
|
||||||
|
|
||||||
|
[node name="ReloadSound" type="AudioStreamPlayer2D" parent="SoundModule"]
|
||||||
|
|
||||||
|
[node name="EmptySound" type="AudioStreamPlayer2D" parent="SoundModule"]
|
||||||
|
|
||||||
|
[connection signal="Empty" from="." to="SoundModule" method="PlayEmptySound"]
|
||||||
|
[connection signal="Reloading" from="." to="SoundModule" method="PlayReloadSound"]
|
||||||
|
[connection signal="Shooting" from="." to="SoundModule" method="PlayShootSound"]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://b1qnfiuokpvsr"]
|
[gd_scene load_steps=4 format=3 uid="uid://b1qnfiuokpvsr"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cybpmpb0d8yva" path="res://Sprites/Projectile.png" id="1_2eu87"]
|
[ext_resource type="Texture2D" uid="uid://cybpmpb0d8yva" path="res://Sprites/Projectile.png" id="1_2eu87"]
|
||||||
[ext_resource type="Script" uid="uid://dsa4b75hdig8p" path="res://Scripts/Bullet.cs" id="1_jvxw3"]
|
[ext_resource type="Script" uid="uid://dsa4b75hdig8p" path="res://Scripts/Bullet.cs" id="1_jvxw3"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cjg8r7bthkfsy" path="res://SFX/Laser_shoot 11.wav" id="3_8bitv"]
|
|
||||||
[ext_resource type="Script" uid="uid://dwnqgkuj6bgay" path="res://Scripts/Misc/LimitedAudioPlayer.cs" id="4_jxgah"]
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_jxptd"]
|
||||||
radius = 2.23607
|
radius = 2.23607
|
||||||
|
|
@ -26,14 +24,6 @@ editor_description = "Player Bullet"
|
||||||
|
|
||||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||||
|
|
||||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
|
||||||
stream = ExtResource("3_8bitv")
|
|
||||||
autoplay = true
|
|
||||||
bus = &"Effects"
|
|
||||||
area_mask = 8
|
|
||||||
script = ExtResource("4_jxgah")
|
|
||||||
AudioName = &"ICE_BULLET"
|
|
||||||
|
|
||||||
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -95,8 +95,7 @@ public partial class PlayerWeaponProvider : Node2D
|
||||||
public void Shoot(Vector2 direction)
|
public void Shoot(Vector2 direction)
|
||||||
{
|
{
|
||||||
if (EquippedWeapon == null) return;
|
if (EquippedWeapon == null) return;
|
||||||
|
|
||||||
|
|
||||||
EquippedWeapon.ShootDirection = direction;
|
EquippedWeapon.ShootDirection = direction;
|
||||||
EquippedWeapon.Shoot();
|
EquippedWeapon.Shoot();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -170,8 +170,6 @@ public partial class Active : PlayerStateBase
|
||||||
//CallDeferred(MethodName.PauseDeferred);
|
//CallDeferred(MethodName.PauseDeferred);
|
||||||
PauseDeferred();
|
PauseDeferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PauseDeferred()
|
private void PauseDeferred()
|
||||||
|
|
|
||||||
|
|
@ -29,16 +29,15 @@ public partial class WeaponResource : Resource
|
||||||
|
|
||||||
[Export] public bool InfiniteAmmo = true;
|
[Export] public bool InfiniteAmmo = true;
|
||||||
|
|
||||||
|
|
||||||
|
[Export] public StringName ItemKey;
|
||||||
|
[Export] public StringName AmmoKey;
|
||||||
|
#region Bullet spawn data
|
||||||
|
[ExportCategory("Bullet Spawn Data")]
|
||||||
[Export] public int BulletsPerShot = 1;
|
[Export] public int BulletsPerShot = 1;
|
||||||
|
|
||||||
[Export] public float SpreadAngle = 0f;
|
[Export] public float SpreadAngle = 0f;
|
||||||
[Export] public float RandomSpread = 0f;
|
[Export] public float RandomSpread = 0f;
|
||||||
|
|
||||||
[Export] public StringName ItemKey;
|
|
||||||
|
|
||||||
#region Bullet spawn data
|
|
||||||
|
|
||||||
[Export] public StringName AmmoKey;
|
|
||||||
//[Export] public float BulletSpeed = 100f;
|
//[Export] public float BulletSpeed = 100f;
|
||||||
//[Export] public float BulletDamage = 1;
|
//[Export] public float BulletDamage = 1;
|
||||||
//[Export] public float LifeTime = 10f;
|
//[Export] public float LifeTime = 10f;
|
||||||
|
|
@ -49,6 +48,11 @@ public partial class WeaponResource : Resource
|
||||||
//[Export] private Array<Resource> _timeModifiers;
|
//[Export] private Array<Resource> _timeModifiers;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
[ExportCategory("Sounds")]
|
||||||
|
[Export] public AudioStream ReloadSound { get; set; }
|
||||||
|
[Export] public AudioStream ShootSound { get; set; }
|
||||||
|
[Export] public AudioStream EmptySound { get; set; }
|
||||||
|
|
||||||
public BulletInfo MakeBullet(Vector2 position)
|
public BulletInfo MakeBullet(Vector2 position)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,14 @@ public partial class Weapon : Node2D
|
||||||
[Export]
|
[Export]
|
||||||
public Marker2D Muzzle { get; set; }
|
public Marker2D Muzzle { get; set; }
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void ShootingEventHandler();
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void ReloadingEventHandler();
|
||||||
|
|
||||||
|
[Signal] public delegate void EmptyEventHandler();
|
||||||
|
|
||||||
public int Ammo { get; set; } = 0;
|
public int Ammo { get; set; } = 0;
|
||||||
|
|
||||||
private int _loadedAmmo;
|
private int _loadedAmmo;
|
||||||
|
|
@ -60,6 +68,8 @@ public partial class Weapon : Node2D
|
||||||
|
|
||||||
public void Reload()
|
public void Reload()
|
||||||
{
|
{
|
||||||
|
EmitSignalReloading();
|
||||||
|
|
||||||
_cooldownTimer.Start(WeaponData.ReloadTime);
|
_cooldownTimer.Start(WeaponData.ReloadTime);
|
||||||
|
|
||||||
if (WeaponData.InfiniteAmmo || string.IsNullOrWhiteSpace(WeaponData.AmmoKey))
|
if (WeaponData.InfiniteAmmo || string.IsNullOrWhiteSpace(WeaponData.AmmoKey))
|
||||||
|
|
@ -77,7 +87,8 @@ public partial class Weapon : Node2D
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GD.Print("Out of ammo");
|
EmitSignalEmpty();
|
||||||
|
//GD.Print("Out of ammo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,11 +111,12 @@ public partial class Weapon : Node2D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EmitSignalShooting();
|
||||||
|
|
||||||
// TODO: Shoot at muzzle position, need to provide a way to turn it, on a radius?
|
// TODO: Shoot at muzzle position, need to provide a way to turn it, on a radius?
|
||||||
|
|
||||||
float halfSpread = WeaponData.SpreadAngle / 2f;
|
float halfSpread = WeaponData.SpreadAngle / 2f;
|
||||||
float spreadStep = WeaponData.BulletsPerShot > 1 ? WeaponData.SpreadAngle / (WeaponData.BulletsPerShot - 1) : 0;
|
float spreadStep = WeaponData.BulletsPerShot > 1 ? WeaponData.SpreadAngle / (WeaponData.BulletsPerShot - 1) : 0;
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < WeaponData.BulletsPerShot; i++)
|
for (int i = 0; i < WeaponData.BulletsPerShot; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
40
Scripts/Weapons/WeaponSoundModule.cs
Normal file
40
Scripts/Weapons/WeaponSoundModule.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Weapons;
|
||||||
|
|
||||||
|
public partial class WeaponSoundModule : Node2D
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public Weapon Weapon { get; private set; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public AudioStreamPlayer2D ShootSound { get; private set; }
|
||||||
|
[Export]
|
||||||
|
public AudioStreamPlayer2D ReloadSound { get; private set; }
|
||||||
|
[Export]
|
||||||
|
public AudioStreamPlayer2D EmptySound { get; private set; }
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
if (Weapon?.WeaponData is null) return;
|
||||||
|
|
||||||
|
ShootSound.Stream = Weapon.WeaponData.ShootSound;
|
||||||
|
ReloadSound.Stream = Weapon.WeaponData.ReloadSound;
|
||||||
|
EmptySound.Stream = Weapon.WeaponData.EmptySound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayReloadSound()
|
||||||
|
{
|
||||||
|
ReloadSound?.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayShootSound()
|
||||||
|
{
|
||||||
|
ShootSound?.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayEmptySound()
|
||||||
|
{
|
||||||
|
EmptySound?.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Scripts/Weapons/WeaponSoundModule.cs.uid
Normal file
1
Scripts/Weapons/WeaponSoundModule.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dw7nwfbws3op4
|
||||||
Loading…
Add table
Add a link
Reference in a new issue