예제 #1
0
    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;
                });
            }
        });
    }