private IEnumerator EndReload(float reloadTime) { yield return(new WaitForSeconds(reloadTime)); CurrentDashCharges = 3; PantsChargeUIManager.ChargesUpdated(CurrentDashCharges); PantsChargeUIManager.StopReload(true); IsReloading = false; ReloadState = ReloadStateEnum.NotReloading; PlayerState = PlayerStateEnum.Idle; }
public void OnReloadPantsInputDown() { //Only allow reloading on the ground if (_Controller.collisions.below) { if (_ReloadRoutine == null && !IsReloading) { if (CurrentDashCharges < MaxDashCharges) { _ReloadStartTime = Time.time; if (CurrentDashCharges == 0) { _ReloadInstanceTime = FullReloadTime; ReloadState = ReloadStateEnum.FullReload; PlayerState = PlayerStateEnum.Reloading; } else { _ReloadInstanceTime = PartialReloadTime; ReloadState = ReloadStateEnum.PartialReload; PlayerState = PlayerStateEnum.Reloading; } _HotspotStartTime = (_ReloadInstanceTime * (ActiveReloadStartPercent / 100)); _HotspotEndtime = (_ReloadInstanceTime * (ActiveReloadEndPercent / 100)); _ReloadRoutine = StartCoroutine(EndReload(_ReloadInstanceTime)); PantsChargeUIManager.StartReload(_ReloadInstanceTime, ActiveReloadStartPercent, ActiveReloadEndPercent); IsReloading = true; } } else if (IsReloading) { if (CheckActiveReloadSuccess()) { PantsChargeUIManager.StopReload(true); IsReloading = false; CurrentDashCharges = MaxDashCharges + PerfectReloadBonus; PantsChargeUIManager.ChargesUpdated(CurrentDashCharges); ReloadState = ReloadStateEnum.ReloadSuccess; PlayerState = PlayerStateEnum.Idle; } else { //Failed reload StopCoroutine(_ReloadRoutine); //Calculate additional time to add on to reload based on percent float percent = (Time.time - _ReloadStartTime) / _ReloadInstanceTime; //invert to get the multiplier for bonus time percent = 100 - percent; float totalBonusTime = MaxFailedReloadBonusTime * (percent / 100); ReloadState = ReloadStateEnum.FailedReload; PlayerState = PlayerStateEnum.Reloading; PantsChargeUIManager.StopReload(false); _ReloadRoutine = StartCoroutine(EndReload(totalBonusTime)); } } } }