some SFX
This commit is contained in:
@@ -65,6 +65,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
public ShapeCast3D CeilingDetector;
|
||||
public RayCast3D DirectGroundDetector;
|
||||
public Area3D WeaponHitbox;
|
||||
public AudioStreamPlayer3D SFXPlayer;
|
||||
|
||||
// Inspector stuff
|
||||
[Export] public Marker3D TutorialWeaponTarget;
|
||||
@@ -226,6 +227,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
private float _lastFrameWasOnFloor = -Mathf.Inf;
|
||||
private const int NUM_OF_HEAD_COLLISION_DETECTORS = 4;
|
||||
private RayCast3D[] _headCollisionDetectors;
|
||||
private AudioStreamPlaybackInteractive _audioStream;
|
||||
|
||||
// Basic movement
|
||||
private bool _movementEnabled = true;
|
||||
@@ -359,6 +361,9 @@ public partial class PlayerController : CharacterBody3D,
|
||||
DashIndicatorMeshCylinder = DashIndicatorMesh.Mesh as CylinderMesh;
|
||||
DashIndicatorMesh.Visible = false;
|
||||
|
||||
SFXPlayer = GetNode<AudioStreamPlayer3D>("SFXPlayer");
|
||||
_audioStream = SFXPlayer.GetStreamPlayback() as AudioStreamPlaybackInteractive;
|
||||
|
||||
// Camera stuff
|
||||
HeadSystem = GetNode<HeadSystem>("HeadSystem");
|
||||
Camera3D camera = GetNode<Camera3D>("HeadSystem/CameraSmooth/Camera3D");
|
||||
@@ -467,6 +472,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
HeadSystem.Init();
|
||||
HeadSystem.HitboxActivated += OnHitboxActivated;
|
||||
HeadSystem.HitboxDeactivated += OnHitboxDeactivated;
|
||||
HeadSystem.StepFoot += OnFootStepped;
|
||||
|
||||
// Movement stuff
|
||||
// Getting universal setting from GODOT editor to be in sync
|
||||
@@ -528,8 +534,11 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_slideCanceled.StateEntered += OnSlideCanceled;
|
||||
_slideCanceled.StatePhysicsProcessing += HandleSlideCanceled;
|
||||
_groundSliding.StatePhysicsProcessing += HandleGroundSlide;
|
||||
_groundSliding.StateEntered += OnGroundSlideStarted;
|
||||
_airGliding.StatePhysicsProcessing += HandleAirGlide;
|
||||
_airGlidingDoubleJump.StatePhysicsProcessing += HandleAirGlide;
|
||||
_airGliding.StateEntered += OnAirGlideStarted;
|
||||
_airGlidingDoubleJump.StateEntered += OnAirGlideStarted;
|
||||
|
||||
_onGroundSlideJump.Taken += JumpFromGroundSlide;
|
||||
_onAirGlideDoubleJump.Taken += JumpFromAirGlide;
|
||||
@@ -651,6 +660,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
public void OnAirborneToGrounded()
|
||||
{
|
||||
HeadSystem.OnJumpEnded();
|
||||
_audioStream!.SwitchToClipByName("land");
|
||||
}
|
||||
|
||||
public bool IsGroundLike()
|
||||
@@ -993,6 +1003,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
}
|
||||
public void SimpleDash(float strength = -1)
|
||||
{
|
||||
_audioStream.SwitchToClipByName("dash");
|
||||
SimpleDashInDirection(GetInputGlobalHDirection(), strength);
|
||||
}
|
||||
|
||||
@@ -1164,7 +1175,6 @@ public partial class PlayerController : CharacterBody3D,
|
||||
return;
|
||||
}
|
||||
|
||||
HeadSystem.OnJumpStarted();
|
||||
if (WallHugSystem.IsWallHugging())
|
||||
{
|
||||
_playerState.SendEvent("wall_jump");
|
||||
@@ -1175,6 +1185,9 @@ public partial class PlayerController : CharacterBody3D,
|
||||
private float _jumpStrengthMultiplier = 1.0f;
|
||||
public void OnJumpStarted(float verticalVelocity)
|
||||
{
|
||||
HeadSystem.OnJumpStarted();
|
||||
_audioStream!.SwitchToClipByName("jump");
|
||||
|
||||
_framesSinceJumpAtApex = 0;
|
||||
var angle = GetFloorAngle();
|
||||
var floorAngleFactor = angle > 1 ? 1 : 1 + angle;
|
||||
@@ -1273,6 +1286,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
public void OnMantleStarted()
|
||||
{
|
||||
HeadSystem.OnMantle();
|
||||
_audioStream!.SwitchToClipByName("mantle");
|
||||
|
||||
_mantlePath = MantlePath.Instantiate() as Path;
|
||||
if (_mantlePath == null)
|
||||
@@ -1379,6 +1393,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
{
|
||||
_targetSpeed = Velocity.Length();
|
||||
SetupSlideCollision();
|
||||
_audioStream!.SwitchToClipByName("glide");
|
||||
}
|
||||
|
||||
public bool CanStandUpFromSlide()
|
||||
@@ -1461,7 +1476,13 @@ public partial class PlayerController : CharacterBody3D,
|
||||
if (!isOnFloorCustom() && !DirectGroundDetector.IsColliding()) _playerState.SendEvent("start_falling");
|
||||
if (CanStandUpFromSlide() && !_isSlideInputDown) _playerState.SendEvent("slide_released");
|
||||
}
|
||||
|
||||
|
||||
public void OnGroundSlideStarted()
|
||||
{
|
||||
}
|
||||
public void OnAirGlideStarted()
|
||||
{
|
||||
}
|
||||
public void GlideInAir(float delta)
|
||||
{
|
||||
if (AllowForVelocityRedirection)
|
||||
@@ -1498,6 +1519,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
}
|
||||
public void SlideEnded()
|
||||
{
|
||||
_audioStream!.SwitchToClipByName("footsteps");
|
||||
SetupStandingCollision();
|
||||
_targetSpeed = WalkSpeed;
|
||||
}
|
||||
@@ -1524,6 +1546,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
{
|
||||
SetHorizontalVelocity(Vector2.Zero);
|
||||
SetVerticalVelocity(-SlamSpeed);
|
||||
_audioStream!.SwitchToClipByName("dash");
|
||||
}
|
||||
public void HandleSlam(float delta)
|
||||
{
|
||||
@@ -1531,6 +1554,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
}
|
||||
public void SlamEnded()
|
||||
{
|
||||
HeadSystem.OnGetHit();
|
||||
_audioStream!.SwitchToClipByName("slam");
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
@@ -1647,6 +1672,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
///////////////////////////
|
||||
public void OnAimedDashStarted()
|
||||
{
|
||||
_audioStream.SwitchToClipByName("dash");
|
||||
|
||||
// Adjusting for player height, where the middle of the capsule should get to the dash location instead of the
|
||||
// feet of the capsule
|
||||
var correction = DashSystem.CollisionNormal == Vector3.Down ? _playerHeight : DashSystem.DashCastRadius;
|
||||
@@ -1678,6 +1705,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
// Weapon dashing
|
||||
public void ThrowWeapon()
|
||||
{
|
||||
_audioStream.SwitchToClipByName("attacks");
|
||||
|
||||
_playerState.SendEvent("cancel_aim");
|
||||
RemoveChildNode(WeaponSystem);
|
||||
HeadSystem.HideWeapon();
|
||||
@@ -1703,6 +1732,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_playerState.SendEvent("cancel_aim");
|
||||
_playerState.SendEvent("weapon_dash");
|
||||
PerformEmpoweredAction();
|
||||
_audioStream.SwitchToClipByName("dash");
|
||||
|
||||
DashSystem.ShouldMantle = false;
|
||||
_dashDirection = (WeaponSystem.GlobalPosition - GlobalPosition).Normalized();
|
||||
@@ -1724,6 +1754,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_playerState.SendEvent("cancel_aim");
|
||||
_playerState.SendEvent("weapon_dash");
|
||||
PerformEmpoweredAction();
|
||||
_audioStream.SwitchToClipByName("dash");
|
||||
|
||||
DashSystem.ShouldMantle = false;
|
||||
var dashLocation = WeaponSystem.PlantLocation;
|
||||
@@ -1788,6 +1819,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
DamageTaken?.Invoke(this, finalDamage);
|
||||
|
||||
HeadSystem.OnGetHit();
|
||||
_audioStream!.SwitchToClipByName("damage_taken");
|
||||
TriggerHitstop();
|
||||
OnHitInvincibility();
|
||||
|
||||
@@ -1823,6 +1855,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
public void PerformHit()
|
||||
{
|
||||
HeadSystem.OnHit();
|
||||
_audioStream!.SwitchToClipByName("attacks");
|
||||
}
|
||||
|
||||
public void OnHitboxActivated()
|
||||
@@ -1850,6 +1883,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_hitEnemies.Clear();
|
||||
|
||||
HeadSystem.OnHitTarget();
|
||||
_audioStream!.SwitchToClipByName("hits");
|
||||
TriggerHitstop();
|
||||
}
|
||||
|
||||
@@ -1888,4 +1922,10 @@ public partial class PlayerController : CharacterBody3D,
|
||||
{
|
||||
_isInvincible = false;
|
||||
}
|
||||
|
||||
// Sound
|
||||
public void OnFootStepped()
|
||||
{
|
||||
_audioStream!.SwitchToClipByName("footsteps");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user