コード例 #1
0
        /// <summary>
        /// 生成牌
        /// </summary>
        /// <param name="poker"></param>
        /// <returns></returns>
        private UIItemPoker_ShiSanZhang SpawnPoker(Poker poker, bool isPlayAnimation)
        {
            Transform trans = UIPoolManager.Instance.Spawn("UIItemPoker_ShiSanZhang");
            UIItemPoker_ShiSanZhang item = trans.GetComponent <UIItemPoker_ShiSanZhang>();

            item.Init(poker, isPlayAnimation, true);
            return(item);
        }
コード例 #2
0
 private void ResetDragPoker()
 {
     m_StartSelectedPoker = null; //初始选中的牌
     m_EndSelectedPoker   = null; //结束选中的牌
     m_IsSelectedPoker    = false;
     m_CurrSelectedPoker.Clear(); //当前拖拽选中的牌
     m_CurrLiftUpPoker.Clear();   //当前抬起的牌
 }
コード例 #3
0
        protected override void OnUpdate()
        {
            base.OnUpdate();
            if (ShiSanZhangGameCtrl.Instance.CommandQueue.Count > 0)
            {
                IGameCommand command = ShiSanZhangGameCtrl.Instance.CommandQueue.Dequeue();
                command.Execute();
            }

            if (!m_IsSelectedPoker && Input.GetMouseButtonDown(0))
            {
                if (RoomShiSanZhangProxy.Instance.CurrentRoom.SszRoomStatus != ROOM_STATUS.ROOM_STATUS_MATEPOKER)
                {
                    return;
                }

                Ray ray = m_UISceneShiSanZhangView.CurrentCamare.ScreenPointToRay(Input.mousePosition);

                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                {
                    Debug.Log("-------------Ray ray -----------------");
                    if (hit.transform.gameObject.layer != 1 << LayerMask.NameToLayer("PlayerHand"))
                    {
                        return;
                    }
                }
                UIItemPoker_ShiSanZhang ctrl = GetRayHitPoker();
                if (ctrl != null)
                {
                    m_EndSelectedPoker = null;   //结束选中的牌
                    m_CurrSelectedPoker.Clear(); //当前拖拽选中的牌
                    //获得第一张牌
                    m_StartSelectedPoker = ctrl;
                    m_CurrSelectedPoker.Add(ctrl);
                    m_IsSelectedPoker = true;
                    ctrl.SetSelected(true);
                }
            }
            if (m_IsSelectedPoker && Input.GetMouseButtonUp(0))
            {
                for (int i = 0; i < m_CurrSelectedPoker.Count; ++i)
                {
                    m_CurrSelectedPoker[i].SetSelected(false);
                    m_CurrSelectedPoker[i].isSelect = !m_CurrSelectedPoker[i].isSelect;
                }
                ResetDragPoker();
                UITipPokerShiSanZhangView.Instance.TipKuang();
            }
        }
