MonsterBase 및 StateMachine 코드 정리
This commit is contained in:
@@ -210,7 +210,7 @@ AnimationClip:
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events:
|
||||
- time: 0.5
|
||||
- time: 0.48333332
|
||||
functionName: FinishAttack
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
[
|
||||
{
|
||||
"skillId": "001",
|
||||
"skillName": "얼음 공격",
|
||||
"skillId": 0,
|
||||
"skillName": "IceBlast",
|
||||
"damage": 50,
|
||||
"cooldown": 5,
|
||||
"range": 5,
|
||||
"animationName": "IceBlast"
|
||||
"prefabName": "IceBlastPrefab"
|
||||
},
|
||||
{
|
||||
"skillId": "002",
|
||||
"skillName": "화염구",
|
||||
"skillId": 1,
|
||||
"skillName": "SmallFire",
|
||||
"damage": 50,
|
||||
"cooldown": 5,
|
||||
"range": 5,
|
||||
"animationName": "SmallFire"
|
||||
"prefabName": "smallFirePrefab"
|
||||
}
|
||||
]
|
||||
@@ -1,12 +1,28 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"id": 0,
|
||||
"name": "blueDragon",
|
||||
"level": 1,
|
||||
"hp": 10,
|
||||
"attackPower": 35,
|
||||
"defencePower": 36,
|
||||
"monsterSkillID": "001",
|
||||
"monsterSkillID": 0,
|
||||
"monsterSkillIDTwo": 1,
|
||||
"patrolRange": 1,
|
||||
"detectionRange": 1,
|
||||
"chaseRange": 1,
|
||||
"moveSpeed": 1,
|
||||
"attackRange": 1
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "greenDragon",
|
||||
"level": 1,
|
||||
"hp": 10,
|
||||
"attackPower": 35,
|
||||
"defencePower": 36,
|
||||
"monsterSkillID": 0,
|
||||
"monsterSkillIDTwo": 1,
|
||||
"patrolRange": 1,
|
||||
"detectionRange": 1,
|
||||
"chaseRange": 1,
|
||||
@@ -15,26 +31,13 @@
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "greenDragon",
|
||||
"level": 1,
|
||||
"hp": 10,
|
||||
"attackPower": 35,
|
||||
"defencePower": 36,
|
||||
"monsterSkillID": "001",
|
||||
"patrolRange": 1,
|
||||
"detectionRange": 1,
|
||||
"chaseRange": 1,
|
||||
"moveSpeed": 1,
|
||||
"attackRange": 1
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "redDragon",
|
||||
"level": 1,
|
||||
"hp": 10,
|
||||
"attackPower": 35,
|
||||
"defencePower": 36,
|
||||
"monsterSkillID": "001",
|
||||
"monsterSkillID": 0,
|
||||
"monsterSkillIDTwo": 1,
|
||||
"patrolRange": 1,
|
||||
"detectionRange": 1,
|
||||
"chaseRange": 1,
|
||||
|
||||
@@ -6181,27 +6181,11 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
id: 0
|
||||
monsterName:
|
||||
level: 0
|
||||
currentHP: 0
|
||||
attackPower: 0
|
||||
defencePower: 10
|
||||
monsterSkillID: 0
|
||||
patrolRange: 0
|
||||
detectionRange: 0
|
||||
chaseRange: 0
|
||||
speed: 3
|
||||
attackRange: 0
|
||||
_spriteRenderer: {fileID: 135546803}
|
||||
_target: {fileID: 0}
|
||||
_collider: {fileID: 0}
|
||||
_hpBarImage: {fileID: 0}
|
||||
skillId: 0
|
||||
skillName:
|
||||
damage: 0
|
||||
cooldown: 0
|
||||
range: 0
|
||||
animationName:
|
||||
smallFirePrefab: {fileID: 0}
|
||||
DragonBreathPrefab: {fileID: 0}
|
||||
IceBlastPrefab: {fileID: 0}
|
||||
@@ -6213,7 +6197,6 @@ MonoBehaviour:
|
||||
WolfPunchPrefab: {fileID: 0}
|
||||
DragonShockWavePrefab: {fileID: 0}
|
||||
FireImpactPrefab: {fileID: 0}
|
||||
DropObjectPrefab: {fileID: 0}
|
||||
--- !u!4 &141676838 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 866829735663616565, guid: 1e126f96ebcf4245a3328353992d46f6, type: 3}
|
||||
@@ -17731,27 +17714,11 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
id: 0
|
||||
monsterName:
|
||||
level: 0
|
||||
currentHP: 0
|
||||
attackPower: 0
|
||||
defencePower: 10
|
||||
monsterSkillID: 0
|
||||
patrolRange: 0
|
||||
detectionRange: 0
|
||||
chaseRange: 0
|
||||
speed: 3
|
||||
attackRange: 0
|
||||
_spriteRenderer: {fileID: 431020305}
|
||||
_target: {fileID: 1333310376}
|
||||
_collider: {fileID: 2147245667}
|
||||
_hpBarImage: {fileID: 309509381}
|
||||
skillId: 0
|
||||
skillName:
|
||||
damage: 0
|
||||
cooldown: 0
|
||||
range: 0
|
||||
animationName:
|
||||
smallFirePrefab: {fileID: 4487626989189845864, guid: 0cc74a53f6c5c944b86daaa75d4bc576, type: 3}
|
||||
DragonBreathPrefab: {fileID: 1270587839958746621, guid: a7b411323f70c6c4db9d2cab98824bd2, type: 3}
|
||||
IceBlastPrefab: {fileID: 5091201270221039787, guid: e0e47ef64af779949aef813fbc15f1b5, type: 3}
|
||||
@@ -17763,7 +17730,6 @@ MonoBehaviour:
|
||||
WolfPunchPrefab: {fileID: 123878659603861660, guid: bdee23ac65f6d2b4bafefc94600190c8, type: 3}
|
||||
DragonShockWavePrefab: {fileID: 3715909542404085769, guid: 358f073558c5daa4185d8950938ae415, type: 3}
|
||||
FireImpactPrefab: {fileID: 6470166121172466421, guid: b12ab214fbad9a449bc80119f185111e, type: 3}
|
||||
DropObjectPrefab: {fileID: 5413697641276301969, guid: 82350566434da384cb94c1c2624dbeae, type: 3}
|
||||
--- !u!95 &431020300
|
||||
Animator:
|
||||
serializedVersion: 5
|
||||
@@ -47902,67 +47868,6 @@ Sprite:
|
||||
m_PhysicsShape: []
|
||||
m_Bones: []
|
||||
m_SpriteID:
|
||||
--- !u!1001 &1205629222
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 705413505888271155, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: _spriteRenderer
|
||||
value:
|
||||
objectReference: {fileID: 1862079974}
|
||||
- target: {fileID: 4336427122757065448, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: RedRex
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 12.868645
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -7.968115
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0.060982164
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8864163214463241537, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
--- !u!114 &1207338009
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -48956,27 +48861,11 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
id: 0
|
||||
monsterName:
|
||||
level: 0
|
||||
currentHP: 0
|
||||
attackPower: 0
|
||||
defencePower: 10
|
||||
monsterSkillID: 0
|
||||
patrolRange: 0
|
||||
detectionRange: 0
|
||||
chaseRange: 0
|
||||
speed: 3
|
||||
attackRange: 0
|
||||
_spriteRenderer: {fileID: 1254298208}
|
||||
_target: {fileID: 1333310376}
|
||||
_collider: {fileID: 199081697}
|
||||
_hpBarImage: {fileID: 0}
|
||||
skillId: 0
|
||||
skillName:
|
||||
damage: 0
|
||||
cooldown: 0
|
||||
range: 0
|
||||
animationName:
|
||||
smallFirePrefab: {fileID: 0}
|
||||
DragonBreathPrefab: {fileID: 0}
|
||||
IceBlastPrefab: {fileID: 0}
|
||||
@@ -48988,7 +48877,6 @@ MonoBehaviour:
|
||||
WolfPunchPrefab: {fileID: 0}
|
||||
DragonShockWavePrefab: {fileID: 0}
|
||||
FireImpactPrefab: {fileID: 0}
|
||||
DropObjectPrefab: {fileID: 0}
|
||||
--- !u!95 &1254298203
|
||||
Animator:
|
||||
serializedVersion: 5
|
||||
@@ -68411,11 +68299,6 @@ MonoBehaviour:
|
||||
m_InstancedGameObject: {fileID: 0}
|
||||
m_Flags: 3
|
||||
m_ColliderType: 1
|
||||
--- !u!212 &1862079974 stripped
|
||||
SpriteRenderer:
|
||||
m_CorrespondingSourceObject: {fileID: 7017725869417428001, guid: 69c66b62d5d42aa48b34c97c6131188f, type: 3}
|
||||
m_PrefabInstance: {fileID: 1205629222}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!213 &1869212074
|
||||
Sprite:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -73928,27 +73811,11 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
id: 0
|
||||
monsterName:
|
||||
level: 0
|
||||
currentHP: 0
|
||||
attackPower: 0
|
||||
defencePower: 10
|
||||
monsterSkillID: 0
|
||||
patrolRange: 0
|
||||
detectionRange: 0
|
||||
chaseRange: 0
|
||||
speed: 3
|
||||
attackRange: 0
|
||||
_spriteRenderer: {fileID: 2041544010}
|
||||
_target: {fileID: 1333310376}
|
||||
_collider: {fileID: 483107484}
|
||||
_hpBarImage: {fileID: 0}
|
||||
skillId: 0
|
||||
skillName:
|
||||
damage: 0
|
||||
cooldown: 0
|
||||
range: 0
|
||||
animationName:
|
||||
smallFirePrefab: {fileID: 0}
|
||||
DragonBreathPrefab: {fileID: 0}
|
||||
IceBlastPrefab: {fileID: 0}
|
||||
@@ -73960,7 +73827,6 @@ MonoBehaviour:
|
||||
WolfPunchPrefab: {fileID: 0}
|
||||
DragonShockWavePrefab: {fileID: 0}
|
||||
FireImpactPrefab: {fileID: 0}
|
||||
DropObjectPrefab: {fileID: 0}
|
||||
--- !u!95 &2041544005
|
||||
Animator:
|
||||
serializedVersion: 5
|
||||
@@ -77831,4 +77697,3 @@ SceneRoots:
|
||||
- {fileID: 6994367162197659328}
|
||||
- {fileID: 9115962474533691980}
|
||||
- {fileID: 1043803241}
|
||||
- {fileID: 1205629222}
|
||||
|
||||
@@ -21,8 +21,10 @@ namespace TON
|
||||
public int attackPower;
|
||||
// 기본 방어력
|
||||
public int defencePower;
|
||||
// 몬스터 스킬 ID
|
||||
// 몬스터 스킬 ID 1
|
||||
public int monsterSkillID;
|
||||
// 몬스터 스킬 ID 2
|
||||
public int monsterSkillIDTwo;
|
||||
// 패트롤 범위
|
||||
public float patrolRange;
|
||||
// 인식 범위
|
||||
|
||||
@@ -12,6 +12,6 @@ namespace TON
|
||||
public float damage; // 스킬 데미지
|
||||
public float cooldown; // 스킬 쿨다운
|
||||
public float range; // 스킬 범위
|
||||
public string animationName; // 스킬 애니메이션 이름
|
||||
public string prefabName; // 스킬 프리팹 이름
|
||||
}
|
||||
}
|
||||
@@ -18,22 +18,6 @@ namespace TON
|
||||
// _monsterBase.SetTransition(new AttackState());
|
||||
// _monsterBase.SetTransition(new MonsterSkillState());
|
||||
}
|
||||
|
||||
// if (!_monsterBase.monsterSkillID)
|
||||
// {
|
||||
// if (other.CompareTag("Player"))
|
||||
// {
|
||||
// // 일정 확률로 스킬 사용
|
||||
// if (Random.value < 0.3f) // 30% 확률
|
||||
// {
|
||||
// _monsterBase.SetTransition(new SkillState());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _monsterBase.SetTransition(new AttackState());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
@@ -41,7 +25,7 @@ namespace TON
|
||||
_monsterBase.IsAttacking = false;
|
||||
// _monsterBase.SetTransition(new ChasingState());
|
||||
|
||||
Debug.Log("감지 벗어남");
|
||||
// Debug.Log("감지 벗어남");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,51 +14,28 @@ using Vector3 = UnityEngine.Vector3;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
// public class AttackPattern
|
||||
// {
|
||||
// public void Attack()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class Monster1AttackManager : AttackPattern
|
||||
// {
|
||||
// public override void Attack()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class Monster2AttackManager : AttackPattern
|
||||
// {
|
||||
// public override void Attack();
|
||||
// }
|
||||
|
||||
public class MonsterBase : MonoBehaviour, IDamage
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
public int id; // 몬스터의 ID
|
||||
public string monsterName; // 몬스터 이름
|
||||
public int level;
|
||||
public float currentHP = 100; // 몬스터의 현재 체력
|
||||
public int attackPower; // 공격력
|
||||
public float defencePower; // 몬스터의 방어력
|
||||
public int monsterSkillID;
|
||||
public float patrolRange;
|
||||
public float detectionRange;
|
||||
public float chaseRange;
|
||||
public float speed = 2; // 몬스터의 이동 속도
|
||||
public float attackRange;
|
||||
public float defencePower;
|
||||
|
||||
[SerializeField] private SpriteRenderer _spriteRenderer; // 몬스터의 스프라이트 렌더러
|
||||
|
||||
private MonsterData _monsterData;
|
||||
private MonsterSkillData _monsterSkillData;
|
||||
private MonsterSkillData _monsterSkillDataTwo;
|
||||
private Animator _animator; // 몬스터 애니메이터
|
||||
|
||||
StateMachine _stateMachine;
|
||||
|
||||
private AttackPattern _attackPattern;
|
||||
|
||||
private Vector3 _direction; // 몬스터의 이동 방향
|
||||
public bool IsDetect { get; set; } // 몬스터가 대상을 인식했는지 여부
|
||||
public bool IsAttacking { get; set; } // 몬스터가 대상을 인식했는지 여부
|
||||
public bool IsFisnishAttack { get; set; } // 몬스터가 대상을 인식했는지 여부
|
||||
public bool IsAttacking { get; set; } // 몬스터가 공격했는지 여부
|
||||
public bool IsFisnishAttack { get; set; } // 몬스터 공격 모션이 끝났는지 여부
|
||||
|
||||
[SerializeField] private GameObject _target; // 몬스터의 타겟
|
||||
|
||||
@@ -67,26 +44,12 @@ namespace TON
|
||||
// 애니메이션 관련 선언
|
||||
private string currentAnimationState; // 현재 애니메이션 상태
|
||||
|
||||
StateMachine _stateMachine;
|
||||
|
||||
// 추적 관련 선언
|
||||
private float _detectStartTime; // 추적 시작 시간
|
||||
private bool _isTracking; // 추적 중인지 여부
|
||||
|
||||
// hp바
|
||||
[SerializeField] private Image _hpBarImage; // HP 바 이미지
|
||||
private float _maxHP;
|
||||
private float currentHP;
|
||||
|
||||
// private AttackPattern _attackPatten;
|
||||
|
||||
// 스킬
|
||||
public int skillId; // 스킬 ID
|
||||
public string skillName; // 스킬 이름
|
||||
public float damage; // 스킬 데미지
|
||||
public float cooldown; // 스킬 쿨다운
|
||||
public float range; // 스킬 범위
|
||||
public string animationName; // 스킬 애니메이션 이름
|
||||
|
||||
// 몬스터 스킬 프리팹
|
||||
public GameObject smallFirePrefab;
|
||||
public GameObject DragonBreathPrefab;
|
||||
public GameObject IceBlastPrefab;
|
||||
@@ -98,59 +61,44 @@ namespace TON
|
||||
public GameObject WolfPunchPrefab;
|
||||
public GameObject DragonShockWavePrefab;
|
||||
public GameObject FireImpactPrefab;
|
||||
public GameObject DropObjectPrefab;
|
||||
|
||||
// 첫 번째 프레임 전에 호출됩니다.
|
||||
private void Start()
|
||||
{
|
||||
|
||||
// _attackPatten = new Monster1AttackManager();
|
||||
// _attackPatten = new Monster2AttackManager();
|
||||
// 전략 패턴
|
||||
_attackPattern = new Monster1AttackPattern();
|
||||
_attackPattern = new Monster2AttackPattern();
|
||||
|
||||
_animator = GetComponent<Animator>(); // 애니메이터 컴포넌트 초기화
|
||||
|
||||
_stateMachine = new StateMachine(new IdleState(), this);
|
||||
|
||||
// // 몬스터 데이터 로드 (테스트용, 첫 번째 몬스터 데이터만 로드)
|
||||
// MonsterData monsterData = MonsterDataManager.Singleton.monstersData[0];
|
||||
// Debug.Log(monsterData.name); // 몬스터 ID 출력
|
||||
|
||||
// 몬스터 데이터 로드 및 적용
|
||||
InitializeMonsterData();
|
||||
InitializeMonsterSkillData();
|
||||
|
||||
id = _monsterData.id;
|
||||
|
||||
_direction = new Vector3(1, 0, 0); // 초기 이동 방향 (x 축 양의 방향)
|
||||
|
||||
_spriteRenderer.flipX = !(_direction.x > 0); // 이동 방향에 따라 스프라이트 플립
|
||||
|
||||
_collider = GetComponent<Collider2D>(); // 콜라이더 컴포넌트 초기화
|
||||
|
||||
// 몬스터 방어력 임시값 설정
|
||||
defencePower = 10f;
|
||||
}
|
||||
|
||||
// TODO : 불러온 값 변수에 대응하게 수정
|
||||
private void InitializeMonsterData()
|
||||
{
|
||||
MonsterData monsterData = MonsterDataManager.Singleton.GetMonsterData(id);
|
||||
if (monsterData != null)
|
||||
{
|
||||
id = monsterData.id;
|
||||
monsterName = monsterData.name;
|
||||
level = monsterData.level;
|
||||
currentHP = monsterData.hp;
|
||||
defencePower = monsterData.defencePower;
|
||||
monsterSkillID = monsterData.monsterSkillID;;
|
||||
patrolRange = monsterData.patrolRange;
|
||||
detectionRange = monsterData.detectionRange;
|
||||
chaseRange = monsterData.chaseRange;
|
||||
speed = monsterData.moveSpeed;
|
||||
attackPower = monsterData.attackPower;
|
||||
_monsterData = MonsterDataManager.Singleton.GetMonsterData(id);
|
||||
|
||||
_maxHP = monsterData.hp;
|
||||
if (_monsterData != null)
|
||||
{
|
||||
_maxHP = _monsterData.hp;
|
||||
currentHP = _maxHP;
|
||||
|
||||
Debug.Log($"몬스터 {monsterData.name} 데이터 로드 완료");
|
||||
defencePower = _monsterData.defencePower;
|
||||
|
||||
Debug.Log($"몬스터 {_monsterData.name} 데이터 로드 완료");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -161,22 +109,22 @@ namespace TON
|
||||
// TODO : 불러온 값 변수에 대응하게 수정
|
||||
private void InitializeMonsterSkillData()
|
||||
{
|
||||
MonsterSkillData monsterSkillData = MonsterSkillDataManager.Singleton.GetMonsterSkillData(monsterSkillID);
|
||||
|
||||
if (monsterSkillData != null)
|
||||
_monsterSkillData = MonsterSkillDataManager.Singleton.GetMonsterSkillData(_monsterData.monsterSkillID);
|
||||
if (_monsterData.monsterSkillIDTwo > -1)
|
||||
{
|
||||
skillId = monsterSkillData.skillId;
|
||||
skillName = monsterSkillData.skillName;
|
||||
damage = monsterSkillData.damage;
|
||||
cooldown = monsterSkillData.cooldown;
|
||||
range = monsterSkillData.range;
|
||||
animationName = monsterSkillData.animationName;
|
||||
_monsterSkillDataTwo = MonsterSkillDataManager.Singleton.GetMonsterSkillData(_monsterData.monsterSkillIDTwo);
|
||||
}
|
||||
|
||||
Debug.Log($"몬스터 {monsterSkillData.skillName} 데이터 로드 완료");
|
||||
if (_monsterSkillData != null && _monsterSkillDataTwo != null)
|
||||
{
|
||||
|
||||
Debug.Log($"몬스터 {_monsterSkillData.skillName} 데이터 로드 완료");
|
||||
Debug.Log($"몬스터 {_monsterSkillDataTwo.skillName} 데이터 로드 완료");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"몬스터 스킬 ID {id}에 대한 데이터를 찾을 수 없습니다.");
|
||||
Debug.LogError($"몬스터 스킬 ID {_monsterSkillData.skillId}에 대한 데이터를 찾을 수 없습니다.");
|
||||
Debug.LogError($"몬스터 스킬 ID {_monsterSkillDataTwo.skillId}에 대한 데이터를 찾을 수 없습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,9 +189,9 @@ namespace TON
|
||||
// 데미지 계산 (현재 임시 값)
|
||||
DamageCalculator damageCalculator = new DamageCalculator();
|
||||
|
||||
float baseAttack = 30f; // 기본 공격력
|
||||
float equipmentAttack = 10f; // 장비 공격력
|
||||
float defense = 0.1f; // 방어력 비율
|
||||
float baseAttack = _monsterData.attackPower; // 기본 공격력
|
||||
float equipmentAttack = 0; // 장비 공격력
|
||||
float defense = _monsterData.defencePower; // 방어력 비율
|
||||
|
||||
// 기본 데미지 계산 (치명타 없음)
|
||||
float damage = damageCalculator.CalculateBaseDamage(baseAttack, equipmentAttack, defense);
|
||||
@@ -265,7 +213,7 @@ namespace TON
|
||||
|
||||
public void Move()
|
||||
{
|
||||
transform.Translate(_direction * speed * Time.deltaTime); // 몬스터를 이동시킴
|
||||
transform.Translate(_direction * _monsterData.moveSpeed * Time.deltaTime); // 몬스터를 이동시킴
|
||||
}
|
||||
|
||||
public void Chasing()
|
||||
@@ -275,7 +223,7 @@ namespace TON
|
||||
// 타겟이 왼쪽에 있으면 스프라이트를 왼쪽으로, 오른쪽에 있으면 오른쪽으로 바라보도록 설정
|
||||
_spriteRenderer.flipX = target.transform.position.x < transform.position.x;
|
||||
|
||||
transform.Translate(direction.normalized * speed * Time.deltaTime); // 타겟 방향으로 이동
|
||||
transform.Translate(direction.normalized * _monsterData.moveSpeed * Time.deltaTime); // 타겟 방향으로 이동
|
||||
}
|
||||
|
||||
public void MonsterSkillLaunch()
|
||||
@@ -295,7 +243,6 @@ namespace TON
|
||||
// GameObject newSkill = Instantiate(WolfPunchPrefab);
|
||||
// GameObject newSkill = Instantiate(DragonShockWavePrefab);
|
||||
// GameObject newSkill = Instantiate(FireImpactPrefab);
|
||||
// GameObject newSkill = Instantiate(DropObjectPrefab);
|
||||
|
||||
|
||||
newSkill.transform.position = transform.position + new Vector3(0, 1f, 0);
|
||||
|
||||
@@ -33,8 +33,6 @@ namespace TON
|
||||
private void SetTransition(IState state)
|
||||
{
|
||||
// 다음음 상태로 전환
|
||||
|
||||
|
||||
_state = state;
|
||||
_state.Enter(_monsterBase);
|
||||
|
||||
@@ -68,7 +66,7 @@ namespace TON
|
||||
private int _walkingTime = 2; // 걷기 시간
|
||||
|
||||
private float _duration = 2;
|
||||
private float _currentDuration = 2;
|
||||
private float _currentDuration;
|
||||
|
||||
|
||||
public void Enter(MonsterBase monsterBase)
|
||||
@@ -112,7 +110,7 @@ namespace TON
|
||||
}
|
||||
}
|
||||
|
||||
_currentDuration += Time.realtimeSinceStartup;
|
||||
_currentDuration += Time.deltaTime;
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
@@ -122,13 +120,13 @@ namespace TON
|
||||
|
||||
public IState CheckTransition()
|
||||
{
|
||||
// TODO : duration을 동안에는 항상 idle = 공격 쿨타운
|
||||
// duration 동안에는 항상 idle = 공격 쿨타운
|
||||
if (_currentDuration < _duration)
|
||||
return this;
|
||||
// TODO : 데미지 받을 때
|
||||
|
||||
|
||||
// TODO : 추적 범위에 들어왔을 때
|
||||
// 추적 범위에 들어왔을 때
|
||||
if (_monsterBase.IsDetect)
|
||||
{
|
||||
return new ChasingState();
|
||||
@@ -169,8 +167,8 @@ namespace TON
|
||||
// Idle로 변경
|
||||
if(_monsterBase.IsDetect== false)
|
||||
return new IdleState();
|
||||
//
|
||||
// // Attack으로 변경
|
||||
|
||||
// Attack으로 변경
|
||||
if (_monsterBase.IsAttacking)
|
||||
return new AttackState();
|
||||
|
||||
@@ -180,13 +178,11 @@ namespace TON
|
||||
}
|
||||
}
|
||||
|
||||
// 몬스터 1의 어택
|
||||
// 몬스터 2의 어택
|
||||
// 몬스터 1의 어택(스킬 1개를 가진 중보스)
|
||||
// 몬스터 2의 어택(스킬 2개를 가진 보스)
|
||||
public class AttackState : IState
|
||||
{
|
||||
private const string AniAttack = "Attack"; // 공격 애니메이션
|
||||
private const string AniIdle = "Idle"; // 대기 애니메이션
|
||||
|
||||
private MonsterBase _monsterBase;
|
||||
private float _attackDelayTime = 2f; // 공격 딜레이 시간
|
||||
private float _lastAttackTime; // 마지막 공격 시간
|
||||
@@ -227,7 +223,6 @@ namespace TON
|
||||
{
|
||||
_monsterBase.ChangeAnimationState(AniAttack);
|
||||
_monsterBase.PlayerAttack();
|
||||
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
@@ -243,7 +238,7 @@ namespace TON
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO : HIT, Death 상태 추가
|
||||
public class MonsterSkillState : IState
|
||||
{
|
||||
private const string AniAttack = "Attack"; // 공격 애니메이션
|
||||
|
||||
Reference in New Issue
Block a user