public bool AdjustMovePosByCollision(Nr3DCharBase kChar, ref Vector2 vMovePos, bool bAlly) { if (Battle.BATTLE.m_bOnlyServerMove) { return(false); } if (kChar.GetCharController() == null) { return(false); } Vector2 b = Vector2.zero; bool result = false; for (int i = 1; i < 120; i++) { NkBattleChar nkBattleChar = this.m_arChar[i]; if (nkBattleChar != null) { Nr3DCharBase nr3DCharBase = nkBattleChar.Get3DChar(); if (!(nr3DCharBase.GetCharController() == null)) { if (nr3DCharBase.GetID() != kChar.GetID()) { if (bAlly || nr3DCharBase.GetParentBattleChar().Ally != kChar.GetParentBattleChar().Ally) { b = vMovePos - new Vector2(nr3DCharBase.GetParentBattleChar().GetCharPos().x, nr3DCharBase.GetParentBattleChar().GetCharPos().z); float num = Vector2.Distance(Vector2.zero, b); float num2 = kChar.GetParentBattleChar().GetCharHalfBound() + nr3DCharBase.GetParentBattleChar().GetCharHalfBound() - num; if (num2 >= 0f) { this.GetTurningPos(kChar, nr3DCharBase, ref vMovePos); result = true; } } } } } } return(result); }
public Nr3DCharBase GetCollisionChar(Nr3DCharBase kChar, Vector2 movepos) { if (kChar.GetCharController() == null) { return(null); } Vector3 vector = Vector3.zero; float num = -3.40282347E+38f; NkBattleChar nkBattleChar = null; NkBattleChar[] charArray = this.GetCharArray(); for (int i = 0; i < charArray.Length; i++) { NkBattleChar nkBattleChar2 = charArray[i]; if (nkBattleChar2 != null) { if (nkBattleChar2.GetBUID() != kChar.GetParentBattleChar().GetBUID()) { if (!(nkBattleChar2.Get3DChar().GetCharController() == null)) { vector = nkBattleChar2.Get3DChar().GetCharController().transform.position; float num2 = kChar.GetParentBattleChar().GetCharHalfBound() + nkBattleChar2.GetCharHalfBound(); float num3 = Vector2.Distance(movepos, new Vector2(vector.x, vector.z)); if (num3 <= num2 && num2 - num3 > num) { num = num2 - num3; nkBattleChar = nkBattleChar2; } } } } } if (nkBattleChar != null) { return(nkBattleChar.Get3DChar()); } return(null); }
public void GetTurningPos(Nr3DCharBase kChar, Nr3DCharBase k3DChar, ref Vector2 vMovePos) { float x = kChar.GetCharController().transform.position.x; float z = kChar.GetCharController().transform.position.z; float x2 = vMovePos.x; float y = vMovePos.y; Vector2 b = Vector2.zero; for (int i = 44; i < 180; i += 2) { double num = (double)i / 180.0 * 3.1414999961853027; float x3 = (float)Math.Cos(num) * (x2 - x) - (float)Math.Sin(num) * (y - z) + x; float y2 = (float)Math.Sin(num) * (x2 - x) + (float)Math.Cos(num) * (y - z) + z; b = new Vector2(x3, y2) - new Vector2(k3DChar.GetParentBattleChar().GetCharPos().x, k3DChar.GetParentBattleChar().GetCharPos().z); float num2 = Vector2.Distance(Vector2.zero, b); float num3 = kChar.GetParentBattleChar().GetCharHalfBound() + k3DChar.GetParentBattleChar().GetCharHalfBound() - num2; if (num3 < 0f) { vMovePos.x = x3; vMovePos.y = y2; return; } } }
public Vector2 ObstacleAvoidance(Nr3DCharBase kChar, Vector2 curPos, Vector2 dir) { if (kChar.GetCharController() == null) { return(Vector2.zero); } float num = 10f; float num2 = 3.40282347E+38f; Nr3DCharBase nr3DCharBase = null; Vector2 vector = Vector2.zero; NkBattleChar[] charArray = this.GetCharArray(); for (int i = 0; i < charArray.Length; i++) { NkBattleChar nkBattleChar = charArray[i]; if (nkBattleChar != null) { Nr3DCharBase nr3DCharBase2 = nkBattleChar.Get3DChar(); if (nkBattleChar.GetBUID() != kChar.GetParentBattleChar().GetBUID()) { if (!(nr3DCharBase2.GetCharController() == null)) { Vector2 pos = new Vector2(nr3DCharBase2.GetCharController().transform.position.x, nr3DCharBase2.GetCharController().transform.position.z); Vector2 vector2 = this.PointToLocalSpace(pos, dir, curPos); if (vector2.x >= 0f) { float num3 = kChar.GetParentBattleChar().GetCharHalfBound() + nr3DCharBase2.GetParentBattleChar().GetCharHalfBound(); if (Mathf.Abs(vector2.y) < num3) { float x = vector2.x; float y = vector2.y; float num4 = Mathf.Sqrt(num3 * num3 - y * y); float num5 = x - num4; if (num5 <= 0f) { num5 = x + num4; } if (num5 < num2) { num2 = num5; nr3DCharBase = nr3DCharBase2; vector = vector2; } } } } } } } Vector2 zero = Vector2.zero; if (nr3DCharBase != null) { float num6 = 1f + (num - vector.x) / num; zero.y = (nr3DCharBase.GetParentBattleChar().GetCharHalfBound() - vector.y) * num6; zero.x = (nr3DCharBase.GetParentBattleChar().GetCharHalfBound() - vector.x) * 0.2f; if (kChar.GetParentBattleChar().GetBUID() == 0) { Debug.Log("*** TYS : steering Force " + zero); Debug.Log("*** TYS : closestIntersectionObstacle " + nr3DCharBase.GetCharCode()); } } return(this.VectorToWorldSpace(zero, dir)); }