Example #1
0
    public void SetMoHandCard(int id, GameObject go = null)
    {
        if (id == -1)
        {
            id = INVALID_ID;
        }

        if (go == null)
        {
            go = ResourcesMgr.GetInstance().LoadMJ(id);
        }

        if (_MoHand != null)
        {
            Debug.LogError("[" + seatindex + "]SetMoHandCard error!!!!!!!!!");
        }

        _MoHand = new HandCardItem(id, go);
        GameObject obj = _MoHand.getObj();

        obj.layer = m_handCard_layer;
        obj.tag   = tagValue;
        obj.transform.SetParent(_MoHandPos);
        obj.transform.rotation = _MoHandPos.rotation;
        obj.transform.position = _MoHandPos.TransformPoint(0.0731f * offSetX, 0, 0);
    }
Example #2
0
    void UpdateHandCard(bool silent = false)
    {
        if (!silent)
        {
            AudioManager.GetInstance().PlayEffectAudio("sort");
        }

        HandCardItem item = null;

        for (int i = 0; i < _handCardList.Count; i++)
        {
            float x = _handCardList.Count / 2.0f - i;

            item = _handCardList[i];

            if (item.getLayer() == "ZhuoPai")
            {
                Debug.LogError("UpdateHandCard zhuopai");
                continue;
            }

            Transform tm = item.getObj().transform;
            tm.localPosition = Vector3.zero;
            tm.localRotation = Quaternion.Euler(Vector3.zero);
            tm.Translate(offSetX * x, 0, 0);
        }

        bool replay = ReplayMgr.GetInstance().isReplay();

        _MoHandPos.localPosition = !isMyself() && replay ? new Vector3(0, 0, 0.04f) : Vector3.zero;
        _MoHandPos.Translate(-(_handCardList.Count / 2.0f + 0.5f) * offSetX, 0, 0);
    }
 public void PlayChuPaiAnimation(HandCardItem item)
 {
     _currentObj = item.getObj();
     id          = item.getId();
     _currentObj.transform.SetParent(_handright_point);
     _currentObj.transform.localPosition = Vector3.zero;
     _currentObj.transform.localRotation = Quaternion.Euler(90, 0, 0);
 }
Example #4
0
    public bool checkObj(HandCardItem item)
    {
        if (item == null || !item.valid())
        {
            return(false);
        }

        return(item.getObj().Equals(_obj));
    }
Example #5
0
    HandCardItem GetRandomHandCardItem(int id)
    {
        int cnt = _handCardList.Count;

        System.Random rd = new System.Random();

        int start = _MoHand != null ? -1 : 0;
        int off   = rd.Next(start, cnt);

        HandCardItem item = null;

        if (-1 == off)
        {
            item = _MoHand;
        }
        else
        {
            item = _handCardList[off];
        }

        GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id);

        obj.layer          = m_handCard_layer;
        obj.gameObject.tag = tagValue;
        obj.transform.SetParent(_HandCardPlace);
        HandCardItem card = new HandCardItem(id, obj);

        obj.transform.localPosition = item.getObj().transform.localPosition;
        obj.transform.localRotation = item.getObj().transform.localRotation;

        if (-1 == off)
        {
            _MoHand = card;
        }
        else
        {
            _handCardList[off] = card;
        }

        item.destroy();
        return(card);
    }
Example #6
0
    public static void playHu()
    {
        if (lastChuPai == null)
        {
            return;
        }

        GameObject pai = lastChuPai.getObj();
        GameObject ob  = Instantiate(Resources.Load("Prefab/Meishu/fx_hu"), pai.transform) as GameObject;
        Transform  ts  = ob.transform;

        ts.localPosition = new Vector3(0, 0.24f, 0.13f);
        lastChuPai.setHu();
    }
Example #7
0
    public void ChuPaiEndEventHandle()
    {
        Debug.Log("[" + seatindex + "]ChuPaiEndEventHandle");

        if (_RecyleHandCardList.Count == 0)
        {
            return;
        }

        HandCardItem item = _RecyleHandCardList[_RecyleHandCardList.Count - 1];
        GameObject   obj  = item.getObj();

        if (obj != null)
        {
            obj.transform.SetParent(this.transform);

            item.resetColor();
            showFocus(obj);

            lastChuPai = item;
        }
    }
