public void BuildNewTrafficLine(AI_TYPE InType, Vector3[] InPositions, bool SmoothPath) { // lazy load Prefab_TrafficLine List <TrafficLine> List_TrafficLine; if (!Map.TryGetValue(InType, out List_TrafficLine)) { List_TrafficLine = new List <TrafficLine>(); Map.Add(InType, List_TrafficLine); } LineType line = List_LineType.Find(it => it.type == InType); GameObject t = Instantiate(line.prefab) as GameObject; t.transform.parent = this.gameObject.transform; TrafficLine trafficLine = t.GetComponent <TrafficLine>(); trafficLine.type = InType; // need to be set before addnewposition List_TrafficLine.Add(trafficLine); Vector3[] SmoothPathPostions = InPositions; Vector3[] NavmeshPostions = InPositions; if (SmoothPath) { SmoothPathPostions = GenerateSmoothPath(InPositions, SmoothAmountTimeForPath); NavmeshPostions = GenerateSmoothPath(InPositions, SmoothAmountTimeAI); } // Draw curve path trafficLine.DrawCurve(SmoothPathPostions); // Use bridge mesh as nav mesh BridgeController.Instance.SendBridgeMaker(InType, NavmeshPostions); }
public void Clear(AI_TYPE InType) { NavMeshSourceTag.UnCollect(InType); List <TrafficLine> List_TrafficLine; if (!Map.TryGetValue(InType, out List_TrafficLine)) { return; } foreach (var t in List_TrafficLine) { Destroy(t.gameObject); } List_TrafficLine.Clear(); }