
var _orangeSlicer : Transform;
var _fireworks : Transform;
var _spray: Transform;
var _splatter00 : Transform; 
var _splatter01 : Transform; 
var _splatter02 : Transform; 
var _slicedFruitLeft : Rigidbody;
var _slicedFruitRight : Rigidbody;
var _distanceDifference : Vector2 = Vector2.zero;
var _orangeColor : Color = Color(0.5,0.5,0);

function Explode (){
	
	var _xPosition : float = 5;
	var _cloneLeft : Rigidbody;
	var _cloneRight : Rigidbody;
	var _randomRotation : float = Random.Range(-100,100);
	var _splat : Transform;
	var _randomSplat : int = Random.Range(0,2);
	
	// Make vertical slice
	transform.LookAt(_orangeSlicer, Vector3.up);
	
	// Create the orange half after the slice
	_cloneLeft = Instantiate(_slicedFruitLeft,Vector3(transform.position.x-
							_xPosition,transform.position.y,transform.position.z),transform.rotation);
	_cloneLeft.velocity = Vector3(_distanceDifference.x+rigidbody.velocity.x/2,_distanceDifference.y+rigidbody.velocity.y/2,0);
	_cloneLeft.gameObject.transform.eulerAngles = Vector3(_randomRotation,_randomRotation,_randomRotation);
	
	_cloneRight = Instantiate(_slicedFruitRight,Vector3(transform.position.x-
							_xPosition,transform.position.y,transform.position.z),transform.rotation);
	_cloneRight.velocity = Vector3(_distanceDifference.x,_distanceDifference.y,0);
	
	// Create the fireworks and the spray effect
	Instantiate(_fireworks,transform.position,transform.rotation);
	Instantiate(_spray,transform.position,transform.rotation);
	
	// Define the splatter type
	if(_randomSplat == 0){
		_splat = Instantiate(_splatter00,Vector3(transform.position.x,transform.position.y,60),Quaternion.Euler(270,0,0));
		}
	if(_randomSplat == 1){
		_splat = Instantiate(_splatter01,Vector3(transform.position.x,transform.position.y,60),Quaternion.Euler(270,0,0));		
		}
	if(_randomSplat == 2){
		_splat = Instantiate(_splatter02,Vector3(transform.position.x,transform.position.y,60),Quaternion.Euler(270,0,0));		
		}
	_splat.GetComponent(Renderer).material.color = _orangeColor;
	
	// Destroy the Object
	Destroy(gameObject);
} 