Exemplo n.º 1
0
        public GameObject GetUIMahjong(int card, UIMahjongType uiType)
        {
            var obj = Instantiate(MahjongCardAssets.UIMahjong[(int)uiType]);

            switch (uiType)
            {
            case UIMahjongType.Big:
                obj.CardValue.sprite = GetMahjongSprite(card);
                obj.CardValue.SetNativeSize();
                break;

            case UIMahjongType.Small:
                obj.CardValue.sprite = GetMahjongSmallSprite(card);
                obj.CardValue.SetNativeSize();
                break;
            }

            var flag = GameCenter.DataCenter.IsLaizi(card);

            if (flag)
            {
                obj.SetLaizi();
            }
            return(obj.gameObject);
        }
Exemplo n.º 2
0
 public GameObject GetUIMahjongBg(UIMahjongType type)
 {
     return(Instantiate(MahjongCardAssets.UIMahjongBg[(int)type]).gameObject);
 }
Exemplo n.º 3
0
        public UiCardGroup GetUIMahjongGroup(IList <int> cards, UIMahjongType uiType, EnGroupType cpgType = EnGroupType.None, bool isHaveBg = false)
        {
            Vector2 mjSize = Vector2.zero;

            GameObject[] list = new GameObject[cards.Count];
            UiCardGroup  cardGroup;

            switch (uiType)
            {
            case UIMahjongType.Big:
                mjSize = mSizeBig;
                break;

            case UIMahjongType.Small:
                mjSize = mSizeSmall;
                break;
            }
            if (cpgType == EnGroupType.XFDan || cpgType == EnGroupType.YaoDan || cpgType == EnGroupType.JiuDan || cpgType == EnGroupType.ZFBDan)
            {
                List <int>            cardsList = new List <int>();
                Dictionary <int, int> dic       = new Dictionary <int, int>();
                for (int i = 0; i < cards.Count; i++)
                {
                    if (!dic.ContainsKey(cards[i]))
                    {
                        dic[cards[i]] = 1;
                        cardsList.Add(cards[i]);
                    }
                    else
                    {
                        dic[cards[i]]++;
                    }
                }
                GameObject[] xjfdList = new GameObject[cardsList.Count];
                for (int i = 0; i < cardsList.Count; i++)
                {
                    if (dic.ContainsKey(cardsList[i]))
                    {
                        xjfdList[i] = GetUIMahjong(cardsList[i], uiType);
                        if (dic[cardsList[i]] > 1)
                        {
                            //GameObject temp = MahjongUtility.GetScriptableAssets<MahjongMiscAssets>().GetAssetToObj("NumSign" + dic[cardsList[i]]);
                            GameObject temp = GameUtils.GetAssets <GameObject>("NumSign" + dic[cardsList[i]]);
                            temp.SetActive(false);
                            var obj = Instantiate(temp);
                            if (obj != null)
                            {
                                obj.transform.parent        = xjfdList[i].transform;
                                obj.transform.localRotation = Quaternion.Euler(0, 0, 0);
                                obj.gameObject.layer        = xjfdList[i].gameObject.layer;
                                switch (uiType)
                                {
                                case UIMahjongType.Big:
                                    obj.transform.localPosition = new Vector3(-20, -37, 0);
                                    obj.transform.localScale    = Vector3.one * 0.7f;
                                    break;

                                case UIMahjongType.Small:
                                    obj.transform.localPosition = new Vector3(-7, -3f, 0);
                                    obj.transform.localScale    = Vector3.one * 0.4f;
                                    break;
                                }
                                obj.SetActive(true);
                            }
                        }
                    }
                }
                cardGroup = UiCardGroup.Create(xjfdList, mjSize, isHaveBg ? MahjongCardAssets.TileBackground : null, cpgType);
            }
            else
            {
                for (int i = 0; i < cards.Count; i++)
                {
                    //暗杠时显示背面, 第四张要反过来
                    if (cpgType == EnGroupType.AnGang && i < 3)
                    {
                        list[i] = GetUIMahjongBg(uiType);
                    }
                    else
                    {
                        list[i] = GetUIMahjong(cards[i], uiType);
                    }
                }
                cardGroup = UiCardGroup.Create(list, mjSize, isHaveBg ? MahjongCardAssets.TileBackground : null, cpgType);
            }
            return(cardGroup);
        }