public static float DistanceH(Vector3 v1, PB.vector3 v2) { if (v2 == null) { return(0); } return((float)Math.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.z - v2.z) * (v1.z - v2.z))); }

/// <summary> /// 后端增加了PB.vector3和Vector3之间的类型转换操作符，不必再使用该函数 /// </summary> /// <param name="pos"></param> /// <returns></returns> public static PB.vector3 ChangeVector3ToPbVec(Vector3 pos) { PB.vector3 _PbPos = new PB.vector3(); _PbPos.x = pos.x; _PbPos.y = pos.y; _PbPos.z = pos.z; return(_PbPos); }

public static void SetPbVector3(PB.vector3 v, Vector3 pos) { if (v == null) { return; } v.x = pos.x; v.y = pos.y; v.z = pos.z; }

/// <summary> /// 后端增加了PB.vector3和Vector3之间的类型转换操作符，不必再使用该函数 /// </summary> /// <param name="pbpos"></param> /// <returns></returns> public static Vector3 ChangePbVecToVector3(PB.vector3 pbpos) { var pos = Vector3.zero; if (pbpos == null) { return(pos); } pos.Set(pbpos.x, pbpos.y, pbpos.z); return(pos); }

public static PB.vector3[] ChangeVector2ListToPbVec3List(Vector2[] pos) { int len = pos.Length; PB.vector3[] pbArray = new PB.vector3[len]; for (int i = 0; i < len; ++i) { pbArray[i].x = pos[i].x; pbArray[i].y = 0; pbArray[i].z = pos[i].y; } return(pbArray); }

public static bool ValidParamVector3(PB.vector3 v) { if (!ValidParamFloat(v.x)) { return(false); } if (!ValidParamFloat(v.y)) { return(false); } if (!ValidParamFloat(v.z)) { return(false); } return(true); }