private void SwipeCallback(bool p_isClockwise) { Transform[] hexTransforms = new Transform[SC.GetSelectedTiles().Length]; for (int i = 0; i < hexTransforms.Length; i++) { hexTransforms[i] = SC.GetSelectedTiles()[i].transform; } _explosionsInProgres = true; FX.MoveHexTiles(hexTransforms, p_isClockwise, () => { BC.RotateTiles(SC.GetSelectedTiles(), p_isClockwise); BC.UpdateTileConnections(); HexTile[] explodingHexes = null; bool isExploding = false; explodingHexes = null; isExploding = BC.CheckForExplosions(out explodingHexes); if (isExploding) { SC.DeSelect(); BC.ExplodeTiles(explodingHexes); ScoreC.AddSore(explodingHexes.Length * GRM.ScoreMultiplier); for (int i = 0; i < explodingHexes.Length; i++) { HexExplosionEffectController epxlosionEffect = Instantiate(GRM.HexTileExplosionEffect); epxlosionEffect.Init(GRM.GetColorFromIndex(explodingHexes[i].HexTileColor), explodingHexes[i].transform.position); } StartCoroutine(DelayedAction(0.4f, () => { if (_playerMadeMove != null) { _playerMadeMove.Invoke(); } RefillBoard(); StartCoroutine(CheckRandomExplosionsSmooth()); })); } else { FX.MoveHexTiles(hexTransforms, !p_isClockwise, () => { BC.RotateTiles(SC.GetSelectedTiles(), !p_isClockwise); BC.UpdateTileConnections(); _explosionsInProgres = false; }); } }); }
private IEnumerator CheckRandomExplosionsSmooth() { HexTile[] explodingHexes = null; bool isExploding = false; int infiniteBreak = 0; do { if (_gameOver) { yield break; } explodingHexes = null; isExploding = BC.CheckForExplosions(out explodingHexes); if (isExploding) { BC.ExplodeTiles(explodingHexes); for (int i = 0; i < explodingHexes.Length; i++) { HexExplosionEffectController epxlosionEffect = Instantiate(GRM.HexTileExplosionEffect); epxlosionEffect.Init(GRM.GetColorFromIndex(explodingHexes[i].HexTileColor), explodingHexes[i].transform.position); } ScoreC.AddSore(explodingHexes.Length * GRM.ScoreMultiplier); yield return(new WaitForSeconds(0.3f)); RefillBoard(); yield return(new WaitForSeconds(0.3f)); } infiniteBreak++; } while (isExploding && infiniteBreak < 100); _explosionsInProgres = false; }
private IEnumerator SmoothGameOver(HexExplosionEffectController p_explosionEffect, Color[] p_hexColors) { HexExplosionEffectController epxlosionEffect = null; for (int i = 0; i < GameTiles.Length; i++) { for (int j = 0; j < GameTiles[i].Length; j++) { if (GameTiles[i][j] != null) { GameTiles[i][j].Explode(); epxlosionEffect = Instantiate(p_explosionEffect); epxlosionEffect.Init(p_hexColors[GameTiles[i][j].HexTileColor], GameTiles[i][j].transform.position); } for (int k = 0; k < UnityEngine.Random.Range(1, 2); k++) { yield return(new WaitForFixedUpdate()); } } } }