사운드 매니저 추가
This commit is contained in:
@@ -34277,6 +34277,50 @@ Transform:
|
|||||||
- {fileID: 1673487155}
|
- {fileID: 1673487155}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &2068238027
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2068238029}
|
||||||
|
- component: {fileID: 2068238028}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: SoundManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &2068238028
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2068238027}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 023ac119be3a3d24c816494653c341dc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!4 &2068238029
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2068238027}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 116.990395, y: -121.206154, z: 0.1832571}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &2135657550
|
--- !u!1 &2135657550
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -34383,3 +34427,4 @@ SceneRoots:
|
|||||||
- {fileID: 2067632268}
|
- {fileID: 2067632268}
|
||||||
- {fileID: 480895542}
|
- {fileID: 480895542}
|
||||||
- {fileID: 1103604663}
|
- {fileID: 1103604663}
|
||||||
|
- {fileID: 2068238029}
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ namespace TON
|
|||||||
|
|
||||||
private CharacterBase _characterBase;
|
private CharacterBase _characterBase;
|
||||||
|
|
||||||
|
public AudioClip _attackSound;
|
||||||
|
public AudioClip _deathSound;
|
||||||
|
public AudioClip _hitSound;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_animator = GetComponent<Animator>(); // 애니메이터 컴포넌트 초기화
|
_animator = GetComponent<Animator>(); // 애니메이터 컴포넌트 초기화
|
||||||
@@ -129,6 +133,8 @@ namespace TON
|
|||||||
float prevHP = currentHP; // 몬스터의 체력을 감소시키고, 죽었을 경우 파괴 처리
|
float prevHP = currentHP; // 몬스터의 체력을 감소시키고, 죽었을 경우 파괴 처리
|
||||||
currentHP -= damage;
|
currentHP -= damage;
|
||||||
|
|
||||||
|
SoundManager.instance.SFXPlay("Hit", _hitSound);
|
||||||
|
|
||||||
UpdateHPBar(currentHP);
|
UpdateHPBar(currentHP);
|
||||||
|
|
||||||
if (prevHP > 0 && currentHP <= 0)
|
if (prevHP > 0 && currentHP <= 0)
|
||||||
@@ -180,6 +186,7 @@ namespace TON
|
|||||||
|
|
||||||
_characterBase.ApplyDamage(damage);
|
_characterBase.ApplyDamage(damage);
|
||||||
|
|
||||||
|
SoundManager.instance.SFXPlay("Attack", _attackSound);
|
||||||
// Debug.Log($" 몬스터 공격! 최종 데미지: {damage}"); // 데미지 출력
|
// Debug.Log($" 몬스터 공격! 최종 데미지: {damage}"); // 데미지 출력
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +225,7 @@ namespace TON
|
|||||||
public void DestroyMonster()
|
public void DestroyMonster()
|
||||||
{
|
{
|
||||||
RewardData();
|
RewardData();
|
||||||
|
SoundManager.instance.SFXPlay("Death", _deathSound);
|
||||||
Destroy(gameObject); // 몬스터 파괴
|
Destroy(gameObject); // 몬스터 파괴
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
Gameton-06/Assets/Gameton/Scripts/Sound.meta
Normal file
8
Gameton-06/Assets/Gameton/Scripts/Sound.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e16344df7c8f56b4095502fb077d9f83
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
35
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs
Normal file
35
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace TON
|
||||||
|
{
|
||||||
|
public class SoundManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static SoundManager instance;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
DontDestroyOnLoad(instance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SFXPlay(string sfxName, AudioClip clip)
|
||||||
|
{
|
||||||
|
GameObject go = new GameObject(sfxName + "Sound");
|
||||||
|
AudioSource audiosource = go.AddComponent<AudioSource>();
|
||||||
|
|
||||||
|
audiosource.clip = clip;
|
||||||
|
audiosource.Play();
|
||||||
|
|
||||||
|
Destroy(go, clip.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs.meta
Normal file
11
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 023ac119be3a3d24c816494653c341dc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user