Example #1
0
        private void Start()
        {
            //_audioManager = FindObjectOfType<AudioManager>();
            BlockHandler.Initialize(canvas);
            block   = new BlockData[35];
            _stack  = new int[35];
            _down   = new int[35];
            _stackN = 0;
            ScoreData.currentScore = 0;

            for (var i = 0; i < 5; ++i)
            {
                for (var j = 0; j < 7; ++j)
                {
                    var x = i * 7 + j;
                    block[x] = BlockHandler.CreateBlock();
                    BlockHandler.SetPosition(block[x], i, j + 4);
                    BlockHandler.SetNumber(block[x], Rand());
                    BlockHandler.Move(block[x], i, j, 0.5f);
                }
            }

            StartCoroutine(Play());
        }
Example #2
0
        private IEnumerator SolveList()
        {
            FindObjectOfType <AudioManager>().Play("Delete");
            for (var i = 1; i < _stackN; ++i)
            {
                BlockHandler.DestroyLine(i);
                var x = _stack[i] / 7;
                var y = _stack[i] % 7;
                for (var j = 0; j < i; ++j)
                {
                    BlockHandler.Move(block[_stack[j]], x, y, 0.08f);
                }

                yield return(new WaitForSeconds(0.08f));
            }

            var sum = 0;

            for (var i = 0; i < _stackN; ++i)
            {
                sum += block[_stack[i]].number;
            }
            AddScore(sum);

            var s = 2;
            var k = 0;

            while (s <= sum)
            {
                s *= 2;
            }
            s /= 2;

            BlockHandler.UndoClick(block[_stack[_stackN - 1]]);

            for (var i = 0; i < 5; ++i)
            {
                var p = 0;
                var c = 0;

                for (var j = 0; j < 7; ++j)
                {
                    var x = i * 7 + j;
                    var y = i * 7 + p;

                    if (!block[x].isClicked)
                    {
                        _tmp     = block[x];
                        block[x] = block[y];
                        block[y] = _tmp;

                        _down[y] = c;
                        p++;
                        if (x == _stack[_stackN - 1])
                        {
                            k = y;
                        }
                    }
                    else
                    {
                        BlockHandler.UndoClick(block[x]);
                        c++;
                    }
                }

                for (var j = p; j < 7; ++j)
                {
                    var x = i * 7 + j;
                    BlockHandler.SetNumber(block[x], Rand());
                    BlockHandler.SetPosition(block[x], i, j + c);
                    _down[x] = c;
                }
            }

            BlockHandler.ChangeNumber(block[k], s);
            for (var i = 0; i < 35; ++i)
            {
                BlockHandler.Move(block[i], i / 7, i % 7, 0.6f);
            }
            yield return(null);
        }