Доброго времени суток, скажите пожалуйста почему мои "лыжи не едут", не работает перезарядка, там их две, когда в магазине есть патроны(reload) и когда он пуст(reload_full). А переменная clips означает общий поезапас, а не количество магазинов
var bulletsLeft : int = 9;
var bulletsInClip : int = 9;
var clips : int = 36;
var gText : GUIText;
function Start()
{
animation.Play("draw_in");
}
function Update ()
{
if(Input.GetMouseButtonDown(0) && !animation.IsPlaying("reload_full") && !animation.IsPlaying("reload"))
{
bulletsLeft --;
animation.Play("fire");
}
if(Input.GetKeyUp("R"))
{
if(bulletsLeft == 0)
{
ReloadFull();
}
else
{
Reload();
}
}
}
function ReloadFull()
{
if( clips >= bulletsInClip)
{
animation.Play("reload_full");
clips += bulletsLeft;
bulletsLeft = 0;
if(!animation.IsPlaying("reload_full"))
{
clips -= bulletsInClip;
bulletsLeft = bulletsInClip;
}
}
else
{
animation.Play("reload_full");
clips += bulletsLeft;
bulletsLeft = 0;
if(!animation.IsPlaying("reload_full"))
{
clips = 0;
bulletsLeft = clips;
}
}
}
function Reload()
{
if( clips >=bulletsInClip)
{
animation.Play("reload");
clips += bulletsLeft;
bulletsLeft = 0;
if(!animation.IsPlaying("reload"))
{
clips -= bulletsInClip;
bulletsLeft = bulletsInClip;
}
}
else
{
animation.Play("reload");
clips += bulletsLeft;
bulletsLeft = 0;
if(!animation.IsPlaying("reload_full"))
{
clips = 0;
bulletsLeft = clips;
}
}
}
function OnGUI()
{
gText.text = bulletsLeft + " | " + clips;
}