private void ExplodeInPoint(Vector2D pos) { List <Slice2D> results = Slicer2D.ExplodeInPointAll(pos, sliceLayer); if (addForce == true) { foreach (Slice2D id in results) { foreach (GameObject gameObject in id.gameObjects) { Rigidbody2D rigidBody2D = gameObject.GetComponent <Rigidbody2D> (); if (rigidBody2D) { float sliceRotation = Vector2D.Atan2(pos, new Vector2D(gameObject.transform.position)); Rect rect = Polygon2D.CreateFromCollider(gameObject).GetBounds(); Physics2DHelper.AddForceAtPosition(rigidBody2D, new Vector2(Mathf.Cos(sliceRotation) * addForceAmount, Mathf.Sin(sliceRotation) * addForceAmount), rect.center); } } if (sliceResultEvent != null) { sliceResultEvent(id); } } } }
void Explode(Vector2D pos) { List <Slice2D> results = Slicer2D.ExplodeInPointAll(pos, sliceLayer); foreach (Slice2D id in results) { eventHandler.Perform(id); } if (addForce == true) { foreach (Slice2D id in results) { Slicer2DAddForce.ExplodeInPoint(id, addForceAmount, pos); } } }
private void ExplodeInPoint(Vector2D pos) { List <Slice2D> results = Slicer2D.ExplodeInPointAll(pos, sliceLayer); foreach (Slice2D id in results) { if (sliceResultEvent != null) { sliceResultEvent(id); } } if (addForce == true) { foreach (Slice2D id in results) { AddForce.ExplodeInPoint(id, addForceAmount, pos); } } }