Skip to content

Commit

Permalink
feat: Rummaging animation & Crew 공포 사운드 변경 및 코드 리펙토링 (#93)
Browse files Browse the repository at this point in the history
* feat: Rummaging 애니메이션 변경

* feat: Crew 공포 사운드 변경 및 코드 리펙토링
  • Loading branch information
scarleter99 committed Apr 28, 2024
1 parent cd51006 commit 22ed1ad
Show file tree
Hide file tree
Showing 20 changed files with 1,115 additions and 2,841 deletions.
Binary file not shown.
884 changes: 0 additions & 884 deletions Client/Assets/Resources/Animations/Ch28_nonPBR@Injured Idle.fbx.meta

This file was deleted.

Binary file not shown.
884 changes: 0 additions & 884 deletions Client/Assets/Resources/Animations/Ch28_nonPBR@Injured Run.fbx.meta

This file was deleted.

Binary file not shown.
884 changes: 0 additions & 884 deletions Client/Assets/Resources/Animations/Ch28_nonPBR@Injured Walk.fbx.meta

This file was deleted.

Binary file added Client/Assets/Resources/Animations/Rummaging.fbx
Binary file not shown.
894 changes: 894 additions & 0 deletions Client/Assets/Resources/Animations/Rummaging.fbx.meta

Large diffs are not rendered by default.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Client/Assets/Scenes/TestScene/Test_Scene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.74762183, g: 0.5764795, b: 0.6462174, a: 1}
m_IndirectSpecularColor: {r: 0.7479761, g: 0.5767737, b: 0.64641577, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down
113 changes: 77 additions & 36 deletions Client/Assets/Scripts/Contents/Controllers/AlienSoundController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fusion;
using UnityEngine;

public class AlienSoundController : BaseSoundController
{
Expand Down Expand Up @@ -43,71 +44,111 @@ public void PlaySound(Define.AlienActionType alienActionType)
[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayFootStepSound(float pitch, float volume)
{
AudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/FootStep_Alien");
AudioSource.pitch = pitch;
AudioSource.volume = volume;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = true;
AudioSource.Play();
CreatureAudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/FootStep_Alien");
CreatureAudioSource.pitch = pitch;
CreatureAudioSource.volume = volume;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = true;
CreatureAudioSource.Play();
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayCrashDoor()
{
AudioSource.pitch = 1f;
AudioSource.volume = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/CrashDoor"));
CreatureAudioSource.pitch = 1f;
CreatureAudioSource.volume = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/CrashDoor"));
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayBasicAttack()
{
AudioSource.pitch = 1f;
AudioSource.volume = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Attack"));
CreatureAudioSource.pitch = 1f;
CreatureAudioSource.volume = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Attack"));
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayRoar()
{
AudioSource.pitch = 1.3f;
AudioSource.volume = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Roar"));
CreatureAudioSource.pitch = 1.3f;
CreatureAudioSource.volume = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Roar"));
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayCursedHowl()
{
AudioSource.pitch = 1f;
AudioSource.volume = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/CursedHowl"));
CreatureAudioSource.pitch = 1f;
CreatureAudioSource.volume = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/CursedHowl"));
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayLeapAttack()
{
AudioSource.pitch = 1f;
AudioSource.volume = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Attack"));
CreatureAudioSource.pitch = 1f;
CreatureAudioSource.volume = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Attack"));
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayHit()
{
AudioSource.pitch = 1f;
AudioSource.volume = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Attack_Hit"));
CreatureAudioSource.pitch = 1f;
CreatureAudioSource.volume = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.PlayOneShot(Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Alien/Attack_Hit"));
}

public override void CheckChasing()
{
if (!HasStateAuthority || !Creature.IsSpawned)
return;

for (float i = 0.2f; i < 0.9f; i += 0.1f)
{
for (float j = 0.2f; j < 0.9f; j += 0.1f)
{
Ray ray = CreatureCamera.Camera.ViewportPointToRay(
new Vector3(i, j, CreatureCamera.Camera.nearClipPlane));

if (i < 0.25f || j < 0.25f || i > 0.75f || j > 0.75f)
Debug.DrawRay(ray.origin, ray.direction * 15f, Color.green);

if (Physics.Raycast(ray, out RaycastHit rayHit, maxDistance: 15f,
layerMask: LayerMask.GetMask("Crew", "MapObject")))
{
if (rayHit.transform.gameObject.TryGetComponent(out Crew crew))
{
if (!IsChasing)
{
StopAllCoroutines();
IsChasing = true;
if (!Managers.SoundMng.IsPlaying(Define.SoundType.Bgm))
Managers.SoundMng.Play($"{Define.BGM_PATH}/The Big Clash", Define.SoundType.Bgm, volume: 1);
}

return;
}
}
}
}

if (IsChasing)
StartCoroutine(CheckNotChasing(7f));

IsChasing = false;
}
}
43 changes: 39 additions & 4 deletions Client/Assets/Scripts/Contents/Controllers/BaseSoundController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
using Fusion;
using System.Collections;
using Fusion;
using UnityEngine;

public abstract class BaseSoundController : NetworkBehaviour
{
public Creature Creature { get; protected set; }
public AudioSource AudioSource => Creature.AudioSource;
public CreatureCamera CreatureCamera => Creature.CreatureCamera;
public AudioSource CreatureAudioSource => Creature.AudioSource;
public Define.CreatureState CreatureState => Creature.CreatureState;
public Define.CreaturePose CreaturePose => Creature.CreaturePose;

public AudioSource BgmAudioSource => SoundManager._audioSources[(int)Define.SoundType.Bgm];

public bool IsChasing { get; protected set; } = false;

public override void Spawned()
{
Init();
Expand All @@ -23,7 +29,36 @@ protected void Init()
[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
public void Rpc_StopEffectMusic()
{
if (AudioSource.isPlaying)
AudioSource.Stop();
if (CreatureAudioSource.isPlaying)
CreatureAudioSource.Stop();
}

#region Chasing

public abstract void CheckChasing();

protected IEnumerator CheckNotChasing(float time)
{
float currentChasingTime = 0f;
while (currentChasingTime < time)
{
currentChasingTime += Time.deltaTime;
yield return null;
}

StartCoroutine(StopChasing());
}

protected IEnumerator StopChasing()
{
while (BgmAudioSource.volume > 0f)
{
BgmAudioSource.volume -= 0.3f * Time.deltaTime;
yield return null;
}

Managers.SoundMng.Stop(Define.SoundType.Bgm);
}

#endregion
}
69 changes: 51 additions & 18 deletions Client/Assets/Scripts/Contents/Controllers/CrewSoundController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fusion;
using UnityEngine;

public class CrewSoundController : BaseSoundController
{
Expand Down Expand Up @@ -34,33 +35,65 @@ public void PlaySound(Define.CrewActionType crewActionType)
[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayFootStepSound(float pitch, float volume)
{
AudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Crew/FootStep");
AudioSource.pitch = pitch;
AudioSource.volume = volume;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = true;
AudioSource.Play();
CreatureAudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Crew/FootStep");
CreatureAudioSource.pitch = pitch;
CreatureAudioSource.volume = volume;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = true;
CreatureAudioSource.Play();
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayDamagedSound()
{
AudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Crew/Damaged");
AudioSource.volume = 0.5f;
AudioSource.pitch = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.Play();
CreatureAudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Crew/Damaged");
CreatureAudioSource.volume = 0.5f;
CreatureAudioSource.pitch = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.Play();
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected void Rpc_PlayDeadSound()
{
AudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Crew/Damaged");
AudioSource.volume = 0.5f;
AudioSource.pitch = 1f;
AudioSource.spatialBlend = 1.0f;
AudioSource.loop = false;
AudioSource.Play();
CreatureAudioSource.clip = Managers.SoundMng.GetOrAddAudioClip($"{Define.EFFECT_PATH}/Crew/Damaged");
CreatureAudioSource.volume = 0.5f;
CreatureAudioSource.pitch = 1f;
CreatureAudioSource.spatialBlend = 1.0f;
CreatureAudioSource.loop = false;
CreatureAudioSource.Play();
}

public override void CheckChasing()
{
if (!HasStateAuthority || !Creature.IsSpawned)
return;

Collider[] hitColliders = new Collider[1];
if (Physics.OverlapBoxNonAlloc(CreatureCamera.Transform.position, new Vector3(25f, 1f, 25f),
hitColliders, Quaternion.identity, LayerMask.GetMask("Alien")) > 0)
{
if (hitColliders[0].gameObject.TryGetComponent(out Alien alien))
{

SoundManager._audioSources[(int)Define.SoundType.Bgm].volume =
-0.045f * (alien.Transform.position - Creature.Transform.position).magnitude + 1.225f;
if (!IsChasing)
{
StopAllCoroutines();
IsChasing = true;

if (!Managers.SoundMng.IsPlaying(Define.SoundType.Bgm))
Managers.SoundMng.Play($"{Define.BGM_PATH}/Deep Space Pulsing Signals", Define.SoundType.Bgm, volume: 0.3f);
}
return;
}
}

if (IsChasing)
StartCoroutine(CheckNotChasing(2f));

IsChasing = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public abstract class BaseWorkStation : NetworkBehaviour, IInteractable

public string Description { get; protected set; }
public Define.CrewActionType CrewActionType { get; protected set; }
[Networked] protected float CurrentWorkAmount { get; set; }
[Networked] protected float CurrentWorkAmount { get; set; } = 0f;
[Networked] protected float TotalWorkAmount { get; set; }
[Networked] protected int WorkerCount { get; set; }
[Networked] protected NetworkBool IsCompleted { get; set; }
[Networked] protected NetworkBool IsCompleted { get; set; } = false;

public bool CanRememberWork { get; protected set; }

Expand All @@ -30,9 +30,6 @@ public override void Spawned()
protected virtual void Init()
{
AudioSource = GetComponent<AudioSource>();

CurrentWorkAmount = 0f;
IsCompleted = false;
}

#region Interact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class Door : BaseWorkStation
{
public new string Description => IsOpened ? "Close" : "Open";

[Networked] private NetworkBool IsOpened { get; set; }
[Networked] private NetworkBool IsOpened { get; set; } = false;

public NetworkMecanimAnimator NetworkAnim { get; protected set; }

Expand All @@ -18,7 +18,6 @@ protected override void Init()

CrewActionType = Define.CrewActionType.OpenDoor;
CanRememberWork = false;
IsOpened = false;

TotalWorkAmount = 15f; // only for alien crashing door
}
Expand Down
Loading

0 comments on commit 22ed1ad

Please sign in to comment.