//산탄(5번, "00000005") 스킬과 속사(6번, "00000006") 스킬을 통합한 것 private void _Skill_NORMAL_ATK_00(Transform attacker, SkillBaseStat whichSkill, bool isUnitUsingThis) { Vector2 valueVec2 = Rotation_Math.Rotation_AND_Position(attacker.rotation, 0.58f, 0.0f); float posX = attacker.position.x; float posZ = attacker.position.z; //나중엔 int indexMax = whichSkill.ammoAmount; int indexMax = (int)(whichSkill.__GET_Skill_Rate); int posHelper = -1; //산탄 스킬이면 1, 속사스킬이면 -1 int isShotGun_OR_FastGun = 1; //보정된 x, z 좌표값 float newX; float newZ; //일단 지정된 attacker(캐릭터의 전면부)에서 3개의 기본 탄환을 서로 각 사선에 평행하도록 발사할 것. //탄환을 몇 개 발사할 것인지는 나중에 SkillBaseStat에서 읽어올 것 //일단 3개니까 이렇게 작성할 것 //본 함수의 0.58f와 1.16f, 이 두 수치에 대해서는 나중에 namespace ConstValueCollection에서 const float spawnDist 변수를 만들어서 관리할 것 //indexMax 값 변형 -> 홀수여야만 정상작동 indexMax = (indexMax - 1) / 2; //속사 스킬이면 if (whichSkill.__Get_Skill_ID == "00000006") { //속사 스킬의 경우, 앞에서 발사하는 경우 좌표 값 보정 예시 (탄환 개수가 최대 3개일때, 보정해야 되는 지점) //_unit_Combat_Engine.Default_ATK(ref attacker, new Vector3(posX + valueVec2.y, attacker.position.y, posZ + valueVec2.x), attacker.rotation, whichSkill); //_unit_Combat_Engine.Default_ATK(ref attacker, new Vector3(posX - valueVec2.y, attacker.position.y, posZ - valueVec2.x), attacker.rotation, whichSkill); //값을 바꿔치기 해서 위의 보정 예시가 아래 반복문에서 적용되도록 한다. valueVec2.Set(valueVec2.y, valueVec2.x); //z 좌표 보정 수식의 부호를 바꿔준다. isShotGun_OR_FastGun = -1; } //산탄 스킬의 경우, 앞에서 발사하는 경우 좌표 값 보정 예시 (탄환 개수가 최대 3개일 때, 보정해야 되는 지점) //_unit_Combat_Engine.Default_ATK(ref attacker, new Vector3(posX + valueVec2.x, attacker.position.y, posZ - valueVec2.y), attacker.rotation, whichSkill); //_unit_Combat_Engine.Default_ATK(ref attacker, new Vector3(posX - valueVec2.x, attacker.position.y, posZ + valueVec2.y), attacker.rotation, whichSkill); //음수부터 반복문을 돌린다 for (int index = -indexMax; index < indexMax + 1; index++) { //x, z 좌표값 보정 newX = posX - (valueVec2.x * posHelper * index); //속사 (6번, "00000006")스킬인 경우 //newZ = posZ - (valueVec.y * posHelper * index)가 된다 (isShotGun_OR_FastGun == -1) newZ = posZ + (valueVec2.y * posHelper * index) * isShotGun_OR_FastGun; _unit_Combat_Engine.Default_ATK(ref attacker, new Vector3(newX, attacker.position.y, newZ), attacker.rotation, whichSkill); posHelper *= (-1); } }
public int GetAngleComp(Transform enemy, Transform destiTrn) { //두 지점 사이의 각도 구하기 (도달해야 되는 각도 => 목표 각도) //일단 플레이어를 향하는 각도를 구한다. float _destiAngle = Mathf.Atan2(destiTrn.position.x - enemy.position.x, destiTrn.position.z - enemy.position.z) * Mathf.Rad2Deg; //어떤 방향으로 돌아야 목표 각도에 빠르게 도달할 수 있는지를 계산하기 위한 변수들 => dir값을 1 또는 -1로 결정 //현재 Enemy가 바라보고 있는 방향의 각도를 구한다. //curAngle은 0 <= curAgnle < 360 (destiAngle은 -180 < destiAngle <= 180)이기 떄문에 curAngle > 180인 경우 curAngle 값을 보정하도록 한다. //curAngle도 -180 < curAngle <= 180으로 변경한다. float curAngle = Rotation_Math.Angle360_TO_Angle180(enemy.rotation.eulerAngles.y); //float destiAngle_FOR_dir = 0.0f; float dirAngle; int dir = 1; //방향 계산을 위해 값을 그대로 가져온다. dirAngle = _destiAngle; //destiAngle_FOR_dir와 curAngle의 부호가 다른 경우 if ((dirAngle < 0 && curAngle >= 0) || (dirAngle >= 0 && curAngle < 0)) { //destiAngle_FOR_dir의 반대방향으로 계산하도록 조정한다. dirAngle = Rotation_Math.Get_Opposite_Direction_Angle(dirAngle); //dir값을 보정한다. dir *= (-1); } //dir값을 결정한다. //각도 차를 구하여 시계방향으로 돌지 반시계방향으로 돌지 결정한다. (1이 시계 방향) if (!(GET_RotataionDir(curAngle, dirAngle))) { dir *= (-1); } //목표 각도를 Quaternion으로 바꿔준다. destiQT = Quaternion.Euler(0, _destiAngle, 0); //호출될 때마다 목표 각도와 현재 각도 차 구하기 angleComp = Quaternion.Angle(enemy.rotation, destiQT) * dir; return(dir); }