コード例 #4
0
 /// <summary>
 /// 牌点击
 /// </summary>
 /// <param name="poker"></param>
 private void OnPokerClick(UIItemPoker_ShiSanZhang poker)
 {
     Debug.Log("点击牌了啊!!!!!!!!     " + poker.Poker.Size);
     for (int i = 0; i < m_HandList.Count; ++i)
     {
         if (m_HandList[i] == poker)
         {
             Debug.Log("点击牌了啊!!!!!!!!     " + poker.Poker.Size);
             m_HandList[i].isSelect = !m_HandList[i].isSelect;
             UITipPokerShiSanZhangView.Instance.TipKuang();
             //SendNotification("OnShiSanZhangPokerClick", poker);
             break;
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// 开局
 /// </summary>
 /// <param name="myPoker"></param>
 public void Begin(List <Poker> myPoker, bool isPlayAnimation)
 {
     myPoker.Sort(Comparator);
     for (int i = 0; i < myPoker.Count; i++)
     {
         UIItemPoker_ShiSanZhang item = SpawnPoker(myPoker[i], isPlayAnimation);
         SetPokerContainer(item.gameObject.transform, m_DealContainer, 0.75f);
         if (m_Index == 0)
         {
             item.gameObject.layer = 11;
         }
         m_HandList.Add(item);
     }
     StartCoroutine(DealMovePokerTor(isPlayAnimation));
 }
コード例 #6
0
        /// <summary>
        /// 手势拖拽中
        /// </summary>
        /// <param name="screenPos"></param>
        protected override void OnFingerDrag(Vector2 screenPos)
        {
            base.OnFingerDrag(screenPos);
            Debug.Log("OnFingerDrag 手势拖拽中");
            if (m_IsSelectedPoker && m_StartSelectedPoker != null)
            {
                //计算拖拽时选中的牌
                UIItemPoker_ShiSanZhang ctrl = GetRayHitPoker();
                Debug.Log(ctrl.Poker.Size + "                                检测到的牌");
                if (ctrl != null)
                {
                    m_CurrSelectedPoker.Clear();
                    m_EndSelectedPoker = ctrl;
                    for (int i = 0; i < m_CurrSelectedPoker.Count; ++i)
                    {
                        m_CurrSelectedPoker[i].SetSelected(true);
                    }



                    //int startIndex = PrefabManager.Instance.GetIndex(RoomPaoDeKuaiProxy.Instance.PlayerSeat.Pos, m_StartSelectedPoker);
                    //int endIndex = PrefabManager.Instance.GetIndex(RoomPaoDeKuaiProxy.Instance.PlayerSeat.Pos, m_EndSelectedPoker);

                    //List<UIItemPoker_ShiSanZhang> playerSeatPoker = PrefabManager.Instance.GetHand(RoomPaoDeKuaiProxy.Instance.PlayerSeat.Pos);
                    //int minIndex = endIndex - startIndex > 0 ? startIndex : endIndex;
                    //int maxIndex = endIndex + startIndex - minIndex;
                    //for (int i = minIndex; i <= maxIndex; ++i)
                    //{
                    //    m_CurrSelectedPoker.Add(playerSeatPoker[i]);

                    //}
                    ////设置拖拽选中状态
                    //for (int i = 0; i < playerSeatPoker.Count; ++i)
                    //{
                    //    playerSeatPoker[i].SetSelected(false);
                    //}
                    //for (int i = 0; i < m_CurrSelectedPoker.Count; ++i)
                    //{
                    //    m_CurrSelectedPoker[i].SetSelected(true);
                    //}
                }
            }
        }
コード例 #7
0
        private UIItemPoker_ShiSanZhang GetRayHitPoker()
        {
            UIItemPoker_ShiSanZhang ctrl = null;
            Vector3 ScreenmousePos       = m_UISceneShiSanZhangView.CurrentCamare.ScreenToWorldPoint(Input.mousePosition);

            RaycastHit2D[] hitArr = Physics2D.RaycastAll(new Vector2(ScreenmousePos.x, ScreenmousePos.y), new Vector2(ScreenmousePos.x, ScreenmousePos.y - 1f), 1, 1 << LayerMask.NameToLayer("PlayerHand"));

            if (hitArr.Length > 0)
            {
                ctrl = hitArr[0].collider.gameObject.GetComponent <UIItemPoker_ShiSanZhang>();
                Debug.Log(" hitArr[0]" + ctrl.ToString() + ctrl.transform.position);
                for (int i = 1; i < hitArr.Length; ++i)
                {
                    UIItemPoker_ShiSanZhang ctrlTemp = hitArr[i].collider.gameObject.GetComponent <UIItemPoker_ShiSanZhang>();
                    Debug.Log("ctrlTemp" + ctrlTemp.ToString() + ctrlTemp.transform.position);
                    if (ctrl.Poker.Size > ctrlTemp.Poker.Size || (ctrl.Poker.Size == ctrlTemp.Poker.Size && ctrl.Poker.Color > ctrlTemp.Poker.Color))
                    {
                        ctrl = ctrlTemp;
                    }
                }
                Debug.Log("ctrl" + ctrl.ToString());
            }
            return(ctrl);
        }