コード例 #1
0
    public void Pop(int id)
    {
        _starsPosition.GetBlackByPoint(id, ref _mvs);
        for (int i = 0; i < 102; i++)
        {
            //Debug.Log(_mvs[i]);
        }

        if (_mvs[101] >= 2) //相同颜色的方块>=2
        {
            _selectTotal = (int)_mvs[101];
            //从局面中弹出
            _starsPosition.DoPop(_mvs);
            //消除星星
            int         x, y;
            Star        star;
            List <Star> popStars  = new List <Star>();
            List <Star> moveStars = new List <Star>();
            for (int i = 0; i < _selectTotal; i++)
            {
                x    = _mvs[i] >> 4;
                y    = 9 - (_mvs[i] & 0xf);
                star = _stars[x][y].GetComponent <Star>();
                popStars.Add(star);//添加到要删除星星列表进行逐个删除
                _stars[x].RemoveAt(y);

                for (int j = y; j < _stars[x].Count; j++)
                {
                    star = _stars[x][j].GetComponent <Star>();
                    star.AddMoveDown(_offset);
                    star.isStopMove = true;//设true禁止Update移动,等待逐个删除完成
                    moveStars.Add(star);
                }
            }
            //测试左移
            CheckMoveLeft(moveStars);
            int scoreMul = _game.scoreMul;
            if (scoreMul > 1)
            {
                _game.SetScoreMul(1);
            }
            //一个个删除
            DeleteOneByOne(popStars, moveStars, true, scoreMul);
            //若盘面达到终结,计算奖励分值,结束当前
            CheckGameOver();
        }
    }