public var GunNormal : Transform;
public var GunAiming : Transform;
public var GunRunning : Transform;
public var GunJumping : Transform;

public var PuntoDisparo : Transform;

public var AnimacionesArma : GameObject;

enum TiposDisparo { Inmediato = 0, Proyectil = 1, Rayo = 2 }
public var Tipo : TiposDisparo = TiposDisparo.Inmediato;

public var CargadoresTotales : int = 10; // Esta es en realidad una var. interna.
public var BalasTotalesPorCargador : int =10;
public var CargadoresActuales : int = 10; // Esta es en realidad una var. interna.
public var BalasActualesEnCargador : int = 10;

public var TiempoDestruccion : float = 10;

public var Aceleracion : float = 1;
public var UseRotation : boolean = false;
public var ProyectilAutoRotacion : boolean = false;
public var VelocidadRotacion : Vector3 = Vector3 (2, 2, 2);
public var Damage : int = 45;
public var RatioDeDisparo : float = 1;

public var SplashObject : GameObject;
public var Decall : GameObject;
public var Destello : GameObject;
public var PuntoCasquillo : Transform;

public var Precision : float = 0.02f;
public var aimPrecision : float = 0.01f;

//  Variables que deberian ser privadas pero son publicas para acceder rapidamente a ellas desde cualquier script
// (la alternativa es hacer privadas y hacer unas funciones Get/Set para recoger su valor)
public var OrigPosGunNormal : Vector3 = Vector3.zero;
public var OrigRotGunNormal : Quaternion = Quaternion.identity;

public var OrigPosGunAiming : Vector3 = Vector3.zero;
public var OrigRotGunAiming : Quaternion = Quaternion.identity;

public var OrigPosGunRunning : Vector3 = Vector3.zero;
public var OrigRotGunRunning : Quaternion = Quaternion.identity;

public var OrigPosGunJumping : Vector3 = Vector3.zero;
public var OrigRotGunJumping : Quaternion = Quaternion.identity;

public var isInicialized : boolean = false;


function Awake () {
	if(AnimacionesArma != null){
		AnimacionesArma.animation.wrapMode = WrapMode.Once;
		AnimacionesArma.animation["recargar"].layer = -1;
		AnimacionesArma.animation["disparo"].layer = 0;
	}
	
	if(GunNormal != null){
		OrigPosGunNormal = GunNormal.localPosition;
		OrigRotGunNormal = GunNormal.localRotation;
		OrigPosGunRunning = GunNormal.localPosition;
		OrigRotGunRunning = GunNormal.localRotation;
		OrigPosGunJumping = GunNormal.localPosition;
		OrigRotGunJumping = GunNormal.localRotation;
	}
	
	if(GunAiming != null){
		OrigPosGunAiming = GunAiming.localPosition;
		OrigRotGunAiming = GunAiming.localRotation;
	}
	
	if(GunRunning != null){
		OrigPosGunRunning = GunRunning.localPosition;
		OrigRotGunRunning = GunRunning.localRotation;
	}
	
	if(GunJumping != null){
		OrigPosGunJumping = GunJumping.localPosition;
		OrigRotGunJumping = GunJumping.localRotation;
	}
	isInicialized = true;
}


function Update() {
	if(FPCStatus.IsJumping && !FPCStatus.IsJumpingAntFrame){
		this.gameObject.SendMessage("ReasignOriginalValues", OrigPosGunJumping);
		this.gameObject.SendMessage("ReasignOriginalRotValues", OrigRotGunJumping);
	}
	else
	if(!FPCStatus.IsJumping && FPCStatus.IsJumpingAntFrame && !FPCStatus.IsAiming){
		if(FPCStatus.isRunning){
			this.gameObject.SendMessage("ReasignOriginalValues", OrigPosGunRunning);
			this.gameObject.SendMessage("ReasignOriginalRotValues", OrigRotGunRunning);
		}
		else
		if(FPCStatus.isNormal){
			this.gameObject.SendMessage("ReasignOriginalValues", OrigPosGunNormal);
			this.gameObject.SendMessage("ReasignOriginalRotValues", OrigRotGunNormal);
		}
	}
	else
	if(FPCStatus.isRunning && !FPCStatus.isRunningAntFrame){
		this.gameObject.SendMessage("ReasignOriginalValues", OrigPosGunRunning);
		this.gameObject.SendMessage("ReasignOriginalRotValues", OrigRotGunRunning);
	}
	else
	if(FPCStatus.isNormal && !FPCStatus.isNormalAntFrame && !FPCStatus.IsAiming){
		this.gameObject.SendMessage("ReasignOriginalValues", OrigPosGunNormal);
		this.gameObject.SendMessage("ReasignOriginalRotValues", OrigRotGunNormal);
	}
	
	FPCStatus.isRunningAntFrame = FPCStatus.isRunning;
	FPCStatus.IsJumpingAntFrame = FPCStatus.IsJumping;
}