コード例 #1
0
    /**打乱*/
    public void Upset()
    {
        //获取星星颜色,位置id,准备打乱
        List <int> cors   = new List <int>();
        List <int> posIds = new List <int>();
        Star       star;
        int        i, j;

        for (i = 0; i < 10; i++)
        {
            for (j = 0; j < _stars[i].Count; j++)
            {
                star = _stars[i][j].GetComponent <Star>();
                cors.Add(star.color);
                posIds.Add(star.posId);
                star.Dispose();
            }
            _stars[i].Clear();
            for (j = 0; j < 10; j++)
            {
                _stars[i].Add(null);
            }
        }
        int[] corArr   = cors.ToArray();
        int[] posIdArr = posIds.ToArray();
        RandomArr.Randomize(corArr, corArr.Length);
        //重建
        StarsBoard[] starsBoards = new StarsBoard[] { new StarsBoard(), new StarsBoard(), new StarsBoard(), new StarsBoard(), new StarsBoard() };
        for (i = 0; i < 5; i++)
        {
            starsBoards[i].SetAll(false);
        }
        int cor; int posId;

        for (i = 0; i < corArr.Length; i++)
        {
            cor   = corArr[i];
            posId = posIdArr[i];
            starsBoards[cor].SetTrue(posId);
            PushStar(cor, posId);
        }
        _starsPosition = new StarsPosition(starsBoards);
        //移除空的元素
        i = _stars.Length;
        while (--i >= 0)
        {
            j = _stars[i].Count;
            while (--j >= 0)
            {
                if (!_stars[i][j])
                {
                    _stars[i].RemoveAt(j);
                }
            }
        }
    }
コード例 #2
0
 public void Dispose()
 {
     _starsPosition = null;
     _mvs           = null;
     for (int i = 0; i < _stars.Length; i++)
     {
         for (int j = 0; j < _stars[i].Count; j++)
         {
             Object.Destroy(_stars[i][j].gameObject);
         }
     }
 }
コード例 #3
0
    public void NewStarsPosition(int[] cnts)
    {
        //清理
        _selectTotal = 0;
        int i; int j;

        for (i = 0; i < 10; i++)
        {
            for (j = 0; j < _stars[i].Count; j++)
            {
                _stars[i][j].GetComponent <Star>().Dispose();
            }
            _stars[i].Clear();
            for (j = 0; j < 10; j++)
            {
                _stars[i].Add(null);
            }
        }

        //新建
        int id;

        StarsBoard[] starsBoards = new StarsBoard[] { new StarsBoard(), new StarsBoard(), new StarsBoard(), new StarsBoard(), new StarsBoard() };
        for (i = 0; i < 5; i++)
        {
            starsBoards[i].SetAll(false);
            for (j = 0; j < cnts[i]; j++)
            {
                id = RandomArr.GetNextRandomElement();
                starsBoards[i].SetTrue(id);
                PushStar(i, id, true);
            }
            //Debug.Log( starsBoards[i].toString());
        }
        _starsPosition = new StarsPosition(starsBoards);
    }