Ejemplo n.º 1
0
        public void AddPokerTriggerOnClick(MonoBehaviour target, PokerCard poker, string mothName)
        {
            var trigger = GetUiEventTrigger(poker);
            var ed      = GetEventDelegate(target, poker, mothName);

            EventDelegate.Add(trigger.onClick, ed);
        }
Ejemplo n.º 2
0
        protected EventDelegate GetEventDelegate(MonoBehaviour target, PokerCard poker, string mothName)
        {
            var ed = new EventDelegate(target, mothName);

            ed.parameters[0] = new EventDelegate.Parameter(poker, "PokerCard");
            return(ed);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 检测扑克个数
        /// </summary>
        protected virtual void InitPokerList()
        {
            if (CardsList.Count == CardCount)
            {
                return;
            }


            if (CardsList.Count > CardCount)
            {
                //删除多余的牌
                int count = CardsList.Count - CardCount;
                for (int i = 0; i < count; i++)
                {
                    var temp = CardsList[i];
                    CardsList.Remove(temp);
                    Destroy(temp);
                }
            }
            else
            {
                int count = CardCount - CardsList.Count;
                for (int i = 0; i < count; i++)
                {
                    PokerCard clone = Instantiate(CardPrefab);
                    clone.transform.parent     = PokerParent;
                    clone.name                 = "poker " + i;
                    clone.transform.localScale = Vector3.one * .6f;
                    clone.GetComponent <PokerCard>().SetCardDepth(130 + i * 2);
                    CardsList.Add(clone);
                }
            }
        }
Ejemplo n.º 4
0
 public override void OnDragOverCard(PokerCard card)
 {
     if (_isFinish)
     {
         return;
     }
     OnClickCard(card);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 代理添加事件,当点击每道的牌时
 /// </summary>
 /// <param name="card"></param>
 void OnClickLinePoker(PokerCard card)
 {
     if (!_isFinish)
     {
         return;
     }
     ExchangeCard(card);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 设置一张牌,包括大小,显示层级等信息
        /// </summary>
        /// <param name="card"></param>
        public void SetOneCard(PokerCard card)
        {
            card.name                 = "line";
            card.transform.parent     = PokerParent.transform;
            card.transform.localScale = Vector3.one * 0.6f;
            card.SetCardDepth(BaseDepth + CardList.Count * 4);
            CardList.Add(card);

            //不可点击
            card.gameObject.SetActive(false);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 点击扑克按钮
        /// </summary>
        /// <param name="card"></param>
        public override void OnClickCard(PokerCard card)
        {
            bool selected = !card.IsSelect;

            //反选牌
            SelectCard(card, selected);

            if (!selected)
            {
                _selectInfo.Dun.Cards.Remove(card.Id);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 更换两张牌的位置
        /// </summary>
        public void ExchangePokersPosition(PokerCard poker1, PokerCard poker2)
        {
            if (poker1 == null || poker2 == null)
            {
                return;
            }
            Facade.Instance <MusicManager>().Play("select");
            Vector3 tempPos = poker1.transform.localPosition;

            poker1.MoveTo(poker1.transform.localPosition, poker2.transform.localPosition);
            poker2.MoveTo(poker2.transform.localPosition, tempPos);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 将牌变为选择的方案牌型
        /// </summary>
        /// <param name="intList"></param>
        void ChoisePlane(List <int> intList)
        {
            //第一次选择的时候不用换牌,直接赋值
            if (_lastList == null || _lastList.Count == 0)
            {
                for (int i = 0; i < intList.Count; i++)
                {
                    PokerCard ca = CardsList[i].GetComponent <PokerCard>();
                    ca.SetCardId(intList[i]);
                    ca.SetCardFront();
                }
                return;
            }

            List <int> tempList = _lastList.GetRange(0, 13);

            if (intList.Count != tempList.Count)
            {
                YxDebug.LogError("码牌数据错误");
                return;
            }

            bool change = false;

            for (int i = 0; i < tempList.Count; i++)
            {
                int index   = i;
                var tempObj = CardsList[i];
                if (intList[i] != tempList[i])
                {
                    index = tempList.IndexOf(intList[i]);

                    CardsList[i]     = CardsList[index];
                    CardsList[index] = tempObj;

                    int tempInt = tempList[i];
                    tempList[i]     = tempList[index];
                    tempList[index] = tempInt;
                    --i;
                    change = true;
                }
                PokerCard card = tempObj.GetComponent <PokerCard>();
                card.MoveTo(CardsList[index].transform.localPosition, RepositionCard(index));
            }
            if (change)
            {
                Facade.Instance <MusicManager>().Play("select");
            }

            _lastList = tempList;
            ResetSelectedCards();
        }
Ejemplo n.º 10
0
 void ResetSelectedCards()
 {
     if (_selectPok1 != null)
     {
         _selectPok1.SetCardSelected(false);
         _selectPok1 = null;
     }
     if (_selectPok2 != null)
     {
         _selectPok2.SetCardSelected(false);
         _selectPok2 = null;
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取扑克在数组中的索引
        /// </summary>
        /// <param name="cardList"></param>
        /// <param name="card"></param>
        /// <param name="from"></param>
        /// <returns></returns>
        int GetPokerIndex(List <PokerCard> cardList, PokerCard card, int from)
        {
            int count = cardList.Count;

            for (int i = from; i < count; i++)
            {
                if (cardList[i].Equals(card))
                {
                    return(i);
                }
            }
            return(0);
        }
Ejemplo n.º 12
0
 public void Reset()
 {
     _dealing = false;
     foreach (GameObject poker in _pokerList)
     {
         poker.SetActive(false);
         PokerCard pokerCard = poker.GetComponent <PokerCard>();
         pokerCard.SetCardId(0);
         pokerCard.SetCardFront();
     }
     _pokerCounter = 0;
     ShootItemList.Clear();
     StopAllCoroutines();
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 逐行展示手牌
        /// </summary>
        /// <param name="line">行数</param>
        /// <param name="cardValueList">牌</param>
        /// <param name="type">牌型</param>
        public void ShowHandPoker(int line, List <int> cardValueList, CardType type)
        {
            int beginIndex = 0;
            int count      = 0;

            InitRange(line, ref beginIndex, ref count);

            List <PokerCard> curShowCards = new List <PokerCard>();

            //设置显示手牌
            for (int i = 0; i < UserCardList.Count; i++)
            {
                GameObject obj = UserCardList[i];
                if (i >= beginIndex && i < beginIndex + count)
                {
                    obj.transform.localScale = Vector3.one * (_scale + .1f);
                    PokerCard card = obj.GetComponent <PokerCard>();
                    card.SetCardDepth(100 + i * 2);
                    card.SetCardId(cardValueList[i]);
                    card.SetCardFront();
                    curShowCards.Add(card);
                }
                else
                {
                    obj.transform.localScale = Vector3.one * _scale;
                    obj.GetComponent <PokerCard>().SetCardDepth(i * 2);
                }
            }

            string typeName;

            if (line == 0 && type == CardType.santiao)
            {
                typeName = "chongsan";
            }
            else if (line == 1 && type == CardType.hulu)
            {
                typeName = "zhongdunhulu";
            }
            else
            {
                typeName = type.ToString();
            }

            App.GetGameManager <SssGameManager>().PlayOnesSound(typeName, Info.Seat);
            HandCardsType.ShowType(line, typeName); //显示手牌牌型

            StartCoroutine(HideHandPoker(line, beginIndex, count));
        }
Ejemplo n.º 14
0
        private void ExchangeCard(PokerCard card)
        {
            if (_selectPok1 == null)
            {
                _selectPok1 = card;
                _selectPok1.SetCardSelected(true);
                return;
            }

            if (_selectPok2 == null)
            {
                if (_selectPok1.Equals(card))
                {
                    ResetSelectedCards();
                    return;
                }
                _selectPok2 = card;
            }

            int cardId1 = _selectPok1.Id;
            int cardId2 = _selectPok2.Id;

            int len = Lines.Length;

            for (int i = 0; i < len; i++)
            {
                var lineInfo = Lines[i].LineInfo;
                var valList  = lineInfo.Dun.Cards;
                int count    = valList.Count;
                for (int j = 0; j < count; j++)
                {
                    if (valList[j] == cardId1)
                    {
                        valList[j] = cardId2;
                        GetLineInfo(valList, i);
                        continue;
                    }

                    if (valList[j] == cardId2)
                    {
                        valList[j] = cardId1;
                        GetLineInfo(valList, i);
                    }
                }
            }

            ResetSelectedCards();
        }
Ejemplo n.º 15
0
        public override void OnClickCard(PokerCard card)
        {
            if (_selectPok1 == null)
            {
                _selectPok1 = card;
                _selectPok1.SetCardSelected(true);
                return;
            }

            if (_selectPok2 == null)
            {
                if (_selectPok1.Equals(card))
                {
                    ResetSelectedCards();
                    return;
                }
                _selectPok2 = card;
            }

            int        index1   = CardsList.IndexOf(_selectPok1);
            int        index2   = CardsList.IndexOf(_selectPok2);
            List <int> tempList = new List <int>(_lastList);
            int        tempInt  = tempList[index1];

            tempList[index1] = tempList[index2];
            tempList[index2] = tempInt;

            ExchangePokersPosition(_selectPok1, _selectPok2);
            var tempObj = CardsList[index1];

            CardsList[index1] = CardsList[index2];
            CardsList[index2] = tempObj;
            _lastList         = tempList;

            foreach (ChoiseItem item in _choiseItems)
            {
                item.SelectMark.SetActive(false);
            }
            _lastChoiseItem = null;
            ResetSelectedCards();
        }
Ejemplo n.º 16
0
        IEnumerator HideHandPoker(int line, int beginIndex, int count)
        {
            yield return(new WaitForSeconds(1.5f));

            HandCardsType.HideType(line);

            for (int i = 0; i < count; i++)
            {
                int index = beginIndex + i;
                if (index >= UserCardList.Count || UserCardList[index] == null)
                {
                    break;
                }

                GameObject obj   = UserCardList[index];
                PokerCard  poker = obj.GetComponent <PokerCard>();
                poker.transform.localScale = Vector3.one * _scale;
                poker.SetCardDepth((beginIndex + i) * 2);
            }

            StopAllCoroutines();
        }
Ejemplo n.º 17
0
        public override void Reset()
        {
            _selectPok1 = null;
            _selectPok2 = null;
            _lastList   = null;

            foreach (var card in CardsList)
            {
                var pokerCard = card.GetComponent <PokerCard>();
                pokerCard.SetCardId(0);
                pokerCard.SetCardFront();
            }
            _curCardValList.Clear();

            foreach (ChoiseItem item in _choiseItems)
            {
                if (item != null)
                {
                    item.Reset();
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 选牌
        /// </summary>
        /// <param name="card"></param>
        /// <param name="isSelect"></param>

        void SelectCard(PokerCard card, bool isSelect)
        {
            card.IsSelect = isSelect;
            if (isSelect)
            {
                MoveYTo(card.transform, 10);
                var selectCards = _selectInfo.SelectedCards;
                if (!selectCards.Contains(card))
                {
                    selectCards.Add(card);
                }

                var dunCards = _selectInfo.Dun.Cards;
                if (!dunCards.Contains(card.Id))
                {
                    dunCards.Add(card.Id);
                }
            }
            else
            {
                MoveYTo(card.transform, 0);
                _selectInfo.SelectedCards.Remove(card);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 初始化每道
        /// </summary>
        private void InitLines()
        {
            int len = Lines.Length;

            for (int i = 0; i < len; i++)
            {
                var line = Lines[i];
                var btn  = line.SelectBtn;

                //初始化选择按钮点击按钮事件
                if (btn != null)
                {
                    CreateEventDelegate(this, "OnClickSelectBtn", btn, i);
                }

                //初始化取消按钮点击按钮事件
                btn = line.ReselectBtn;
                if (btn != null)
                {
                    CreateEventDelegate(this, "OnClickReselectBtn", btn, i);
                }

                int count = i == 0 ? 3 : 5;
                if (line.CardList.Count == count)
                {
                    continue;                                   //已经有这么多牌了 无需创建牌
                }
                for (int j = 0; j < count; j++)
                {
                    PokerCard poker = Instantiate(CardPrefab);
                    AddPokerTriggerOnClick(this, poker, "OnClickLinePoker");
                    line.SetOneCard(poker);
                }
                line.ParentReposition();
            }
        }
Ejemplo n.º 20
0
 public virtual void OnDragOverCard(PokerCard card)
 {
 }
Ejemplo n.º 21
0
 public virtual void OnClickCard(PokerCard card)
 {
 }
Ejemplo n.º 22
0
 protected UIEventTrigger GetUiEventTrigger(PokerCard card)
 {
     return(card.GetComponentInChildren <UIEventTrigger>());
 }
Ejemplo n.º 23
0
 public void AddPokerEvent(PokerCard poker)
 {
     AddPokerTriggerOnClick(this, poker, "OnClickCard");
     AddPokerTriggerOnDragOver(this, poker, "OnDragOverCard");
 }