Ejemplo n.º 1
0
        private IEnumerator AnimateClearedLines(List <int> clearedLines)
        {
            // Play sound
            _soundController.PlayClearLine();

            // blink animation
            bool blink = true;

            for (float elapsedTime = 0; elapsedTime < _clearLineAnimationTime; elapsedTime = Mathf.MoveTowards(elapsedTime, _clearLineAnimationTime, _clearLineAnimationTime * _clearLineMultiplier))
            {
                for (int i = 0; i < clearedLines.Count; i++)
                {
                    int line = clearedLines[i];
                    for (int column = 0; column < BoardModel.NumColumns; column++)
                    {
                        if (blink)
                        {
                            BoardView.Blocks[line, column].sharedMaterial = _blocks.Ghost;
                        }
                        else
                        {
                            int blockType = BoardModel.Blocks[line, column];
                            BoardView.Blocks[line, column].sharedMaterial = _blocks.GetMaterial(blockType);
                        }
                    }
                }

                blink = !blink;

                yield return(new WaitForSeconds(_clearLineAnimationTime * _clearLineMultiplier));
            }
        }