Ejemplo n.º 1
0
 public void StartReload(float reload, scr_ammo ammo)
 {
     _ReloadTime     = reload;
     _Img.fillAmount = 0;
     StopAllCoroutines();
     ammo.ReloadStart();
     _AmmoText.text = ammo.GetAmmoInClip() + "/" + ammo.GetCurrentAmmoToString();
     StartCoroutine(Reload(ammo));
 }
Ejemplo n.º 2
0
    IEnumerator Reload(scr_ammo ammo)
    {
        float time = 0;

        while (time < _ReloadTime)
        {
            time += Time.deltaTime;
            float progress = Mathf.Lerp(0, 1, time / _ReloadTime);
            _Img.fillAmount = progress;
            yield return(null);
        }
        ammo.ReloadEnd();
        _AmmoText.text = ammo.GetAmmoInClip() + "/" + ammo.GetCurrentAmmoToString();

        yield return(new WaitForSeconds(0.1f));

        _Img.fillAmount = 0;
    }
Ejemplo n.º 3
0
 // Start is called before the first frame update
 void Awake()
 {
     _Anim          = GetComponent <Animator>();
     _Hips          = _Anim.GetBoneTransform(HumanBodyBones.Hips);
     _Spine         = _Anim.GetBoneTransform(HumanBodyBones.Spine);
     _CC            = GetComponent <CharacterController>();
     _RArm          = _Anim.GetBoneTransform(HumanBodyBones.RightShoulder);
     _LArm          = _Anim.GetBoneTransform(HumanBodyBones.LeftShoulder);
     _RHand         = _Anim.GetBoneTransform(HumanBodyBones.RightHand);
     _LHand         = _Anim.GetBoneTransform(HumanBodyBones.LeftHand);
     _ShotFiring    = false;
     _Ammo          = GetComponent <scr_ammo>();
     _AmmoText      = GameObject.FindGameObjectWithTag("AmmoText").GetComponent <TextMeshProUGUI>();
     _AS            = GetComponent <AudioSource>();
     _AmmoText.text = _Ammo.GetAmmoInClip() + "/" + _Ammo.GetCurrentAmmoToString();
     _AimPlane      = new Plane(Vector3.up, Vector3.zero);
     _Dashbar       = GameObject.FindGameObjectWithTag("Dashbar").GetComponent <scr_dashbar>();
     _Health        = GetComponent <scr_health>();
 }