示例#1
0
        public void ShowInfo(List <int> data)
        {
            Show(true);
            data = GameTools.SortCardWithOutLaiZi(data, App.GetGameManager <Mahjong2DGameManager>().LaiZiNum);
            int ChildLenth = _grid.transform.childCount;

            while (ChildLenth > 0)
            {
                DestroyImmediate(_grid.transform.GetChild(0).gameObject);
                ChildLenth--;
            }
            for (int i = 0, lenth = data.Count; i < lenth; i++)
            {
                MahjongItem item = GameTools.CreateMahjong(data[i], false).GetComponent <MahjongItem>();
                GameTools.DestroyDragObject(item);
                item.SelfData.Action        = EnumMahJongAction.StandWith;
                item.SelfData.Direction     = EnumMahJongDirection.Vertical;
                item.SelfData.ShowDirection = EnumShowDirection.Self;
                item.SelfData.MahjongLayer  = ConstantData.ShowItemLayler;
                UIEventListener.Get(item.gameObject).onClick = OnClickItem;
                GameTools.AddChild(_grid.transform, item.transform);
                BoxCollider box = item.gameObject.AddComponent <BoxCollider>();
                box.size = new Vector3(item.BGSprite.width, item.BGSprite.height);
            }
            _grid.repositionNow = true;
            _paiBg.width        = (int)(_grid.GetChildList().Count *_grid.cellWidth);
        }
示例#2
0
        private void CreatMahjongData(List <int> data)
        {
            var obj    = new GameObject();
            var item   = new MahjongItem();
            var parent = obj.AddComponent <UIGrid>();

            for (int i = 0, lenth = data.Count; i < lenth; i++)
            {
                item = GameTools.CreateMahjong(data[i], false).GetComponent <MahjongItem>();
                GameTools.DestroyDragObject(item);
                item.SelfData.Action        = EnumMahJongAction.StandWith;
                item.SelfData.Direction     = EnumMahJongDirection.Vertical;
                item.SelfData.ShowDirection = EnumShowDirection.Self;
                item.SelfData.MahjongLayer  = ConstantData.ShowItemLayler;
                GameTools.AddChild(parent.transform, item.transform);
            }
            UIEventListener.Get(parent.gameObject).onClick = OnClickSpecialGangItem;
            var box = parent.gameObject.AddComponent <BoxCollider>();

            box.size             = new Vector3(parent.GetChildList().Count *item.BGSprite.width, item.BGSprite.height);
            box.center           = new Vector3(110, 0, 0);
            parent.cellWidth     = 72;
            parent.repositionNow = true;
            GameTools.AddChild(_grid.transform, parent.transform);
        }
示例#3
0
        /// <summary>
        ///     胡牌
        /// </summary>
        /// <param name="huCards"></param>
        private void InitHuCards(List <int> huCards)
        {
            var lenth = huCards.Count;

            _huPile.transform.localPosition = new Vector3(nextPos, 0);
            for (var i = 0; i < lenth; i++)
            {
                var item = GameTools.CreateMahjong(huCards[i], false);
                item.GetComponent <MahjongItem>().SetHuTag();
                _huPile.AddItem(item, false);
            }
            _handPile.ResetPosition();
            nextPos += lenth * _handPile.Layout.Width;
        }
示例#4
0
        /// <summary>
        /// 手牌
        /// </summary>
        /// <param name="handCards"></param>
        private void InitHandCards(List <int> handCards)
        {
            int lenth = handCards.Count;

            handCards = GameTools.SortCardWithLaiZiOppset(handCards, App.GetGameManager <Mahjong2DGameManager>().LaiZiNum).ToList();
            _handPile.transform.localPosition = new Vector3(nextPos, 0);
            for (int i = 0; i < lenth; i++)
            {
                Transform item = GameTools.CreateMahjong(handCards[i], false);
                item.GetComponent <MahjongItem>().JudgeHunTag(App.GetGameManager <Mahjong2DGameManager>().LaiZiNum);
                _handPile.AddItem(item, false);
            }
            _handPile.ResetPosition();
            nextPos += lenth * _handPile.Layout.Width + GroupTypeCell + HuCardTypeCell;
        }
