private IEnumerator BootstrapCoroutine() { yield return(new WaitForSecondsRealtime(1)); timer.ResetTimer(); gridController.BuildGrid(); scoreController.ResetTargetScore(); yield return(new WaitForSecondsRealtime(0.8f)); timer.StartTimer(); soundFXController.PlayClear(); selector.PlayingGame = true; var gemRenderers = gridController.AllGems .Select(x => x.SpriteRenderer).ToArray(); animator.AnimateGemSpawn(gemRenderers); }
private void OnComboConfirm(List <List <Gem> > combos) { if (!PlayingGame) { return; } OnCombo?.Invoke(combos); soundFXController.PlayClear(); var removedGems = combos.SelectMany(x => x).ToArray(); foreach (var gem in removedGems) { gem.Removed = true; } var gemRenerers = removedGems.Select(x => x.SpriteRenderer).ToArray(); var droppedGems = gridController.DropGems(removedGems); var gemDroppedPosition = new Dictionary <Transform, Vector3>(); foreach (var gem in droppedGems) { if (!gem.Removed) { gemDroppedPosition.Add( gem.transform, gridController.GetGemWorldPosition(gem)); } } animator.AnimateGemMove(gemDroppedPosition); var fadeAnimation = animator.AnimateGemFade(gemRenerers); fadeAnimation.AppendInterval(0.1f); fadeAnimation.AppendCallback(() => { gridController.RebuildGems(removedGems); animator.AnimateGemSpawn(removedGems.Select(x => x.SpriteRenderer).ToArray()); var totalModifiedGems = removedGems.Concat(droppedGems).ToArray(); var newCombos = gridController.GetGemsCombos(totalModifiedGems); if (newCombos.Count > 0) { StartCoroutine(ComboChainDelay(newCombos)); } else { if (!gridController.HasAvailableCombos()) { StartCoroutine(ShuffleGemsDelay()); } else { gameTimer.StartTimer(); canSelect = true; } } }); }