public void GenerateObstacleInfo(KdObstacleTree tree, float scale) { //可行走区 foreach (TiledData data in walk_area_list_) { List <Vector3> pts = data.GetPoints(); AddObstacle(pts, true, tree, scale); } //阻挡区 foreach (TiledData data in obstacle_area_list_) { List <Vector3> pts = data.GetPoints(); AddObstacle(pts, true, tree, scale); } //阻挡线 foreach (TiledData data in obstacle_line_list_) { List <Vector3> pts = data.GetPoints(); AddObstacle(pts, false, tree, scale); } //防弹区 foreach (TiledData data in shotproof_area_list_) { List <Vector3> pts = data.GetPoints(); AddObstacle(pts, true, tree, scale); } //防弹线 foreach (TiledData data in shotproof_line_list_) { List <Vector3> pts = data.GetPoints(); AddObstacle(pts, false, tree, scale); } //路障区 foreach (TiledData data in roadblock_area_list_) { List <Vector3> pts = data.GetPoints(); AddObstacle(pts, true, tree, scale); } //路障线 foreach (TiledData data in roadblock_line_list_) { List <Vector3> pts = data.GetPoints(); AddObstacle(pts, false, tree, scale); } //能量墙不影响行走,故无需加入避让阻挡信息 }
private void AddObstacle(List <Vector3> pts, bool isPolygon, KdObstacleTree tree, float scale) { if (isPolygon) { List <Vector3> pts2 = new List <Vector3>(); foreach (Vector3 pt in pts) { pts2.Add(pt * scale); } pts2.Add(pts[0] * scale); tree.AddObstacle(pts2); } else { List <Vector3> pts2 = new List <Vector3>(); foreach (Vector3 pt in pts) { pts2.Add(pt * scale); } tree.AddObstacle(pts2); } }