//FPS Constructor - Weapons
//Copyright Dastardly Banana Productions 2010
//This script, and all others contained within the Dastardly Banana Weapons Package, may not be shared or redistributed. They can be used in games, either commerical or non-commercial, as long as Dastardly Banana Productions is attributed in the credits.
//Permissions beyond the scope of this license may be available at mailto://info@dastardlybanana.com.


var bulletsLeft : int;
var clips : int;
var showClips : boolean = true;
var display : boolean = true;
var clipDisplay : String;
private var gunScripts = new Array();
private var gunScriptSecondary : gunscript;
private var gunScript : gunscript;

function Start () {
	gunScripts = this.GetComponents(gunscript);
	for(var i = 0; i < gunScripts.length; i++){
		if(gunScripts[i].isPrimaryWeapon){
			gunScript = gunScripts[i];
		} else {
			gunScriptSecondary = gunScripts[i];
		}
	}
}
function OnGUI (){
	if(showClips){
		clipDisplay ="/"+gunScript.clips;
		if(gunScriptSecondary != null)
			clipDisplay2 ="/"+gunScriptSecondary.clips;
	}else{
		clipDisplay = "";
		clipDisplay2 = "";
	}
	
	if(display){
		if(gunScriptSecondary != null){
			GUI.Box(Rect(Screen.width - 110,Screen.height-55,100,20),"Ammo: "+Mathf.Round(gunScript.ammoLeft) + clipDisplay);
			GUI.Box(Rect(Screen.width - 80,Screen.height-30,70,20),"Alt: "+Mathf.Round(gunScriptSecondary.ammoLeft) + clipDisplay2);
		} else {
			GUI.Box(Rect(Screen.width - 110,Screen.height-30,100,20),"Ammo: "+Mathf.Round(gunScript.ammoLeft) + clipDisplay);
		}
	}

}
function selectWeapon () {
	display = true;
}
function deselectWeapon () {
	display = false;
}