public void ReloadData() { if (isActiveAndEnabled) { StartCoroutine(_ReloadData()); } else { _reloadingState = ReloadingState.ReloadingSuspend; } }
IEnumerator _ReloadData() { if (_delegate == null) { throw new Exception("You must set delegate first"); } if (_reloadingState == ReloadingState.Reloading) { yield break; } _reloadingState = ReloadingState.Reloading; while (true) { LazyGetViewportHeight(); if (_viewportHeight <= 0) { yield return(new WaitForEndOfFrame()); } else { break; } } RecreateCellInfo(); CalculateCellPosition(); DeactiveAllCell(); UpdateViewContent(); UpdateCellVisibility(); if (_scrollRectWorkAround != null) { _scrollRectWorkAround.ForceUpdateScrollBar(_scrollRect.normalizedPosition); } _reloadingState = ReloadingState.Idle; }
protected virtual IEnumerator ReloadState() { while (true) { yield return(new WaitUntil(() => reloadingState == ReloadingState.StartReloading)); while (bulletRemaining < data.bulletCapacity) { reloadingState = ReloadingState.Reloading; float t = 0; yield return(new WaitUntil( () => { t += Time.deltaTime; if (t >= data.bulletReloadTime / data.bulletCapacity) { audioSource.PlayOneShot(data.reloadClip); bulletRemaining++; return true; } else if (reloadingState == ReloadingState.StopReloading) { return true; } else { return false; } })); if (reloadingState == ReloadingState.StopReloading) { break; } } reloadingState = ReloadingState.Ready; } }
protected virtual IEnumerator ShootState() { while (true) { yield return(new WaitWhile(() => bulletRemaining <= 0)); yield return(new WaitUntil(() => shootingState == ShootingState.Shoot)); if (reloadingState == ReloadingState.Reloading) { reloadingState = ReloadingState.StopReloading; // Detiene la recarga de balas shootingState = ShootingState.Idle; continue; //yield return new WaitUntil(() => reloadingState == ReloadingState.Ready); } Shoot(); yield return(new WaitForSeconds(data.bulletShotTime)); shootingState = ShootingState.Idle; } }