Скорректирован баг с перезарядкой.

This commit is contained in:
DyatelO 2022-01-05 03:41:23 +03:00
parent e196974851
commit b85aae35d4

View File

@ -29,7 +29,7 @@ public class UnitView : MonoBehaviour
private Coroutine _previosRegen; private Coroutine _previosRegen;
private Coroutine _previosReload; private Coroutine _previosReload;
// //
//private WaitForSeconds regenTick = new WaitForSeconds(0.5f); private WaitForSeconds regenTick = new WaitForSeconds(0.5f);
// //
private int _mana; private int _mana;
private Action _capureHex; private Action _capureHex;
@ -139,10 +139,24 @@ public class UnitView : MonoBehaviour
yield return new WaitForSeconds(_weapon.reloadTime); yield return new WaitForSeconds(_weapon.reloadTime);
if (_toReloadStack.Count == 0) yield break; if (_toReloadStack.Count == 0) yield break;
var shot = _toReloadStack.Pop(); var shot = _toReloadStack.Pop();
shot.Switch();
_shootUIStack.Push(shot); // _shootUIStack.Push(shot);
StartCoroutine(Reload()); shot.Switch();
_previosReload = null; _shootUIStack.Push(shot);
foreach (var item in _toReloadStack)
{
if(Time.deltaTime < _weapon.reloadTime)
{
StopCoroutine(_previosReload);
_previosReload = null;
}
_previosReload = StartCoroutine(Reload());
}
} }
private IEnumerator Regen() private IEnumerator Regen()