몬스터 추격범위 추가, 플레이어 탐지 범위 리팩토링
This commit is contained in:
20
Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs
Normal file
20
Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class Attack : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private MonsterBase _monsterBase;
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
_monsterBase.Attack(other.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs.meta
Normal file
11
Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0913d8f50c531ce4585705c1366b8351
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs
Normal file
50
Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class Eyesight : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private MonsterBase _monsterBase;
|
||||
// private bool _isDetect;
|
||||
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
// TODO : 플레이어 감지하면 따라가기
|
||||
|
||||
_monsterBase.IsDetect = true;
|
||||
Debug.Log("감지됨");
|
||||
|
||||
if (_monsterBase.IsDetect)
|
||||
{
|
||||
_monsterBase.Detect(other.gameObject);
|
||||
|
||||
// _monsterBase.IsWalking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 단순 플레이어 태그 기준 따라가는 코드
|
||||
private void FixedUpdate()
|
||||
{
|
||||
// 타겟의 위치에서 내 현제 위치를 뺌
|
||||
// UnityEngine.Vector2 direction = target.transform.position - transform.position;
|
||||
|
||||
// 방향 * 속도 * 시간간격
|
||||
// transform.Translate(direction.normalized * speed * Time.deltaTime);
|
||||
// animator.SetBool("Iidle", true);
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
_monsterBase.IsDetect = false;
|
||||
_monsterBase.IsWalking = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs.meta
Normal file
11
Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eeefb865ea9d4749bbb4de3d1100f3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user