Exemple #1
0
 /// <summary>
 /// 更换麻将牌值
 /// </summary>
 /// <param name="mahjong">更换的麻将</param>
 /// <param name="newValue">新的牌值</param>
 public void SwitchMahjongValue(MahjongContainer mahjong, int newValue)
 {
     if (mahjong != null)
     {
         mahjong.Value = newValue;
     }
 }
Exemple #2
0
        protected virtual void OnDrag(Vector2 delta)
        {
            if (!GameCenter.Scene.HandMahTouchEnable)
            {
                return;
            }
            if (ForbidDrag)
            {
                return;
            }
            if (mDragClone == null)
            {
                //克隆出一个新的麻将
                mDragClone = GameCenter.Scene.MahjongCtrl.PopMahjong(gameObject.GetComponent <MahjongContainer>().Value);
                mDragClone.transform.SetParent(transform.parent);
                mDragClone.transform.position   = transform.position;
                mDragClone.transform.rotation   = transform.rotation;
                mDragClone.transform.localScale = transform.localScale;
                MahjongUtility.ChangeLayer(mDragClone.transform, transform.gameObject.layer);
                mDragClone.GetComponent <MahjongContainer>().RemoveMahjongScript();
                mRecordMahjongPos = transform.position;
            }
            var handCarmera = GameCenter.Scene.MahjongCamera.HandCamera;
            //物体的屏幕坐标
            Vector3 screenPos = handCarmera.WorldToScreenPoint(mDragClone.transform.position);

#if (UNITY_ANDROID || UNITY_IPHONE) && !UNITY_EDITOR
            Vector3 mousePos = Input.touches[0].position;
#else
            Vector3 mousePos = Input.mousePosition;
#endif
            mousePos.z = screenPos.z;
            Vector3 worldPos = handCarmera.ScreenToWorldPoint(mousePos);
            mDragClone.transform.position = new Vector3(worldPos.x, worldPos.y, worldPos.z);
        }
Exemple #3
0
 public virtual void SetMahjongNormalState(MahjongContainer item)
 {
     item.Lock = false;
     item.SetMahjongScript();
     item.SetThowOutCall(ThrowCardClickEvent);
     item.ResetPos();
 }
