Пример #1
0
        public static UiCardGroup create(GameObject[] objList, Vector2 MjSize, Sprite bg, EnGroupType cpgType = EnGroupType.None)
        {
            GameObject  obj = new GameObject();
            UiCardGroup ret = obj.AddComponent <UiCardGroup>();

            ret._mjSize = MjSize;
            ret.AddObj(objList);

            //根据暗杠的形式摆牌
            if (cpgType == EnGroupType.AnGang)
            {
                ret.SortAnGangGroup();
                return(ret);
            }

            ret.Sort();

            if (bg != null)
            {
                Image imgBg = obj.AddComponent <Image>();
                imgBg.sprite = bg;
                imgBg.type   = Image.Type.Sliced;
                //设置底图大小 要比大
                RectTransform rtf = obj.GetComponent <RectTransform>();
                rtf.sizeDelta = new Vector2(ret.ObjList.Count * ret._mjSize.x + 20, ret._mjSize.y + 20);

                obj.AddComponent <Button>();
            }

            return(ret);
        }
Пример #2
0
        public UiCardGroup GetGroup(int[] value, EnD2MjType type, bool isHaveBg = false, int laizi = UtilDef.NullMj, EnGroupType cpgType = EnGroupType.None)
        {
            GameObject[] list   = new GameObject[value.Length];
            Vector2      mjSize = new Vector2();

            for (int i = 0; i < value.Length; i++)
            {
                list[i] = GetMj(value[i], type, laizi, cpgType, i);

                switch (type)
                {
                case EnD2MjType.Me:
                    mjSize = MjSizeMe;
                    break;

                case EnD2MjType.Up:
                    mjSize = MjSizeUp;
                    break;
                }
            }
            //tileBack_up_0
            UiCardGroup cardGroup = UiCardGroup.create(list, mjSize, isHaveBg ? Bg : null, cpgType);

            return(cardGroup);
        }
Пример #3
0
        //0 以左对齐,1 中心对齐
        public void Sort(int sortType)
        {
            _startPos    = 0;
            GroupsLength = 0;

            for (int i = 0; i < _groups.Count; i++)
            {
                UiCardGroup cardGroup = _groups[i];
                _startPos = _startPos + cardGroup.Width / 2;
                cardGroup.transform.localPosition = new Vector3(_startPos, 0);
                _startPos  = _startPos + cardGroup.Width / 2;
                _startPos += Interval;

                GroupsLength += cardGroup.Width;
            }

            GroupsLength += (_groups.Count - 1) * Interval;

            float addDis = 0;

            if (sortType == 0)
            {
                addDis = -Size.x / 2;
            }
            else if (sortType == 1)
            {
                addDis = -GroupsLength / 2;
            }

            for (int i = 0; i < _groups.Count; i++)
            {
                UiCardGroup cardGroup = _groups[i];
                cardGroup.transform.localPosition += new Vector3(addDis, 0);
            }
        }
Пример #4
0
        public void AddUiCdGroup(UiCardGroup cardGroup)
        {
            cardGroup.transform.parent     = transform;
            cardGroup.transform.localScale = Vector3.one;

            _groups.Add(cardGroup);
        }
Пример #5
0
        public virtual void SetCpgCardJp(List <CpgData> value, int laizi = UtilDef.NullMj)
        {
            foreach (CpgData cpgData in value)
            {
                UiCardGroup uiGroup = D2MahjongMng.Instance.GetGroup(cpgData.AllCards().ToArray(), EnD2MjType.Up, false, laizi, cpgData.Type);

                CardGroup.AddUiCdGroup(uiGroup);
            }
        }
Пример #6
0
        public UiCardGroup GetGroup(int value, EnD2MjType type, bool isHaveBg = false, int laizi = UtilDef.NullMj)
        {
            GameObject[] list   = new GameObject[1];
            Vector2      mjSize = new Vector2();

            list[0] = GetMj(value, type, laizi);
            switch (type)
            {
            case EnD2MjType.Me:
                mjSize = MjSizeMe;
                break;

            case EnD2MjType.Up:
                mjSize = MjSizeUp;
                break;
            }

            UiCardGroup cardGroup = UiCardGroup.create(list, mjSize, isHaveBg ? Bg : null);

            return(cardGroup);
        }
Пример #7
0
        public virtual void SetChooseCg(List <int[]> cgList, DVoidInt call, int outPutCard = UtilDef.NullMj)
        {
            gameObject.SetActive(true);
            CgGroup.Clear();

            for (int i = 0; i < cgList.Count; i++)
            {
                var valueList = new List <int>(cgList[i]);
                if (valueList.Count < 4 && outPutCard != UtilDef.NullMj)
                {
                    valueList.Add(outPutCard);
                }

                valueList.Sort((a, b) =>
                {
                    if (a > b)
                    {
                        return(1);
                    }
                    if ((a < b))
                    {
                        return(-1);
                    }
                    return(0);
                });

                UiCardGroup group = D2MahjongMng.Instance.GetGroup(valueList.ToArray(), EnD2MjType.Me, true);
                CgGroup.AddUiCdGroup(group);
                int i1 = i;
                group.SetClickCallFunc(() =>
                {
                    UtilFunc.OutPutArray(cgList[i1], "选着的牌");
                    call(i1);
                    gameObject.SetActive(false);
                });
            }

            CgGroup.Sort(1);
        }
Пример #8
0
        public virtual void SetHuCard(int value)
        {
            UiCardGroup uiGroupCard = D2MahjongMng.Instance.GetGroup(value, EnD2MjType.Up);

            CardGroup.AddUiCdGroup(uiGroupCard);
        }
Пример #9
0
        public virtual void SetHardCard(int[] value, int laizi)
        {
            UiCardGroup uiGroupCard = D2MahjongMng.Instance.GetGroup(value, EnD2MjType.Up, false, laizi);

            CardGroup.AddUiCdGroup(uiGroupCard);
        }