//대상 추적하기 void SearchTarget() { MoveUnit(); //추적할 대상이 없음 CUnit enemy = CGameManager.GetInstance().GetEnemy(this); if (enemy == null || !enemy.IsLive()) { if (mTarget == null) { SetStatus(UNIT_STATUS.US_MOVE); } else { if (mTarget.GetDistanceSq(this) > (mSight * mSight)) { mTarget = null; SetStatus(UNIT_STATUS.US_MOVE); } else { SetStatus(UNIT_STATUS.US_TRACE); } } return; } //대상이 있으면 추적으로 설정하기 mTarget = enemy; if (mTarget.GetDistanceSq(this) > (mSight * mSight)) { mTarget = null; SetStatus(UNIT_STATUS.US_MOVE); } else { mTargetPos = mTarget.GetPos(); mMoveDirection = mTargetPos - GetPos(); mMoveDirection.Normalize(); SetStatus(UNIT_STATUS.US_MOVE_TARGET); } }