[Feat] 돌발 이벤트 사운드 추가 그리고 리팩토링
This commit is contained in:
parent
4ae48da950
commit
c17ec2c0a9
@ -73,7 +73,7 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
|||||||
_isBattle = !isHousingScene;
|
_isBattle = !isHousingScene;
|
||||||
Debug.Log("_isBattle: " + _isBattle);*/
|
Debug.Log("_isBattle: " + _isBattle);*/
|
||||||
|
|
||||||
SwitchBattleMode();
|
// SwitchBattleMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
BIN
Assets/LIN/Resources/OvertimeWork.mp3
(Stored with Git LFS)
Normal file
BIN
Assets/LIN/Resources/OvertimeWork.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
23
Assets/LIN/Resources/OvertimeWork.mp3.meta
Normal file
23
Assets/LIN/Resources/OvertimeWork.mp3.meta
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6142a6977f91d604d98880bdda758192
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 7
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/LIN/Resources/TeamGathering.mp3
(Stored with Git LFS)
Normal file
BIN
Assets/LIN/Resources/TeamGathering.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
23
Assets/LIN/Resources/TeamGathering.mp3.meta
Normal file
23
Assets/LIN/Resources/TeamGathering.mp3.meta
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59471df5d383e88478a567ac9b1e83d4
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 7
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -88,33 +88,30 @@ public class InteractionController : MonoBehaviour
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//퇴근 후 돌발 이벤트
|
#region 퇴근 후 돌발 이벤트
|
||||||
|
|
||||||
|
//이벤트 발생 확률 계산기
|
||||||
private AfterWorkEventType SuddenEventCalculator()
|
private AfterWorkEventType SuddenEventCalculator()
|
||||||
{
|
{
|
||||||
var index = Random.Range(0, HousingConstants.AFTER_WORK_DENOMINATOR);
|
var index = Random.Range(0, HousingConstants.AFTER_WORK_DENOMINATOR);
|
||||||
return HousingConstants.AfterWorkEvents.GetValueOrDefault(index, AfterWorkEventType.None);
|
return HousingConstants.AfterWorkEvents.GetValueOrDefault(index, AfterWorkEventType.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Interaction Controller와 같은 방식으로 작동됩니다.
|
||||||
private void SuddenAfterWorkEventHappen()
|
private void SuddenAfterWorkEventHappen()
|
||||||
{
|
{
|
||||||
AfterWorkEventType afterWorkEventType = SuddenEventCalculator();
|
AfterWorkEventType afterWorkEventType = SuddenEventCalculator();
|
||||||
Debug.Log(afterWorkEventType);
|
|
||||||
|
|
||||||
if (afterWorkEventType == AfterWorkEventType.None) return;
|
if (afterWorkEventType == AfterWorkEventType.None) return;
|
||||||
switch (afterWorkEventType)
|
|
||||||
|
HousingConstants.SuddenEventTexts.TryGetValue(afterWorkEventType, out string suddenEventText);
|
||||||
|
|
||||||
|
housingCanvasController.ShowSuddenEventPanel(suddenEventText, () =>
|
||||||
{
|
{
|
||||||
case AfterWorkEventType.OvertimeWork:
|
housingCanvasController.ShowSuddenEventImage(afterWorkEventType);
|
||||||
housingCanvasController.ShowSuddenEventPanel("부장님이 퇴근을 안하셔.. 야근할까?", () =>
|
GameManager.Instance.PlaySuddenEventSound(afterWorkEventType);
|
||||||
{
|
|
||||||
housingCanvasController.ShowSuddenEventImage(0);
|
|
||||||
//Todo: 스테이터스 변경
|
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
case AfterWorkEventType.TeamGathering:
|
|
||||||
housingCanvasController.ShowSuddenEventPanel("갑자기 팀 회식이 잡혔다. 참석 하러 가자",
|
|
||||||
() => { housingCanvasController.ShowSuddenEventImage(1); });
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,15 +92,22 @@ public class HousingCanvasController : MonoBehaviour
|
|||||||
OnSuddenButtonPressed?.Invoke();
|
OnSuddenButtonPressed?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowSuddenEventImage(int index)
|
public void ShowSuddenEventImage(AfterWorkEventType afterWorkEventType)
|
||||||
{
|
{
|
||||||
if (_autoHideCoroutine != null) StopCoroutine(_autoHideCoroutine);
|
if (_autoHideCoroutine != null) StopCoroutine(_autoHideCoroutine);
|
||||||
|
|
||||||
suddenEventImages[index].SetActive(true);
|
switch (afterWorkEventType)
|
||||||
|
{
|
||||||
|
case AfterWorkEventType.OvertimeWork:
|
||||||
|
suddenEventImages[0].SetActive(true);
|
||||||
|
break;
|
||||||
|
case AfterWorkEventType.TeamGathering:
|
||||||
|
suddenEventImages[1].SetActive(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
//사운드 재생
|
//사운드 재생
|
||||||
|
|
||||||
_autoHideCoroutine = StartCoroutine(AutoHideSuddenImage());
|
_autoHideCoroutine = StartCoroutine(AutoHideSuddenImage(afterWorkEventType));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HideSuddenEventImage()
|
public void HideSuddenEventImage()
|
||||||
@ -110,10 +117,10 @@ public class HousingCanvasController : MonoBehaviour
|
|||||||
image.SetActive(false);
|
image.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private IEnumerator AutoHideSuddenImage()
|
private IEnumerator AutoHideSuddenImage(AfterWorkEventType afterWorkEventType)
|
||||||
{
|
{
|
||||||
float startTime = Time.time;
|
float startTime = Time.time;
|
||||||
while (Time.time - startTime < 2.0f)
|
while (Time.time - startTime < HousingConstants.SUDDENEVENT_IAMGE_SHOW_TIME)
|
||||||
{
|
{
|
||||||
if (Input.touchCount > 0 || Input.GetMouseButtonDown(0))
|
if (Input.touchCount > 0 || Input.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
@ -122,9 +129,10 @@ public class HousingCanvasController : MonoBehaviour
|
|||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//패널 닫고 애니메이션 null처리
|
//패널 닫고 효과음 끄기
|
||||||
HideSuddenEventImage();
|
HideSuddenEventImage();
|
||||||
HideSuddenEventPanel();
|
HideSuddenEventPanel();
|
||||||
|
GameManager.Instance.StopSuddenEventSound(afterWorkEventType);
|
||||||
|
|
||||||
_autoHideCoroutine = null;
|
_autoHideCoroutine = null;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public static class HousingConstants
|
|||||||
//돌발 이벤트 확률 계산
|
//돌발 이벤트 확률 계산
|
||||||
public static int AFTER_WORK_DENOMINATOR = 2;
|
public static int AFTER_WORK_DENOMINATOR = 2;
|
||||||
//돌발 이벤트 보여줄 시간
|
//돌발 이벤트 보여줄 시간
|
||||||
public static float SUDDENEVENT_IAMGE_SHOW_TIME = 3.0f;
|
public static float SUDDENEVENT_IAMGE_SHOW_TIME = 4.0f;
|
||||||
|
|
||||||
|
|
||||||
#region 상호작용 멘트
|
#region 상호작용 멘트
|
||||||
@ -33,7 +33,6 @@ public static class HousingConstants
|
|||||||
"도저히 출근할 체력이 안되는걸..?","출근하는 중")},
|
"도저히 출근할 체력이 안되는걸..?","출근하는 중")},
|
||||||
{ ActionType.Eat, new InteractionTexts("식사를 하자","1시간 동안 체력 1을 회복한다.","밥 먹는 중") }
|
{ ActionType.Eat, new InteractionTexts("식사를 하자","1시간 동안 체력 1을 회복한다.","밥 먹는 중") }
|
||||||
};
|
};
|
||||||
#endregion
|
|
||||||
|
|
||||||
public struct InteractionTexts
|
public struct InteractionTexts
|
||||||
{
|
{
|
||||||
@ -50,9 +49,33 @@ public static class HousingConstants
|
|||||||
AnimationText = animationText;
|
AnimationText = animationText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 돌발 이벤트
|
||||||
|
|
||||||
|
public static readonly Dictionary<AfterWorkEventType, string> SuddenEventTexts =
|
||||||
|
new Dictionary<AfterWorkEventType, string>
|
||||||
|
{
|
||||||
|
{ AfterWorkEventType.OvertimeWork, "부장님이 퇴근을 안하셔.. 야근할까?" },
|
||||||
|
{ AfterWorkEventType.TeamGathering, "갑자기 팀 회식이 잡혔다. 참석 하러 가자"}
|
||||||
|
};
|
||||||
|
|
||||||
|
public struct SuddenEventTypes
|
||||||
|
{
|
||||||
|
public AfterWorkEventType AfterWorkEvent { get; private set; }
|
||||||
|
public string AfterWorkEventText { get; private set; }
|
||||||
|
|
||||||
|
public SuddenEventTypes(AfterWorkEventType afterWorkEvent, string afterWorkEventText)
|
||||||
|
{
|
||||||
|
AfterWorkEvent = afterWorkEvent;
|
||||||
|
AfterWorkEventText = afterWorkEventText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
// 랜덤 값에 일치하는 함수를 리턴하기 위한 딕셔너리
|
// 랜덤 값에 일치하는 함수를 리턴하기 위한 딕셔너리
|
||||||
// AFTER_WORK_DENOMINATOR 값 확정 후에 키 값 수정
|
// TODO: AFTER_WORK_DENOMINATOR 값 확정 후에 키 값 수정
|
||||||
public static readonly Dictionary<int, AfterWorkEventType> AfterWorkEvents = new Dictionary<int, AfterWorkEventType> {
|
public static readonly Dictionary<int, AfterWorkEventType> AfterWorkEvents = new Dictionary<int, AfterWorkEventType> {
|
||||||
{0, AfterWorkEventType.OvertimeWork},
|
{0, AfterWorkEventType.OvertimeWork},
|
||||||
{1, AfterWorkEventType.TeamGathering}
|
{1, AfterWorkEventType.TeamGathering}
|
||||||
|
@ -27,6 +27,10 @@ public partial class GameManager
|
|||||||
[SerializeField] private AudioClip eatingSFX;
|
[SerializeField] private AudioClip eatingSFX;
|
||||||
[SerializeField] private AudioClip sleepingSFX;
|
[SerializeField] private AudioClip sleepingSFX;
|
||||||
|
|
||||||
|
[Header("돌발 이벤트 효과음")]
|
||||||
|
[SerializeField] private AudioClip overtimeWorkSFX;
|
||||||
|
[SerializeField] private AudioClip teamGatheringSFX;
|
||||||
|
|
||||||
[Header("게임 결과 효과음")]
|
[Header("게임 결과 효과음")]
|
||||||
[SerializeField] private AudioClip gameOverSFX;
|
[SerializeField] private AudioClip gameOverSFX;
|
||||||
[SerializeField] private AudioClip victorySFX;
|
[SerializeField] private AudioClip victorySFX;
|
||||||
@ -84,6 +88,10 @@ public partial class GameManager
|
|||||||
if (eatingSFX != null) SafeSoundManager?.LoadAudioClip("Eating", eatingSFX);
|
if (eatingSFX != null) SafeSoundManager?.LoadAudioClip("Eating", eatingSFX);
|
||||||
if (sleepingSFX != null) SafeSoundManager?.LoadAudioClip("Sleeping", sleepingSFX);
|
if (sleepingSFX != null) SafeSoundManager?.LoadAudioClip("Sleeping", sleepingSFX);
|
||||||
|
|
||||||
|
// 돌발 이벤트 효과음 등록
|
||||||
|
if(overtimeWorkSFX != null) SafeSoundManager?.LoadAudioClip("OvertimeWork", overtimeWorkSFX);
|
||||||
|
if(teamGatheringSFX != null) SafeSoundManager?.LoadAudioClip("TeamGathering", teamGatheringSFX);
|
||||||
|
|
||||||
// 플레이어 전투 효과음 등록
|
// 플레이어 전투 효과음 등록
|
||||||
if (housingFootstepSFX != null) SafeSoundManager?.LoadAudioClip("HousingFootstep", housingFootstepSFX);
|
if (housingFootstepSFX != null) SafeSoundManager?.LoadAudioClip("HousingFootstep", housingFootstepSFX);
|
||||||
if (dungeonFootstepSFX != null) SafeSoundManager?.LoadAudioClip("DungeonFootstep", dungeonFootstepSFX);
|
if (dungeonFootstepSFX != null) SafeSoundManager?.LoadAudioClip("DungeonFootstep", dungeonFootstepSFX);
|
||||||
@ -299,6 +307,53 @@ public partial class GameManager
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 돌발 이벤트
|
||||||
|
public void PlaySuddenEventSound(AfterWorkEventType afterWorkEventType)
|
||||||
|
{
|
||||||
|
// 배경음 중지 (페이드아웃)
|
||||||
|
SafeSoundManager?.StopBGM(true, 0.5f);
|
||||||
|
|
||||||
|
// 효과음 재생
|
||||||
|
switch (afterWorkEventType)
|
||||||
|
{
|
||||||
|
case AfterWorkEventType.TeamGathering:
|
||||||
|
SafeSoundManager?.PlaySFX("TeamGathering");
|
||||||
|
break;
|
||||||
|
case AfterWorkEventType.OvertimeWork:
|
||||||
|
SafeSoundManager?.PlaySFX("OvertimeWork");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 상호작용 효과음 종료
|
||||||
|
public void StopSuddenEventSound(AfterWorkEventType afterWorkEventType, float fadeTime = 0.5f)
|
||||||
|
{
|
||||||
|
string sfxName = "";
|
||||||
|
|
||||||
|
switch (afterWorkEventType)
|
||||||
|
{
|
||||||
|
case AfterWorkEventType.TeamGathering:
|
||||||
|
sfxName = "TeamGathering";
|
||||||
|
break;
|
||||||
|
case AfterWorkEventType.OvertimeWork:
|
||||||
|
sfxName = "OvertimeWork";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(sfxName))
|
||||||
|
{
|
||||||
|
SafeSoundManager?.FadeOutSFXByName(sfxName, fadeTime);
|
||||||
|
|
||||||
|
// 배경음 재개
|
||||||
|
if (wasPlayingBGM && previousBGMClip != null)
|
||||||
|
{
|
||||||
|
StartCoroutine(FadeOutAndPlayBGM(sfxName, fadeTime));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 플레이어 전투 효과음 제어
|
#region 플레이어 전투 효과음 제어
|
||||||
|
|
||||||
public void PlayHousingFootstepSound()
|
public void PlayHousingFootstepSound()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user