Exemple #1
0
        public void SetMahjongValue(int v)
        {
            mahjongValue = v;
            Sprite[] allImagesHolding = Resources.LoadAll <Sprite>("h");
            Image    holdingImage     = holding.GetComponent <Image>();

            holdingImage.sprite = allImagesHolding[MJHelper.ConvertValueToHoldingImageIndex(v)];
            holdingImage.SetNativeSize();

            Sprite[] allImagesOpened = Resources.LoadAll <Sprite>("o");
            Image    openImage       = opened.GetComponent <Image>();

            openImage.sprite = allImagesOpened[MJHelper.ConvertValueToHoldingImageIndex(v)];
            openImage.SetNativeSize();
        }
Exemple #2
0
        private void InitAllTiles(int row, int col)
        {
            Debug.Log("[MyTilesScript] [InitAllTiles] row:" + row + " col:" + col);
            List <Transform> allTiles  = new List <Transform>();
            List <int>       indexList = MJHelper.GenerateForFirstChoose(13);

            // GridLayoutGroup gridLayoutGroup = GetComponent<GridLayoutGroup>();
            // gridLayoutGroup.constraint = GridLayoutGroup.Constraint.FixedRowCount;
            // gridLayoutGroup.constraintCount = row;
            indexList.Sort();
            for (int i = 0; i < indexList.Count; i++)
            {
                if (CreateMahjongByValue(indexList[i]) == false)
                {
                    break;
                }
            }
        }
Exemple #3
0
        private void InitAllTiles(int row, int col)
        {
            Debug.Log("[InitAllTiles] row:" + row + " col:" + col);

            List <Transform> allTiles        = new List <Transform>();
            List <int>       indexList       = MJHelper.GenerateForFirstChoose(row * col);
            GridLayoutGroup  gridLayoutGroup = GetComponent <GridLayoutGroup>();

            gridLayoutGroup.constraint = GridLayoutGroup.Constraint.Flexible;
            // gridLayoutGroup.constraintCount = row;

            for (int i = 0; i < indexList.Count; i++)
            {
                GameObject newCell = Instantiate <GameObject>(mahjongPrefab) as GameObject;
                Mahjong    mahjong = newCell.GetComponent <Mahjong>() as Mahjong;
                mahjong.SetMahjongValue(indexList[i]);
                mahjong.SetStatus(Mahjong.Status.Selecting);
                // mahjong.SetStatus(Mahjong.Status.Closed);
                newCell.transform.SetParent(this.gameObject.transform, false);
            }
        }