/// <summary> /// 평타 프로젝타일 프로세스 /// </summary> /// <param name="spd"></param> /// <param name="index"></param> /// <returns></returns> private IEnumerator IE_MissileAttack(float spd, int index) { float subDistance; Vector3 dir; yield return(new WaitForEndOfFrame()); Transform misslie = _meleeProjectile[index]; misslie.transform.position = transform.position + Vector3.up; ITargetUnit tempTarget = targetUnit; //타겟 지정 MainManager.instance.Set_ActiveProjectile(_meleeProjectile[index].gameObject, true); //_meleeProjectile[index].gameObject.SetActive(true); do { if (tempTarget == null) { break; } subDistance = Vector3.Distance(tempTarget.Get_Position(), new Vector3(misslie.transform.position.x, tempTarget.Get_Position().y, misslie.transform.position.z)); dir = tempTarget.Get_Position() - new Vector3(misslie.transform.position.x, tempTarget.Get_Position().y, misslie.transform.position.z); dir.Normalize(); misslie.transform.Translate(dir * _speed * Time.deltaTime, Space.World); yield return(null); } while (subDistance >= 0.1f); if (tempTarget != null) { tempTarget.Set_Target(this); tempTarget.TakeDamage(_attackDamage); if (tempTarget.Check_IsDead()) { Add_Money(tempTarget.Get_TargetCredit()); } } MainManager.instance.Set_ActiveProjectile(misslie.gameObject, false); // _meleeProjectile[index].gameObject.SetActive(false); //_meleeProjectile.parent = _animator.transform; }
/// <summary> /// Animation Event - 공격 모션의 특정 프레임에서 데미지 전달을 시킵니다. /// </summary> public void AnimEvent_Attack() { //공격 상태가 아니라면 리턴 if (!_myState.Equals(PLAYER_STATE.ATTACK)) { return; } //중간에 대상 플레이어가 이탈한 경우 리턴 if (targetUnit == null) { return; } //근접공격 if (_meleeProjectile.Length == 0) { targetUnit.Set_Target(this); targetUnit.TakeDamage(_attackDamage); if (targetUnit.Check_IsDead()) { Add_Money(targetUnit.Get_TargetCredit()); } } //원거리 공격일 경우 등록해둔 밀리프로젝타일 풀을 돌려가며 사용한다. else { if (_meleeProjectile[meleeIndex].gameObject.activeInHierarchy) { StopCoroutine(meleeCoroutine[meleeIndex]); //StopCoroutine(IE_MissileAttack(45f, meleeIndex)); MainManager.instance.Set_ActiveProjectile(_meleeProjectile[meleeIndex].gameObject, false); //_meleeProjectile[meleeIndex].gameObject.SetActive(false); } meleeCoroutine[meleeIndex] = StartCoroutine(IE_MissileAttack(45f, meleeIndex)); meleeIndex++; if (meleeIndex == 3) { meleeIndex = 0; } } }