효과음 겹치는 문제 수정을 위해 효과음 재생중일때 효과음이 재생되지 않도록 수정

This commit is contained in:
Mingu Kim
2025-06-28 01:09:22 +09:00
parent 02dbaae8d1
commit 8d0e2ee53e
5 changed files with 89 additions and 85 deletions

View File

@@ -24,77 +24,4 @@ namespace TON
{
}
}
public class Monster1AttackPattern : AttackPattern
{
public Monster1AttackPattern(MonsterBase monsterBase) : base(monsterBase)
{
}
public override void Attack()
{
if (Time.time >= _lastSkillTime + _skill1Cooldown)
{
Skill1();
_lastSkillTime = Time.time;
}
else
{
MeleeAttack();
}
}
private void Skill1()
{
_monsterBase.MonsterSkillLaunch();
}
private void MeleeAttack()
{
_monsterBase.PlayerAttack();
}
}
public class Monster2AttackPattern : AttackPattern
{
private float _lastSkill2Time;
public Monster2AttackPattern(MonsterBase monsterBase) : base(monsterBase)
{
_lastSkill2Time = -_skill2Cooldown;
}
public override void Attack()
{
if (Time.time >= _lastSkillTime + _skill1Cooldown)
{
Skill1();
_lastSkillTime = Time.time;
}
else if (Time.time >= _lastSkill2Time + _skill2Cooldown)
{
Skill2();
_lastSkill2Time = Time.time;
}
else
{
MeleeAttack();
}
}
private void Skill1()
{
_monsterBase.MonsterSkillLaunch(1); // 스킬 1 발사
}
private void Skill2()
{
_monsterBase.MonsterSkillLaunch(2); // 스킬 2 발사
}
private void MeleeAttack()
{
_monsterBase.PlayerAttack();
}
}
}

View File

@@ -38,7 +38,7 @@ namespace TON
private CharacterBase _characterBase;
// public AudioClip _attackSound;
public AudioClip _attackSound;
public AudioClip _deathSound;
public AudioClip _hitSound;
@@ -135,7 +135,6 @@ namespace TON
if (prevHP > 0 && currentHP <= 0)
{
_stateMachine.SetTransition(new DeathState());
//TODO : 현재 웨이브 값, 경험치, 골드 MonsterSpawner.WaveData;
}
else if (prevHP > 0 && currentHP > 0)
{
@@ -167,7 +166,7 @@ namespace TON
}
}
public void Attack(GameObject player)
public void Attack(CharacterBase player)
{
// 데미지 계산 (현재 임시 값)
DamageCalculator damageCalculator = new DamageCalculator();
@@ -181,13 +180,17 @@ namespace TON
_characterBase.ApplyDamage(damage);
// SoundManager.instance.SFXPlay("Attack", _attackSound);
if (player != null)
{
SoundManager.instance.SFXPlay("Attack", _attackSound);
}
// Debug.Log($" 몬스터 공격! 최종 데미지: {damage}"); // 데미지 출력
}
public void PlayerAttack()
{
var target = GameObject.FindGameObjectWithTag("Player");
var target = GameObject.Find("TON.Player").GetComponentInChildren<CharacterBase>();
Attack(target);
}