示例#5
0
        public virtual Transform AddCard(int value, bool isSingle, bool changeNumber = true)
        {
            Transform newMahJong = GameTools.CreateMahjong(value, changeNumber);

            ParseItemToThis(newMahJong);
            if (isSingle)
            {
                MahjongItem item = newMahJong.GetComponent <MahjongItem>();
                SetMahjongAsNewGetIn(item);
            }
            else
            {
                AddItem(newMahJong);
            }
            newMahJong.GetComponent <MahjongItem>().JudgeHunTag(App.GetGameManager <Mahjong2DGameManager>().LaiZiNum);
            return(newMahJong);
        }
示例#6
0
        /// <summary>
        /// 胡牌
        /// </summary>
        /// <param name="huCards"></param>
        private void InitHuCards(List <int> huCards, bool showHuTag = true)
        {
            int lenth = huCards.Count;

            _huPile.transform.localPosition = new Vector3(nextPos, 0);
            for (int i = 0; i < lenth; i++)
            {
                Transform item = GameTools.CreateMahjong(huCards[i], false);
                if (showHuTag)
                {
                    item.GetComponent <MahjongItem>().SetHuTag();
                }
                _huPile.AddItem(item, false);
            }
            _handPile.ResetPosition();
            nextPos += lenth * _handPile.Layout.Width + GroupTypeCell;
        }
示例#7
0
        public virtual Transform AddCard(int value, bool isSingle, bool changeNumber = true)
        {
            var newMahJong = GameTools.CreateMahjong(value, changeNumber);

            ParseItemToThis(newMahJong);
            if (isSingle)
            {
                var item = newMahJong.GetComponent <MahjongItem>();
                ParseItemToThis(item);
                NewCard.GetIn = item;
                GameTools.AddChild(NewCard.transform, item.transform, ItemScaleX, ItemScaleY);
            }
            else
            {
                AddItem(newMahJong);
            }
            newMahJong.GetComponent <MahjongItem>().JudgeHunTag(App.GetGameManager <Lyzz2DGameManager>().LaiZiNum);
            return(newMahJong);
        }
示例#8
0
        public void DealGroupData(List <List <int> > groupData)
        {
            if (GroupPile)
            {
                var count = groupData[0].Count;
                switch (count)
                {
                case 3:
                    GroupPile.Layout.maxPerLine       = 5;
                    GroupPile.Layout.Width            = 190;
                    GroupPile.transform.localPosition = new Vector3(70, 0, 0);
                    break;

                case 4:
                    GroupPile.Layout.maxPerLine       = 4;
                    GroupPile.Layout.Width            = 250;
                    GroupPile.transform.localPosition = new Vector3(15, 0, 0);
                    break;
                }
                GroupPile.ResetPile();
                foreach (var group in groupData)
                {
                    MahjongGroupData data = new MahjongGroupData(GroupType.Other);
                    data.values = group.ToArray();
                    var mahJongList = new List <MahjongItem>();
                    for (int i = 0; i < group.Count; i++)
                    {
                        mahJongList.Add(GameTools.CreateMahjong(group[i], false).GetComponent <MahjongItem>());
                    }
                    var         groupItem = GroupPile.AddGroup(data, mahJongList, false);
                    BoxCollider box       = groupItem.gameObject.AddComponent <BoxCollider>();
                    box.size   = new Vector3(GroupPile.Layout.Width, GroupPile.Layout.Height);
                    box.center = new Vector3(GroupPile.Layout.Width / 3, 0);
                    UIEventListener.Get(groupItem.gameObject).onClick = OnGroupItemClick;
                }
                var bound = GroupPile.Layout.GetLayoutBounds();
                CardsBg.width  = (int)(bound.x + BgBaseBounds.x);
                CardsBg.height = (int)(bound.y + BgBaseBounds.y);
            }
        }
示例#9
0
        /// <summary>
        ///     设置组牌中的UI显示
        /// </summary>
        /// <param name="data"></param>
        /// <param name="IsOther"></param>
        /// <returns></returns>
        public virtual Transform SetGroup(MahjongGroupData data, List <MahjongItem> items, float groupWidth,
                                          float groupHeight, float fourOffsetY, bool IsOther, DefLayout.Directon direction, bool changeNum = true)
        {
            _data = data;
            var values = data.values;
            var pos    = Vector3.zero;

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

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

                case GroupType.AnGang:
                case GroupType.FengGang:
                    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:
                    newTran = null;
                    YxDebug.LogError("There is not exist such GroupType " + data.type);
                    break;
                }
                if (i == 3)
                {
                    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(transform);
        }