private void ExplodeByPoint(Vector2D pos) { List <Slice2D> results = Slicer2D.ExplodeByPointAll(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 ExplodeFromPoint(Vector2D pos) { List <Slice2D> results = Slicer2D.ExplodeByPointAll(pos, sliceLayer); foreach (Slice2D id in results) { eventHandler.Perform(id); } if (addForce == true) { foreach (Slice2D id in results) { Slicer2DAddForce.ExplodeByPoint(id, addForceAmount, pos); } } }
private void ExplodeByPoint(Vector2D pos) { List <Slice2D> results = Slicer2D.ExplodeByPointAll(pos, sliceLayer); foreach (Slice2D id in results) { if (sliceResultEvent != null) { sliceResultEvent(id); } } if (addForce == true) { foreach (Slice2D id in results) { AddForce.ExplodeByPoint(id, addForceAmount, pos); } } }