Exemple #1
0
 public void SetNewItem(MahjongItem item, int value, EnumMahJongAction action)
 {
     item.Value           = value;
     item.SelfData.Action = action;
     item.SetColor(Color.white);
     GameTools.AddChild(transform, item.transform);
     _itemList.Add(item);
 }
Exemple #2
0
        /// <summary>
        /// 设置组牌中的UI显示
        /// </summary>
        /// <param name="data"></param>
        /// <param name="isOther"></param>
        /// <returns></returns>
        public virtual List <MahjongItem> SetGroup(MahjongGroupData data, List <MahjongItem> items, float groupWidth, float groupHeight, float fourOffsetY, bool isOther, Directon direction, bool changeNum = true)
        {
            _data = data;
            int[]   values = data.values;
            Vector3 pos    = Vector3.zero;

            if (items == null)
            {
                items = new List <MahjongItem>();
                foreach (var value in values)
                {
                    items.Add(GameTools.CreateMahjong(value, changeNum).GetComponent <MahjongItem>());
                }
            }
            bool isHorizontal = direction.Equals(Directon.Horizontal);

            for (int i = 0, lenth = values.Length; i < lenth; i++)
            {
                MahjongItem item = items[i];
                if (item == null)
                {
                    YxDebug.LogError("找不到一张牌了?");
                }
                Transform newTran = item.transform;
                switch (data.type)
                {
                case GroupType.Chi:
                case GroupType.Peng:
                case GroupType.MingGang:
                case GroupType.ZhuaGang:
                case GroupType.PengGang:
                case GroupType.CaiGang:
                case GroupType.FengGang:
                    SetNewItem(item, values[i], EnumMahJongAction.Lie);
                    break;

                case GroupType.AnGang:
                    if (isOther)
                    {
                        SetNewItem(item, values[i], EnumMahJongAction.Push);
                    }
                    else
                    {
                        if (i != 3)
                        {
                            SetNewItem(item, values[i], EnumMahJongAction.Push);
                        }
                        else
                        {
                            SetNewItem(item, values[i], EnumMahJongAction.Lie);
                        }
                    }
                    break;

                case GroupType.JueGang:
                    if (isOther)
                    {
                        SetNewItem(item, values[i], EnumMahJongAction.Push);
                    }
                    else
                    {
                        if (i != 1)
                        {
                            SetNewItem(item, values[i], EnumMahJongAction.Push);
                        }
                        else
                        {
                            SetNewItem(item, values[i], EnumMahJongAction.Lie);
                        }
                    }
                    break;

                default:
                    SetNewItem(item, values[i], EnumMahJongAction.Lie);
                    break;
                }
                if (i == 3 && data.type != GroupType.Other)
                {
                    if (isHorizontal)
                    {
                        pos.x = 1 * groupWidth;
                        pos.y = pos.y + fourOffsetY;
                    }
                    else
                    {
                        pos.y = 1 * groupHeight + fourOffsetY;
                    }
                }
                else
                {
                    if (isHorizontal)
                    {
                        pos.x = i * groupWidth;
                    }
                    else
                    {
                        pos.y = i * groupHeight;
                    }
                }
                newTran.localPosition = pos;
            }
            return(items);
        }
Exemple #3
0
 public void RefreshGroup(MahjongItem addItem)
 {
     addItem.SelfData.Action = EnumMahJongAction.Lie;
 }