Example #8
0
    public void onMJClicked(HandCardItem item)
    {
        if (item == null || !item.valid())
        {
            return;
        }

        RoomMgr rm = RoomMgr.GetInstance();

        if (_gangState == 0)
        {
            onMJChoosed(item);
            return;
        }

        if (!rm.isMyTurn() || shot)
        {
            return;
        }

        HandCardItem old = selected;
        GameObject   ob  = item.getObj();

        if (old != null && item.checkObj(old))
        {
            if (_tingState != 0)
            {
                old.choosed(false);
            }

            Highlight(old.getId(), false);

            ob.transform.position = selPos;
            selected = null;
            selPos   = Vector3.zero;

            shoot(item);
            shot = true;
            hidePrompt();
            return;
        }

        if (old != null && old.valid())
        {
            ob = old.getObj();

            // NOTE: old maybe in recycle
            if (old.getLayer() == "Self")
            {
                ob.transform.position = selPos;

                if (_tingState != 0)
                {
                    old.choosed(false);
                }

                Highlight(old.getId(), false);
            }

            selected = null;
        }

        ob       = item.getObj();
        selPos   = ob.transform.position;
        selected = item;

        ob.transform.Translate(0, 0.01f, 0);

        onMJChoosed(item);
    }
Example #9
0
    public void MoveHandCard()
    {
        HandCardItem item = null;

        if (newIndex == oldIndex)
        {
        }
        else if (newIndex < oldIndex)
        {
            //newIndex~oldIndex,数组中后移,手牌上右移
            GameObject obj = new GameObject("tempParent");
            obj.transform.SetParent(_HandCardPlace);//获取父节点的方式有问题
            obj.transform.localPosition = Vector3.zero;
            obj.transform.rotation      = _HandCardPlace.rotation;
            for (int i = oldIndex - 1; i >= newIndex; i--)
            {
                item = _handCardList[i];
                if (item.getLayer() == "ZhuoPai")
                {
                    Debug.LogError("move handcard zhuopai");
                    continue;
                }

                _handCardList[i + 1] = item;
                item.getObj().transform.SetParent(obj.transform);
            }

            obj.transform.Translate(-offSetX, 0, 0);
            Transform[] tran = obj.GetComponentsInChildren <Transform>();
            for (int j = 0; j < tran.Length; j++)
            {
                if (!tran[j].gameObject.Equals(obj.gameObject))
                {
                    tran[j].transform.SetParent(_HandCardPlace);//获取父节点的方式有问题
                }
            }

            Destroy(obj);
        }
        else if (newIndex > oldIndex)
        {
            //oldIndex~list.count:数组前移,牌桌上的手牌左移,item入数组尾部
            GameObject obj = new GameObject("tempParent");
            obj.transform.SetParent(_HandCardPlace);//获取父节点的方式有问题
            obj.transform.localPosition = Vector3.zero;
            obj.transform.rotation      = _HandCardPlace.rotation;
            for (int i = oldIndex; i < newIndex; i++)
            {
                item = _handCardList[i + 1];
                if (item.getLayer() == "ZhuoPai")
                {
                    Debug.LogError("move handcard2 zhuopai");
                    continue;
                }

                _handCardList[i] = item;
                item.getObj().transform.SetParent(obj.transform);
            }
            obj.transform.Translate(offSetX, 0, 0);
            Transform[] tran = obj.GetComponentsInChildren <Transform>();
            for (int j = 0; j < tran.Length; j++)
            {
                if (!tran[j].gameObject.Equals(obj.gameObject))
                {
                    tran[j].transform.SetParent(_HandCardPlace);//获取父节点的方式有问题
                }
            }

            Destroy(obj);
        }

        _handCardList[newIndex] = _MoHand;
    }
Example #10
0
    public void chapai()
    {
        oldIndex = GetOldIndex();
        if (oldIndex == -2)
        {
            Debug.LogError("oldindex error");
            return;
        }

        HandCardItem item = null;

        if (oldIndex != -1)
        {
            item = _handCardList[oldIndex];
        }
        else
        {
            item = _MoHand;
        }

        if (isPeng)     //碰牌以后,直接打牌,不需要摸牌,也不能插牌
        {
            if (oldIndex != -1)
            {
                _handCardList.RemoveAt(oldIndex);
            }
            else
            {
                _MoHand = null;
            }

            isPeng = false;
            UpdateHandCard();

            item.invoke();
        }
        else if (oldIndex != -1 && _MoHand != null)           //如果需要插牌,则执行插牌
        {
            newIndex = isHoldsValid() ? GetIndexByItem(_MoHand) : GetRandomIndex();
            if (newIndex > oldIndex)
            {
                newIndex--;
            }

            if (newIndex == oldIndex && newIndex == 13)
            {
                newIndex--;
            }

            item.invoke();
            ChaPai(newIndex, _MoHand.getObj());
        }
        else if (oldIndex == -1)
        {
            _MoHand = null;

            item.invoke();
        }
        else
        {
            _handCardList.RemoveAt(oldIndex);
            UpdateHandCard();

            item.invoke();
        }
    }
