몬스터 스킬 코드 복구 누락파일
This commit is contained in:
100
Gameton-06/Assets/Gameton/Scripts/Monster/AttackPattern.cs
Normal file
100
Gameton-06/Assets/Gameton/Scripts/Monster/AttackPattern.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class AttackPattern
|
||||
{
|
||||
protected MonsterBase _monsterBase;
|
||||
protected float _lastSkillTime;
|
||||
protected float _skill1Cooldown = 5f;
|
||||
protected float _skill2Cooldown = 8f;
|
||||
|
||||
public AttackPattern(MonsterBase monsterBase)
|
||||
{
|
||||
_monsterBase = monsterBase;
|
||||
// 쿨다운 값을 MonsterData에서 가져오기
|
||||
_skill1Cooldown = _monsterBase.GetSkillCooldown(1);
|
||||
_skill2Cooldown = _monsterBase.GetSkillCooldown(2);
|
||||
_lastSkillTime = -_skill1Cooldown;
|
||||
}
|
||||
|
||||
public virtual void Attack()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user