Exemple #4
0
 protected virtual void OnPress(bool isPress)
 {
     if (!GameCenter.Scene.HandMahTouchEnable)
     {
         return;
     }
     if (isPress == false)
     {
         //麻将结束拖拽
         if (mDragClone != null)
         {
             //判断是否拖拽有效
             if (mDragClone.transform.position.y - mRecordMahjongPos.y >= 0.4f)
             {
                 //拖拽有效 出牌
                 if (OnThrowOut != null)
                 {
                     OnThrowOut(transform);
                 }
             }
             GameCenter.Scene.MahjongCtrl.PushMahjongToPool(mDragClone);
             mDragClone = null;
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// 获取麻将
        /// </summary>
        /// <param name="card">牌值</param>
        /// <returns></returns>
        public MahjongContainer PopMahjong(int card)
        {
            MahjongContainer mahjong = null;

            if (mMahjongPool.Count > 10)
            {
                mahjong = mMahjongPool.Dequeue();
                if (!mMahjongIndexRecord.ContainsKey(card))
                {
                    mMahjongIndexRecord.Add(card, 0);
                }
                mahjong.MahjongIndex = mMahjongIndexRecord[card]++;
            }
            else
            {
                //var template = MahjongUtility.GetScriptableAssets<MahjongCardAssets>().MahjongTemplate;
                var template = GameCenter.Assets.MahjongTemplate;
                mahjong = Instantiate(template);
            }
            if (mahjong != null)
            {
                mahjong.Value = card;
            }
            mahjong.gameObject.SetActive(true);
            return(mahjong);
        }
Exemple #6
0
        /// <summary>
        /// 设置翻开的牌
        /// </summary>
        public MahjongContainer SetMahjong(int card, int laizi)
        {
            if (card == 0)
            {
                return(null);
            }
            DisplayBottom.gameObject.SetActive(true);
            var scene = GameCenter.Scene;

            if (mDisplayMahjong.ExIsNullOjbect())
            {
                GameCenter.DataCenter.LeaveMahjongCnt--;
                scene.MahjongGroups.PopMahFromCurrWall();
                mDisplayMahjong = scene.MahjongCtrl.PopMahjong(card);
            }
            var bottom = DisplayBottom.FindChild("bottom");

            mDisplayMahjong.transform.SetParent(bottom);
            mDisplayMahjong.transform.localPosition = new Vector3(0, 0.1f, 0);
            mDisplayMahjong.transform.localRotation = Quaternion.Euler(new Vector3(90, 0, 0));
            mDisplayMahjong.transform.localScale    = Vector3.one;
            mDisplayMahjong.gameObject.SetActive(true);
            if (card == laizi)
            {
                mDisplayMahjong.Laizi = true;
            }
            return(mDisplayMahjong);
        }
Exemple #7
0
 // 抓牌时,如果新进牌属于花猪,手牌置灰
 public override void GetInMahjong(MahjongContainer item)
 {
     if ((item.Value >> 4) == (mPigColor >> 4))
     {
         item.ShowGray();
     }
 }
Exemple #8
0
 public override void AddMahjong(MahjongContainer item)
 {
     base.AddMahjong(item);
     item.ChangeToHardLayer(true);
     item.SetMahjongScript();
     item.SetThowOutCall(ThrowCardClickEvent);
 }
Exemple #9
0
 protected void OnClick()
 {
     if (!GameCenter.Scene.HandMahTouchEnable)
     {
         return;
     }
     if (AllowOffsetStatus)
     {
         var currMahjong = transform.GetComponent <MahjongContainer>();
         if (SelectTransform == null || currMahjong.MahjongIndex != SelectTransform.MahjongIndex || currMahjong.Value != SelectTransform.Value)
         {
             if (SelectTransform != null && SelectTransform.gameObject.layer == MahjongPlayerHand.PlayerHardLayer)
             {
                 SelectTransform.RollDown();
             }
             //这里必须重新获取对象, 不用currMahjong赋值
             SelectTransform = transform.GetComponent <MahjongContainer>();
             SelectTransform.RollUp();
             return;
         }
     }
     if (OnThrowOut != null)
     {
         OnThrowOut(transform);
     }
 }
 public void ShowOutcardFlag(MahjongContainer item)
 {
     if (!item.ExIsNullOjbect())
     {
         GetParts <MahjongOutCardFlag>(TablePartsType.OutCardFlag).Show(item);
     }
 }
Exemple #11
0
        public virtual MahjongContainer PopMahjong()
        {
            MahjongContainer item = mMahjongList[mMahjongList.Count - 1];

            mMahjongList.RemoveAt(mMahjongList.Count - 1);
            GameCenter.Scene.MahjongCtrl.PushMahjongToPool(item);
            return(item);
        }
Exemple #12
0
 public virtual void SetLastCardPos(int value)
 {
     if (mMahjongList.Count > 1)
     {
         MahjongContainer lastMj = mMahjongList[mMahjongList.Count - 1];
         lastMj.transform.localPosition = GetHardLastMjPos();
     }
 }
Exemple #13
0
 protected virtual void AddMahjongToList(MahjongContainer item)
 {
     if (item == null)
     {
         return;
     }
     item.transform.ExSetParent(transform);
     mMahjongList.Add(item);
 }
Exemple #14
0
 public virtual void AddMahjong(MahjongContainer item)
 {
     if (item == null)
     {
         return;
     }
     MahjongHand.MahjongList.Add(item);
     item.transform.ExSetParent(transform);
 }
        public override MahjongContainer ThrowOut(int value)
        {
            MahjongContainer Mahjong = base.ThrowOut(value);

            if (Mahjong != null)
            {
                Mahjong.ChangeToHardLayer(false);
            }
            return(Mahjong);
        }
Exemple #16
0
 public virtual MahjongContainer GetInMahjong(MahjongContainer item)
 {
     if (null == item)
     {
         return(null);
     }
     AddMahjongToList(item);
     SetMahjongPos();
     return(item);
 }
Exemple #17
0
 /// <summary>
 /// 回收麻将
 /// </summary>
 public void PushMahjongToPool(MahjongContainer mahjong)
 {
     if (mahjong == null)
     {
         return;
     }
     mMahjongPool.Enqueue(mahjong);
     mahjong.transform.ExSetParent(transform);
     mahjong.OnReset();
 }
        //当抢杠胡
        public virtual void OnQiangganghu(int value)
        {
            MahjongContainer findItem = mMahjongList.Find((item) =>
            {
                return(item.Value == value);
            });

            GameCenter.Scene.MahjongCtrl.PushMahjongToPool(findItem);
            mMahjongList.Remove(findItem);
            SortHandMahjong();
        }
Exemple #19
0
 public override void OnReset()
 {
     if (mAnbaoEffect != null)
     {
         GameCenter.Pools.GetPool <ObjectPoolComponent>(PoolUitlity.Po_EffectObject).Push(mAnbaoEffect);
         mAnbaoEffect = null;
     }
     DisplayBottom.gameObject.SetActive(false);
     GameCenter.Scene.MahjongCtrl.PushMahjongToPool(mDisplayMahjong);
     mDisplayMahjong = null;
 }
Exemple #20
0
        public virtual MahjongContainer GetInMahjong(int value)
        {
            MahjongContainer item = GameCenter.Scene.MahjongCtrl.PopMahjong(value);

            AddMahjongToList(item);
            SetMahjongPos();
            if (MahjongUtility.MahjongFlagCheck(value))
            {
                item.Laizi = true;
            }
            return(item);
        }
Exemple #21
0
        public MahjongContainer PopMahjong()
        {
            MahjongContainer item = mMahjongList[StartIndex];

            if (null != item)
            {
                mMahjongList.RemoveAt(StartIndex);
                GameCenter.Scene.MahjongCtrl.PushMahjongToPool(item);
                return(item);
            }
            return(null);
        }
Exemple #22
0
        /// <summary>
        /// 设置翻宝麻将
        /// </summary>
        public MahjongContainer SetBaoMahjong(int bao, bool isShow = true)
        {
            DisplayBottom.gameObject.SetActive(true);
            var scene = GameCenter.Scene;

            if (mDisplayMahjong.ExIsNullOjbect())
            {
                mDisplayMahjong = scene.MahjongCtrl.PopMahjong();
            }
            mDisplayMahjong.Value = bao;
            mDisplayMahjong.Laizi = true;
            int quadrant = 1;

            if (!isShow)
            {
                if (mAnbaoEffect == null)
                {
                    var obj = GameCenter.Pools.GetPool <ObjectPoolComponent>(PoolUitlity.Po_EffectObject).Pop <EffectObject>(EffectObject.AssetsNamePrefix + PoolObjectType.anbao, (go) =>
                    {
                        return(go.Type == PoolObjectType.anbao);
                    });
                    if (obj != null)
                    {
                        obj.ExSetParent(DisplayBottom);
                        obj.gameObject.SetActive(true);
                        obj.transform.localPosition = GameCenter.DataCenter.Config.AnbaoPos;
                        obj.Execute();
                        if (!obj.AutoRecycle)
                        {
                            mAnbaoEffect = obj;
                        }
                    }
                }
                quadrant = -1;
            }
            else
            {
                if (mAnbaoEffect != null)
                {
                    mAnbaoEffect.gameObject.SetActive(false);
                }
            }
            var bottom = DisplayBottom.FindChild("bottom");

            mDisplayMahjong.transform.SetParent(bottom);
            mDisplayMahjong.transform.localPosition = new Vector3(0, 0.1f, 0);
            mDisplayMahjong.transform.localRotation = Quaternion.Euler(new Vector3(90 * quadrant, 0, 0));
            mDisplayMahjong.transform.localScale    = Vector3.one;
            mDisplayMahjong.gameObject.SetActive(true);
            //mDisplayMahjong.IsSign = true;
            return(mDisplayMahjong);
        }
Exemple #23
0
        private void OnCreateMahjong(MahjongContainer obj, int aount)
        {
            MahjongContainer mahjongItem = null;

            for (int i = 0; i < aount; i++)
            {
                mahjongItem = Instantiate(obj);
                mahjongItem.transform.ExSetParent(transform);
                mahjongItem.OnInitalization();
                mahjongItem.OnReset();
                PushMahjongToPool(mahjongItem);
            }
        }
Exemple #24
0
        public MahjongContainer GetInMahjongNoAni(int value)
        {
            MahjongContainer LastGetIn = GameCenter.Scene.MahjongCtrl.PopMahjong(value);

            AddMahjongToList(LastGetIn);
            if (MahjongUtility.MahjongFlagCheck(value))
            {
                LastGetIn.Laizi = true;
            }
            //位子放到最后
            LastGetIn.transform.localPosition = GetHardLastMjPos();
            return(LastGetIn);
        }
Exemple #25
0
        public MahjongContainer PopMahjong()
        {
            if (mMahjongList.Count == 0)
            {
                return(null);
            }

            MahjongContainer item = mMahjongList[mMahjongList.Count - 1];

            GameCenter.Scene.MahjongCtrl.PushMahjongToPool(item);
            mMahjongList.Remove(item);
            return(item);
        }
Exemple #26
0
        public void RemoveMahjong(int value, bool sort = true)
        {
            MahjongContainer item = GetMahjongItemByValue(value);

            if (item != null)
            {
                mMahjongList.Remove(item);
                GameCenter.Scene.MahjongCtrl.PushMahjongToPool(item);
            }
            if (sort)
            {
                SetMahjongPos();
            }
        }
Exemple #27
0
        public override MahjongContainer GetInMahjong(int value)
        {
            MahjongContainer LastGetIn = GameCenter.Scene.MahjongCtrl.PopMahjong(value);

            AddMahjongToList(LastGetIn);
            if (MahjongUtility.MahjongFlagCheck(value))
            {
                LastGetIn.Laizi = true;
            }
            //位子放到最后
            LastGetIn.transform.localPosition = GetHardLastMjPos();
            //转动方向
            LastGetIn.RotaTo(new Vector3(-90, 0, 0), Vector3.zero, GameCenter.DataCenter.Config.TimeGetInCardRote, GameCenter.DataCenter.Config.TimeGetInCardWait);
            return(LastGetIn);
        }
Exemple #28
0
        public virtual MahjongContainer ThrowOut(int value)
        {
            MahjongContainer Mahjong = GetMahjongItemByValue(value);

            if (Mahjong == null)
            {
                return(null);
            }
            Mahjong.ShowNormal();
            mMahjongList.Remove(Mahjong);
            SortMahjongForHand();
            SetMahjongPos();
            GameCenter.Scene.MahjongCtrl.PushMahjongToPool(Mahjong);
            return(Mahjong);
        }
Exemple #29
0
        protected virtual void SwitchNormalState()
        {
            MahjongContainer item = null;
            var list = PlayerHand.MahjongList;

            for (int i = 0; i < list.Count; i++)
            {
                item      = list[i];
                item.Lock = false;
                item.SetMahjongScript();
                item.SetAllowOffsetStatus(true);
                item.SetThowOutCall(ThrowCardClickEvent);
                item.ResetPos();
            }
            UserContorl.ClearSelectCard();
        }
Exemple #30
0
 public void RemoveMahjong(IList <int> value, bool sort = true)
 {
     for (int i = 0; i < value.Count; i++)
     {
         MahjongContainer item = GetMahjongItemByValue(value[i]);
         if (item != null)
         {
             mMahjongList.Remove(item);
             GameCenter.Scene.MahjongCtrl.PushMahjongToPool(item);
         }
     }
     if (sort)
     {
         SetMahjongPos();
     }
 }