コード例 #1
0
    void Reload()
    {
        if (_gunInventory[_currentlySelectedWeapon].gunObject && !_grenadeSelected && _currentlySelectedWeapon != 2)
        {
            if (_currentWeaponInterface.returnCurrentMagazineValue() == 0)
            {
                RemoveCritBoost();
            }


            bool fullMagazine = _currentWeaponInterface.returnCurrentMagazineValue() == _currentWeaponInterface.ReturnClipSize();
            if (XCI.GetButtonDown(XboxButton.X, _inputScript.controller) && !fullMagazine && _gunInventory[_currentlySelectedWeapon].currentAmmo > 0)
            {
                GetComponent <SCR_PlayerWorldSpaceUI>().ShowReloadPrompt(true);
                if (!_isReloading)
                {
                    if (bCritActive)
                    {
                        RemoveCritBoost();
                    }
                    critGauge    = null;
                    _isReloading = true;
                    _currentWeaponInterface.GunReload(true);
                    normalGauge = uiManagerScript.DecreaseSteamGauge(gameObject.tag, this, reloadMultiplier, playerWorldSpaceUIScr);
                    _currentWeaponInterface.PlayReloadSound();
                    StartCoroutine(normalGauge);

                    if (!bHasReloaded && bTutorialCanReload)
                    {
                        GameObject tutorialManager = GameObject.FindGameObjectWithTag("TutorialManager");
                        if (tutorialManager)
                        {
                            SCR_TutorialManager tutorialManagerScr = tutorialManager.GetComponent <SCR_TutorialManager>();
                            tutorialManagerScr.SetHasReloaded();
                        }
                        bHasReloaded = true;
                    }

                    playerWorldSpaceUIScr.HideReloadButtonPrompt();
                }
                else if (_isReloading && !_CritAttempted)
                {
                    if (normalGauge != null)
                    {
                        StopCoroutine(normalGauge);
                        normalGauge = null;
                    }

                    critGauge = uiManagerScript.rotateGaugePinFull(0.0f, this, gameObject.tag, false);
                    StartCoroutine(critGauge);


                    playerWorldSpaceUIScr.ShowReloadPrompt(false);
                    //Original system
                    //float clipPercentage = uiManagerScript.ReturnPercentage(gameObject.tag);
                    //float ammoGaugePercentage = RefillClip(clipPercentage);


                    //EGX SYSTEM
                    float ammoGaugePercentage = RefillClip(100);


                    _CritAttempted = true;
                    uiManagerScript.SetCurrentAmmoText(gameObject.tag, ammoGaugePercentage * _currentWeaponInterface.ReturnClipSize(), _gunInventory[_currentlySelectedWeapon].currentAmmo, _currentWeaponInterface.ReturnClipSize());

                    if (uiManagerScript.WithinCritZone())
                    {
                        CriticalDamageBonus();
                        SCR_AudioManager.instance.Play("DingReload");
                    }
                }
            }
        }
    }