static public List <Slice2D> LinearCutSliceAll(LinearCut linearCut, Slice2DLayer layer = null) { List <Slice2D> result = new List <Slice2D> (); if (layer == null) { layer = Slice2DLayer.Create(); } foreach (Slicer2D id in GetListLayer(layer)) { Slice2D sliceResult = id.LinearCutSlice(linearCut); if (sliceResult.gameObjects.Count > 0) { result.Add(sliceResult); } } return(result); }
static public List <Slice2D> ExplodeAll(Slice2DLayer layer = null, int explosionSlices = 0) { List <Slice2D> result = new List <Slice2D> (); if (layer == null) { layer = Slice2DLayer.Create(); } foreach (Slicer2D id in GetListLayer(layer)) { Slice2D sliceResult = id.Explode(explosionSlices); if (sliceResult.GetGameObjects().Count > 0) { result.Add(sliceResult); } } return(result); }
static public List <Slice2D> ExplodeInPointAll(Vector2D point, Slice2DLayer layer = null) { List <Slice2D> result = new List <Slice2D> (); if (layer == null) { layer = Slice2DLayer.Create(); } foreach (Slicer2D id in GetListLayer(layer)) { Slice2D sliceResult = id.ExplodeInPoint(point); if (sliceResult.GetGameObjects().Count > 0) { result.Add(sliceResult); } } return(result); }
static public List <Slice2D> PointSliceAll(Vector2D slice, float rotation, Slice2DLayer layer = null) { List <Slice2D> result = new List <Slice2D> (); if (layer == null) { layer = Slice2DLayer.Create(); } foreach (Slicer2D id in GetListLayer(layer)) { Slice2D sliceResult = id.PointSlice(slice, rotation); if (sliceResult.GetGameObjects().Count > 0) { result.Add(sliceResult); } } return(result); }
static public List <Slice2D> ComplexCutSliceAll(ComplexCut complexCut, Slice2DLayer layer = null) { List <Slice2D> result = new List <Slice2D> (); if (layer == null) { layer = Slice2DLayer.Create(); } foreach (Slicer2D id in GetListLayer(layer)) { Slice2D sliceResult = id.ComplexCutSlice(complexCut); if (sliceResult.GetGameObjects().Count > 0) { result.Add(sliceResult); } } return(result); }
public void Cut() { foreach (var cutPair in _userCutPoints) { List <Slice2D> sliceResult = Slicer2D.LinearSliceAll(cutPair, Slice2DLayer.Create()); foreach (var slice in sliceResult) { List <GameObject> slicedGameObjects = slice.GetGameObjects(); foreach (var sg in slicedGameObjects) { sg.GetComponent <Rigidbody2D>().AddForce(UnityEngine.Random.insideUnitCircle * 20, ForceMode2D.Impulse); sg.AddComponent <SliceMoveOut>(); } } } GameObject[] cutLines = GameObject.FindGameObjectsWithTag("cut_line"); foreach (var cutLine in cutLines) { Destroy(cutLine); } }