public void AddNewArea(int areaId) { UnWalkData walkData = new UnWalkData(); walkData.areaId = areaId; walkData.AreaName = "Area" + walkData.areaId; allAreas.Add(walkData); areasName.Add(walkData.AreaName); }
public void InsertPoint(int areaIndex, int prePointIndex, GameObject obj) { if (areaIndex < allAreas.Count) { UnWalkData walkData = allAreas[areaIndex]; string pointName = "区域" + (areaIndex + 1) + "->点" + (walkData.LastPointNum); obj.name = pointName; walkData.InsertPoint(prePointIndex, obj); } else { LogManager.Log("区域索引[" + areaIndex + "]不对,请选择区域先"); } }
public string[] GetAllPointsName(int areaIndex) { string[] emptyName = { }; if (allAreas == null) { return(emptyName); } if (areaIndex >= allAreas.Count || allAreas.Count <= 0) { //LogManager.Log("区域索引[" + areaIndex + "]不对"); return(emptyName); } UnWalkData walkData = allAreas[areaIndex]; return(walkData.GetAllPointNames()); }
/// <summary> /// 删除不可行走区域 /// </summary> /// <param name="index">区域索引</param> /// <returns></returns> public void DelArea(int index) { if (allAreas.Count <= 0) { return; } if (index <= allAreas.Count) { UnWalkData walkData = allAreas[index]; // 需要删除游戏里面的所有顶点对象 foreach (GameObject obj in walkData.points) { GameObject.DestroyImmediate(obj); } allAreas.RemoveAt(index); areasName.RemoveAt(index); } }
/// <summary> /// 根据索引删除顶点 /// </summary> /// <param name="areaIndex">不可行走区域索引</param> /// <param name="pointIndex">顶点索引</param> /// <returns></returns> public void DelPoint(int areaIndex, int pointIndex) { if (areaIndex < allAreas.Count) { UnWalkData walkData = allAreas[areaIndex]; if (walkData.points.Count <= 0) { LogManager.Log("顶点已经全部删除"); } else if (pointIndex < walkData.points.Count) { walkData.DelPoint(pointIndex); } else { LogManager.LogError("顶点索引[" + pointIndex + "]不对,请选择正确的顶点"); } } else { LogManager.LogError("区域索引[" + areaIndex + "]不对,请选择区域先"); } }