Пример #1
0
    public void OnFinished()
    {
        tweenScale.enabled = false;
        GameObject playerObj = GameObject.Find("Player");

        if (playerObj)
        {
            HitAnimation hitA = playerObj.GetComponent <HitAnimation>();
            hitA.ResetAnimation();

            FallingAnimation fallA = playerObj.GetComponent <FallingAnimation>();
            fallA.ResetAnimation();
        }
    }
Пример #2
0
        /// <summary>
        /// Render destroy animation.
        /// </summary>
        private void RenderDestroyAnimation()
        {
            var destroyAnimation = _animation as DestroyingAnimation;

            if (destroyAnimation == null)
            {
                return;
            }

            foreach (var cell in destroyAnimation.Cells)
            {
                var rectangleCell   = CellToRectangle(cell.X, cell.Y);
                var rectangleCircle = CellToCircleRectangle(cell.X, cell.Y);

                //Drawing background, border and element
                _graphics.FillRectangle(_backgroundColor, rectangleCell);
                _graphics.DrawRectangle(_borderPen, rectangleCell);
                _graphics.FillEllipse(new SolidBrush(Color.FromArgb(destroyAnimation.Alpha, _cellTypesColors[_field[cell.X, cell.Y] - 1])), rectangleCircle);
            }

            if (destroyAnimation.CompletedPersent < 1)
            {
                return;
            }

            //If animation is complete

            //Searching max y coordinate of each column contains deleted items
            var maxEmptyYOfLines = Enumerable.Repeat(-1, _fieldSize).ToArray();

            foreach (var cell in destroyAnimation.Cells)
            {
                _field[cell.X, cell.Y] = 0;
                if (maxEmptyYOfLines[cell.X] < cell.Y)
                {
                    maxEmptyYOfLines[cell.X] = cell.Y;
                }
            }

            //Prepararing falling animation and generate new elements
            var fallingAnimation = new FallingAnimation(CellFallingSpeed);

            for (var i = 0; i < _fieldSize; ++i)
            {
                if (maxEmptyYOfLines[i] == -1)
                {
                    continue;
                }

                var fallingColumn = new FallingAnimation.Column(i, maxEmptyYOfLines[i]);

                for (var j = fallingColumn.MaxY; j >= 0; --j)
                {
                    if (_field[i, j] != 0)
                    {
                        fallingColumn.Cells.Add(new FallingAnimation.Column.Cell(j, _field[i, j]));
                    }
                }

                var newCellsCount = fallingColumn.MaxY - fallingColumn.Cells.Count + 1;
                for (var j = 1; j <= newCellsCount; ++j)
                {
                    fallingColumn.Cells.Add(new FallingAnimation.Column.Cell(j * -1, RandomElement));
                }

                fallingAnimation.Columns.Add(fallingColumn);
            }

            _animation = fallingAnimation;
        }