From b85aae35d4e26592380bb319b417c96aa30fae8a Mon Sep 17 00:00:00 2001 From: DyatelO Date: Wed, 5 Jan 2022 03:41:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=B1=D0=B0=D0=B3?= =?UTF-8?q?=20=D1=81=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B7=D0=B0=D1=80=D1=8F?= =?UTF-8?q?=D0=B4=D0=BA=D0=BE=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Units/Views/UnitView.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Units/Views/UnitView.cs b/Assets/Scripts/Units/Views/UnitView.cs index 77b1e719..3d7d8de6 100644 --- a/Assets/Scripts/Units/Views/UnitView.cs +++ b/Assets/Scripts/Units/Views/UnitView.cs @@ -29,7 +29,7 @@ public class UnitView : MonoBehaviour private Coroutine _previosRegen; private Coroutine _previosReload; // - //private WaitForSeconds regenTick = new WaitForSeconds(0.5f); + private WaitForSeconds regenTick = new WaitForSeconds(0.5f); // private int _mana; private Action _capureHex; @@ -139,10 +139,24 @@ public class UnitView : MonoBehaviour yield return new WaitForSeconds(_weapon.reloadTime); if (_toReloadStack.Count == 0) yield break; var shot = _toReloadStack.Pop(); - shot.Switch(); - _shootUIStack.Push(shot); - StartCoroutine(Reload()); - _previosReload = null; + + // _shootUIStack.Push(shot); + shot.Switch(); + _shootUIStack.Push(shot); + + foreach (var item in _toReloadStack) + { + if(Time.deltaTime < _weapon.reloadTime) + { + StopCoroutine(_previosReload); + _previosReload = null; + } + _previosReload = StartCoroutine(Reload()); + + } + + + } private IEnumerator Regen()