/// <summary> /// 根据路段类型 返回其路段的组件 /// </summary> /// <returns>The road segment.</returns> /// <param name="_type">_type.</param> private MissionRoadSegment M_getRoadSegment(EnumRoadSegment _type) { MissionRoadSegment targetSegment = null; switch (_type) { case EnumRoadSegment.Start: targetSegment = segments_start; break; case EnumRoadSegment.End: targetSegment = segments_end; break; case EnumRoadSegment.Middle_Line: targetSegment = segments_middle_line; break; case EnumRoadSegment.Middle_Left: targetSegment = segments_middle_left; break; case EnumRoadSegment.Middle_Right: targetSegment = segments_middle_right; break; } return(targetSegment); }
/// <summary> /// 根据类型 创建一个新的路段 起始或结束路段 /// </summary> /// <param name="_targetSegment">_target segment.</param> private void M_creatSegment_StartEnd(MissionRoadSegment _targetSegment) { UIUtils.M_addChild(segment_parent, _targetSegment.transform); _targetSegment.gameObject.SetActive(true); _targetSegment.transform.localPosition = lastPostion; _targetSegment.transform.localRotation = Quaternion.Euler(lastRotatioin); }
/// <summary> /// 创建一个指定类型的路段 /// </summary> /// <param name="_type">_type.</param> private void M_creatSegment(EnumRoadSegment _type) { Transform newSegment_transform = null; MissionRoadSegment targetSegment = null; float point_x; float point_z; switch (_type) { case EnumRoadSegment.Start: { targetSegment = segments_start; M_creatSegment_StartEnd(targetSegment); } break; case EnumRoadSegment.End: { targetSegment = segments_end; M_creatSegment_StartEnd(targetSegment); } break; case EnumRoadSegment.Middle_Line: { targetSegment = segments_middle_line; newSegment_transform = M_creatSegment_Middle(_type, targetSegment.gameObject); newSegment_transform.localPosition = lastPostion; newSegment_transform.localRotation = Quaternion.Euler(lastRotatioin); targetSegment = newSegment_transform.GetComponent <MissionRoadSegment>(); } break; case EnumRoadSegment.Middle_Left: { targetSegment = segments_middle_left; newSegment_transform = M_creatSegment_Middle(_type, targetSegment.gameObject); newSegment_transform.localPosition = lastPostion; lastRotatioin += new Vector3(0, -90, 0); newSegment_transform.localRotation = Quaternion.Euler(lastRotatioin); targetSegment = newSegment_transform.GetComponent <MissionRoadSegment>(); } break; case EnumRoadSegment.Middle_Right: { targetSegment = segments_middle_right; newSegment_transform = M_creatSegment_Middle(_type, targetSegment.gameObject); newSegment_transform.localPosition = lastPostion; lastRotatioin += new Vector3(0, 90, 0); newSegment_transform.localRotation = Quaternion.Euler(lastRotatioin); targetSegment = newSegment_transform.GetComponent <MissionRoadSegment>(); } break; } if (targetSegment != null) { point_x = targetSegment.distance * (int)Mathf.Cos(lastRotatioin.y * Mathf.Deg2Rad); point_z = targetSegment.distance * (int)Mathf.Sin(-lastRotatioin.y * Mathf.Deg2Rad); lastPostion += new Vector3(point_x, 0, point_z); segmentList.Add(targetSegment); targetSegment.maxStep = currentLastStep + targetSegment.totalSteps; currentLastStep += targetSegment.totalSteps; Vector3[] targetSegmentPoints = targetSegment.M_getPoints(); ListKit.AddRange(missionPoints, targetSegmentPoints); } }
/// <summary> /// 返回路段类型所对应的该路段中的步点总数 /// </summary> /// <returns>The segment step count.</returns> /// <param name="_type">_type.</param> public int M_getSegmentStepCount(EnumRoadSegment _type) { MissionRoadSegment segment = M_getRoadSegment(_type); return(segment.totalSteps); }