Example #11
0
    IEnumerator _HuPai(HuPushInfo info, Action cb)
    {
        bool       myself = isMyself();
        bool       zimo   = info.iszimo;
        int        layer  = myself ? LayerMask.NameToLayer("Self") : LayerMask.NameToLayer("ZhuoPai");
        List <int> holds  = info.holds;

        holds.Sort((a, b) => a - b);

        if (!myself)
        {
            for (int i = 0; i < _handCardList.Count && i < holds.Count; i++)
            {
                HandCardItem item = _handCardList [i];

                int          id   = holds [i];
                GameObject   obj  = ResourcesMgr.GetInstance().LoadMJ(id);
                HandCardItem card = new HandCardItem(id, obj);
                obj.layer = layer;
                obj.tag   = tagValue;
                obj.transform.SetParent(_HandCardPlace);

                obj.transform.localRotation = item.getObj().transform.localRotation;
                obj.transform.localPosition = item.getObj().transform.localPosition;

                _handCardList [i] = card;
                item.destroy();
            }

            foreach (HandCardItem item in _handCardList)
            {
                item.setLayer("ZhuoPai");
            }
        }

        if (_MoHand != null)
        {
            _MoHand.destroy();
        }

        if (true)
        {
            int        id  = info.hupai;
            GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id);
            _MoHand   = new HandCardItem(id, obj);
            obj.layer = layer;
            obj.tag   = tagValue;
            obj.transform.SetParent(_MoHandPos);
            obj.transform.rotation = _MoHandPos.rotation;
            obj.transform.position = _MoHandPos.TransformPoint(0.0731f * offSetX, 0, 0);
        }

        _MoHand.setInteractable(false, false);

        bool anim   = false;
        bool replay = ReplayMgr.GetInstance().isReplay();

        if (!myself && !replay)
        {
            _MoHandPos.transform.Translate(0, 0, 0.04f);
            _MoHandPos.transform.Rotate(-90, 0, 0);
            anim = true;
        }

        if (anim)
        {
            Transform  huHandSpawn = this.transform.parent.Find("HandSpawn");
            GameObject huHand      = ResourcesMgr.mInstance.InstantiateGameObjectWithType("HupaiHand", ResourceType.Hand);
            huHand.transform.rotation = huHandSpawn.rotation;
            huHand.transform.position = huHandSpawn.position;
            huHand.GetComponent <DHM_HandAnimationCtr> ().huPaiEvent += HuPaiEventHandle;
        }

        if (!zimo)
        {
            DHM_RecyleHandCardManager.playHu();
        }
        else
        {
            Transform trans = _MoHand.getObj().transform;

            if (!myself)
            {
                GameObject ob = Instantiate(Resources.Load("Prefab/Meishu/fx_hu"), trans) as GameObject;
                Transform  ts = ob.transform;
                ts.localPosition = new Vector3(0, 0.24f, 0.13f);
            }
        }

        _MoHand.setHu();
        yield return(new WaitForSeconds(1.0f));

/*
 *              if (huPaiSpawn == null)
 *          huPaiSpawn = this.transform.parent.Find("HuPaiSpwan");
 *
 *      GameObject effectObj = Instantiate(_huEffect);
 *      effectObj.SetActive(true);
 *      effectObj.transform.position = huPaiSpawn.position;
 *
 *              GameObject huCard = ResourcesMgr.GetInstance ().LoadMJ (id);
 *      huCard.transform.rotation = huPaiSpawn.rotation;
 *      huCard.transform.position = huPaiSpawn.position;
 *      huCard.transform.SetParent(huPaiSpawn);
 */

        AudioManager.GetInstance().PlayEffectAudio("hu");
        MainViewMgr mm = MainViewMgr.GetInstance();

        if (zimo)
        {
            mm.showAction(seatindex, "zimo");
        }
        else
        {
            mm.showAction(seatindex, "hu");
            if (info.target >= 0)
            {
                mm.showAction(info.target, "dianpao");
            }
        }

        yield return(new WaitForSeconds(4.0f));

        cb();
    }