/*
============================================================================================================
	 _	 _  ____  _      _  ____  _____  _____  _______  ____  _____
	| | | || ___|| |    | || ___||  _  || ___ ||__   __|| ___|| ___ |
	| |_| || |__ | |    | || |   | | | || |_| |   | |   | |__ | |_| |
	|  _  || ___|| |    | || |   | | | || ____|   | |   | ___|| __  |
	| | | || |__ | |___ | || |__ | |_| || |       | |   | |__ | | \ \
	|_| |_||____||_____||_||____||_____||_|       |_|   |____||_|  \_\
	
		 _______  _   _  _______  _____  _____   _  _____  _
		|__   __|| | | ||__   __||  _  || ___ | | ||  _  || |
		   | |   | | | |   | |   | | | || |_| | | || |_| || |
		   | |   | | | |   | |   | | | ||  _  | | ||  _  || |
		   | |   | |_| |   | |   | |_| || | \ \ | || | | || |___
		   |_|   |_____|   |_|   |_____||_|  \_\|_||_| |_||_____|
	   
				   	 _________________________
					|_____by: Andrew Gotow____|
			
============================================================================================================

	This is a simple little script to send a message to the helicopter object to notify it that one of the props
has been destroyed. The helicopter has functions called "MainRotorDestroyed" and "TailRotorDestroyed". These functions
basically disable certain aspects of the helicopter script, and are called from the props themselves using the 
"SendMessage" function. This is necessary because the helicopter body itself can not respond to the built in "OnTriggerEnter"
event for another object, so using the same script, it is impossible to determine whether the props had hit anything. This
script is not necessary, but allows us to use these functions easily.
*/

var 	rotor_Name 			: String;		// A string that tells the script which function to call.
var 	main_Body 			: GameObject;	// A variable so the script knows what object the function is in.
var		explosion_Prefab 	: GameObject;	// The explosion object to be created when the rotor is destroyed.


// Now we can respond to the basic OnTriggerEnter event. This function is called automatically any time an object with a collider 
// marked as a "trigger" comes in contact with another.
function OnTriggerEnter () {
	
	// now we simply set a value in the helicopter script to set the rotor enabled value
	if ( rotor_Name == "MainRotor" ) {
		main_Body.GetComponent( "Helicopter_Script" ).main_Rotor_Active = false;
	}else if ( rotor_Name == "TailRotor" ) {
		main_Body.GetComponent( "Helicopter_Script" ).tail_Rotor_Active = false;
	}
	
	// Instantiate the explosion prefab object.
	Instantiate( explosion_Prefab, transform.position, transform.rotation );
	
	// and finally, we destroy the propeller gameobject itself.
	Destroy( gameObject );
}