コード例 #1
0
    // 몬스터 센서링 수행 코루틴
    private IEnumerator FrontTargetCheckCoroutine(
        CMonsterAttack monsterAttack)
    {
        while (_monsterState.state == _checkState)
        {
            // 수평 방향으로 발포 감지 레이저를 발사함
            Vector2 endPos = new Vector2(
                _attackPoint.position.x -
                ((_monsterState._isRightDir) ? -_checkRange : _checkRange),
                _attackPoint.position.y);

            // 충돌 체크 디버그 레이저 발사
            Debug.DrawLine(_attackPoint.position, endPos, Color.green);

            // 라인 체크
            // Physics2D.Linecast(라인시작위치, 라인끝위치, 검출레이어)
            //RaycastHit2D hitInfo = Physics2D.Linecast(
            //_attackPoint.position, endPos, _monsterState._targetMask);

            RaycastHit2D hitInfo = Physics2D.Linecast(
                _attackPoint.position, endPos, _checkTarget);

            // 충돌체가 존재한다면
            if (hitInfo.collider != null)
            {
                // 공격 시작
                monsterAttack.AttackReady();
            }

            yield return(null); // Update 주기와 동일
        }
    }
コード例 #2
0
    public IEnumerator CircleAreaTargetCheckCoroutine(CMonsterAttack monsterAttack)
    {
        // 몬스터가 대기 상태라면 감시를 진행함
        while (_monsterState.state == _checkState)
        {
            float distance = Vector2.Distance(_attackPoint.position, _playerPos.position);

            //Debug.Log("player pos => " + _playerPos.position);

            if (distance < _checkRange)
            {
                // 공격 시작
                monsterAttack.AttackReady();
            }

            yield return(null);
        }
    }
コード例 #3
0
 void Awake()
 {
     _attack       = GetComponent <CMonsterAttack>();
     _navMeshAgent = GetComponent <NavMeshAgent>();
     _anim         = GetComponent <CPlayerAnimation>();
 }
コード例 #4
0
 void Awake()
 {
     _movement = GetComponent <CMonsterMovement>();
     _anim     = GetComponent <CMonsterAnimation>();
     _attack   = GetComponent <CMonsterAttack>();
 }
コード例 #5
0
 public void CircleAreaTargetChecker(CMonsterAttack monsterAttack)
 {
     StartCoroutine("CircleAreaTargetCheckCoroutine", monsterAttack);
 }
コード例 #6
0
 // 몬스터 센서링 가동
 public void FrontTargetChecker(CMonsterAttack monsterAttack)
 {
     StartCoroutine("FrontTargetCheckCoroutine", monsterAttack);
 }