コード例 #1
0
    public int GetIndexByItem(HandCardItem targetItem)
    {
        int index = -1;
        int key   = int.MaxValue;

        HandCardItem item = null;
        int          tid  = targetItem.getId();

        for (int i = 0; i < _handCardList.Count; i++)
        {
            item = _handCardList[i];

            int id = item.getId();

            if (tid == id)
            {
                index = i;
                break;
            }
            else if (tid < id && key > id)
            {
                index = i;
                key   = id;
            }
        }

        if (index == -1)
        {
            index = _handCardList.Count;
        }

        return(index);
    }
コード例 #2
0
    HandCardItem GetHandCardItemByObj(GameObject obj)
    {
        if (obj == null)
        {
            return(null);
        }

        HandCardItem item = null;

        for (int i = 0; i < _handCardList.Count; i++)
        {
            item = _handCardList[i];

            if (item != null && item.checkObj(obj))
            {
                return(item);
            }
        }

        item = _MoHand;
        if (item != null && item.checkObj(obj))
        {
            return(item);
        }

        return(null);
    }
コード例 #3
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);
    }
コード例 #4
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);
    }
コード例 #5
0
    public void sync()
    {
        List <int> folds = RoomMgr.GetInstance().seats [seatindex].folds;

        ResetInfo();

        for (int i = 0; i < folds.Count; i++)
        {
            int          id   = folds [i] % 100;
            bool         ting = folds [i] > 100;
            GameObject   ob   = ResourcesMgr.GetInstance().LoadMJ(id);
            HandCardItem item = new HandCardItem(id, ob);

            int row = getRow(i);
            int col = getCol(i);

            ob.layer = LayerMask.NameToLayer("ZhuoPai");
            ob.transform.SetParent(this.transform);
            ob.transform.localRotation = Quaternion.Euler(new Vector3(-90, 0, 0));
            ob.transform.localPosition = new Vector3(offSetX * col, 0, offSetZ * row + 0.0098f);
            //ob.transform.Translate(offSetX * col, 0, offSetZ * row);

            if (ting)
            {
                item.setTing(true);
            }

            _RecyleHandCardList.Add(item);
        }
    }
コード例 #6
0
ファイル: RuleManager.cs プロジェクト: isoundy000/shmj3d
    /// <summary>
    /// 定缺,缺一门
    /// </summary>
    /// <param name="type">指定的需要定缺的类型</param>
    /// <param name="_handCardList">指定的需要定缺的数组</param>
    public void DingQue(DingQueType type, List <HandCardItem> _handCardList)
    {
        int low   = -1;
        int hight = -1;

        switch (type)
        {
        case DingQueType.WAN:
            low   = 0;
            hight = 9;
            break;

        case DingQueType.TIAO:
            low   = 10;
            hight = 19;
            break;

        case DingQueType.TONG:
            low   = 20;
            hight = 29;
            break;
        }
        if (low != -1 || hight != -1)
        {
            for (int i = _handCardList.Count - 1; i >= 0; i--)
            {
                HandCardItem item = _handCardList[i];
                if (item._id >= low && item._id <= hight)
                {
                    Debug.Log("定缺");
                    item._obj.GetComponent <Renderer>().materials[1].color = new Color(0.286f, 0.286f, 0.286f, 1f);
                }
            }
        }
    }
コード例 #7
0
ファイル: RuleManager.cs プロジェクト: isoundy000/shmj3d
    public HandCardItem DingQue(DingQueType type, HandCardItem target)
    {
        int low   = -1;
        int hight = -1;

        switch (type)
        {
        case DingQueType.WAN:
            low   = 0;
            hight = 9;
            break;

        case DingQueType.TIAO:
            low   = 10;
            hight = 19;
            break;

        case DingQueType.TONG:
            low   = 20;
            hight = 29;
            break;
        }
        if (low != -1 || hight != -1)
        {
            if (target._id >= low && target._id <= hight)
            {
                target._obj.GetComponent <Renderer>().materials[1].color = new Color(0.286f, 0.286f, 0.286f, 1f);
            }
        }
        return(target);
    }
コード例 #8
0
ファイル: InteractMgr.cs プロジェクト: isoundy000/shmj3d
    void onMJChoosed(HandCardItem item)
    {
        int id = item.getId();

        if (_gangState == 0)
        {
            enterGangState(1, item.getId());
        }

        GameAction ac = _options;

        int cnt = ac.help.Count;

        if (cnt > 0)
        {
            List <HuPai> hus = null;
            for (int i = 0; i < cnt; i++)
            {
                if (ac.help [i].pai == id)
                {
                    hus = ac.help[i].hus;
                    break;
                }
            }

            showPrompt(hus);
        }

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

        Highlight(id, true);
    }
コード例 #9
0
    public void ChuPai(HandCardItem item, bool isMoNi)
    {
        item.setLayer("ZhuoPai");
        _RecyleHandCardList.Add(item);
        PlayChuPaiAnimation(isMoNi);

        AudioManager.GetInstance().PlayHandCardAudio(item.getId());
    }
コード例 #10
0
 public void PlayChuPaiAnimation(HandCardItem item)
 {
     _currentObj = item._obj;
     id          = item._id;
     _currentObj.transform.SetParent(_handright_point);
     _currentObj.transform.localPosition = Vector3.zero;
     _currentObj.transform.localRotation = Quaternion.Euler(90, 0, 0);
 }
コード例 #11
0
    public void PushToList(int id, GameObject obj)
    {
        HandCardItem item = new HandCardItem();

        item._id  = id;
        item._obj = obj;
        _handCardList.Add(item);
    }
コード例 #12
0
 public void ChuPai(HandCardItem item, bool isMoNi)
 {
     item._obj.layer = LayerMask.NameToLayer("ZhuoPai");
     RuleManager.m_instance.ResetHandCardColor(item._obj);
     Debug.Log("_RecyleHandCardList" + _RecyleHandCardList.Count);
     _RecyleHandCardList.Add(item);
     PlayChuPaiAnimation(isMoNi);
     AudioManager.Instance.PlayHandCardAudio(item._id);
 }
コード例 #13
0
    public void ChuPai(int id)
    {
        HandCardItem item = new HandCardItem();

        item._id = id;
        GameObject obj = (GameObject)Instantiate(_handCardPrefab);

        item._obj = RuleManager.UVoffSetWithReturn(id, obj);
    }
コード例 #14
0
    public bool checkObj(HandCardItem item)
    {
        if (item == null || !item.valid())
        {
            return(false);
        }

        return(item.getObj().Equals(_obj));
    }
コード例 #15
0
    public void ChuPai(int pai, Action cb)
    {
        GameObject   ob   = currentObj;
        HandCardItem item = null;

        int  id   = pai % 100;
        bool ting = pai > 100;

        if (ob != null)
        {
            item = GetHandCardItemByObj(ob);

            if (item != null && item.checkId(id))
            {
                item.setTing(ting);

                item.setCB(cb);
                chuPaiEvent(item, true);
                currentObj = null;
                return;
            }
            else if (item == null)
            {
                Debug.LogError("id not found");
            }
            else
            {
                Debug.LogError("id wrong");
            }
        }

        currentObj = null;

        bool valid = isHoldsValid();

        if (valid)
        {
            item = GetHandCardItemById(id);
        }
        else
        {
            item = GetRandomHandCardItem(id);
        }

        if (item != null)
        {
            item.setTing(ting);

            item.setCB(cb);
            chuPaiEvent(item, true);
            return;
        }

        Debug.LogError("chupai not found: " + id);
    }
コード例 #16
0
    void hideMopai()
    {
        HandCardItem item = _MoHand;

        if (item != null && item.valid())
        {
            item.destroy();
        }

        _MoHand = null;
    }
コード例 #17
0
    public void RemoveMoHandCard(int id)
    {
        HandCardItem item = _MoHand;

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

        _MoHand = null;
    }
コード例 #18
0
    public int GetIndexByItem(HandCardItem targetItem)
    {
        int  index          = -1;
        int  key            = int.MaxValue;
        int  DQ_Start_index = -1;
        bool isGetDQIndex   = false;

        for (int i = 0; i < _handCardList.Count; i++)
        {
            if (CheckIsDingQue(_handCardList[i]._id) && !isGetDQIndex)
            {
                DQ_Start_index = i;
                isGetDQIndex   = true;
            }
            if (targetItem._id == _handCardList[i]._id)
            {
                index = i;
                break;
            }
            else if (targetItem._id < _handCardList[i]._id && key > _handCardList[i]._id)
            {
                index = i;
                key   = _handCardList[i]._id;
            }
        }
        if (CheckIsDingQue(targetItem._id) && DQ_Start_index == -1)
        {
            index = _handCardList.Count;
        }
        else if (CheckIsDingQue(targetItem._id) && DQ_Start_index != -1)
        {
            if (index < DQ_Start_index)
            {
                index = _handCardList.Count;
            }
        }
        if (index == -1)//新牌是最大的,需要在最末尾
        {
            if (!CheckIsDingQue(targetItem._id) && DQ_Start_index != -1)
            {
                index = DQ_Start_index;
            }

            else
            {
                index = _handCardList.Count;
            }
        }
        return(index);//
    }
コード例 #19
0
    GameObject FindGameObj(int id)
    {
        GameObject obj = null;

        for (int i = _handCardList.Count - 1; i >= 0; i--)
        {
            HandCardItem item = _handCardList[i];
            if (item._id == id)
            {
                obj = item._obj;
            }
        }
        return(obj);
    }
コード例 #20
0
    void MotoCardList()
    {
        if (_MoHand != null)
        {
            GameObject ob = _MoHand.getObj();
            ob.transform.SetParent(_HandCardPlace);
            _handCardList.Add(_MoHand);
            _MoHand = null;

            _handCardList.Sort((a, b) => a.getId() - b.getId());

            UpdateHandCard();
        }
    }
コード例 #21
0
    void ChaPaiEndEventHandle(DHM_HandAnimationCtr hand)
    {
        hand.moveHandEvent  -= MoveHandCard;
        hand.chaPaiEndEvent -= ChaPaiEndEventHandle;
        float x = _handCardList.Count / 2.0f - newIndex;

        _MoHand._obj.transform.SetParent(_HandCardPlace);
        _MoHand._obj.transform.localPosition = Vector3.zero;
        _MoHand._obj.transform.localRotation = Quaternion.Euler(Vector3.zero);
        _MoHand._obj.transform.Translate(offSetX * x, 0, 0);
        _MoHand = null;
        ResourcesMgr.m_Instance.RemoveGameObject(hand.gameObject);
        GameManager.m_instance.islock = false;
        Debug.LogWarning("ChaPaiEndEventHandle结束:" + GameManager.m_instance.islock);
    }
コード例 #22
0
    public void ResetInfo()
    {
        hideFocus();

        Transform[] trans = this.GetComponentsInChildren <Transform>();
        for (int i = trans.Length - 1; i >= 0; i--)
        {
            if (trans[i] != this.transform)
            {
                DestroyImmediate(trans[i].gameObject);
            }
        }

        _RecyleHandCardList.Clear();
        lastChuPai = null;
    }
コード例 #23
0
    void ChaPaiEndEventHandle(DHM_HandAnimationCtr hand)
    {
        hand.moveHandEvent  -= MoveHandCard;
        hand.chaPaiEndEvent -= ChaPaiEndEventHandle;
        float x = _handCardList.Count / 2.0f - newIndex;

        Transform tm = _MoHand.getObj().transform;

        tm.SetParent(_HandCardPlace);
        tm.localPosition = Vector3.zero;
        tm.localRotation = Quaternion.Euler(Vector3.zero);
        tm.Translate(offSetX * x, 0, 0);

        _MoHand = null;
        ResourcesMgr.mInstance.RemoveGameObject(hand.gameObject);
    }
コード例 #24
0
    void onMJClicked(GameObject ob)
    {
        InteractMgr  im   = InteractMgr.GetInstance();
        HandCardItem item = GetHandCardItemByObj(ob);

        if (item == null)
        {
            return;
        }

        if (item.interactable())
        {
            im.onMJClicked(item);
            currentObj = ob;
        }
    }
コード例 #25
0
    public void DeleteCard()
    {
        if (_RecyleHandCardList.Count == 0)
        {
            return;
        }

        int          id   = _RecyleHandCardList.Count - 1;
        HandCardItem item = _RecyleHandCardList[id];

        detachFocus();

        _RecyleHandCardList.RemoveAt(id);
        item.destroy();

        lastChuPai = null;
    }
コード例 #26
0
    /// <summary>
    /// 发牌
    /// </summary>
    public void FaPai()
    {
        ClearList();
        for (int i = 0; i < 13; i++)
        {
            GameObject obj = Instantiate(_handCardPrefab);

            obj.layer          = m_handCard_layer;
            obj.gameObject.tag = tagValue;
            obj.transform.SetParent(_HandCardPlace);
            obj.transform.Rotate(90, 0, 0);
            HandCardItem item = new HandCardItem();
            item._obj = obj;
            _handCardList.Add(item);
        }
        UpdateHandCard();
        TestUV();
    }
コード例 #27
0
    /// <summary>
    /// 插牌,被出牌动画的帧事件调用
    /// </summary>
    public void chapai()
    {
        if (isPeng)//碰牌以后,直接打牌,不需要摸牌,也不能插牌
        {
            if (oldIndex != -1)
            {
                _handCardList.RemoveAt(oldIndex);
            }
            else
            {
                _MoHand = null;
            }
            isPeng = false;
            UpdateHandCard();

            GameManager.m_instance.islock = false;
            Debug.LogWarning("碰以后打出的牌:" + GameManager.m_instance.islock);
            return;
        }
        else if (oldIndex != -1 && _MoHand != null)//如果需要插牌,则执行插牌
        {
            newIndex = GetIndexByItem(_MoHand);
            if (newIndex > oldIndex)
            {
                newIndex--;
            }
            if (newIndex == oldIndex && newIndex == 13)
            {
                newIndex--;
            }
            ChaPai(newIndex, _MoHand._obj);
        }
        else if (oldIndex == -1)
        {
            GameManager.m_instance.islock = false;
            Debug.LogWarning("打出莫的牌:" + GameManager.m_instance.islock);
        }
        else
        {
            GameManager.m_instance.islock = false;
            Debug.LogWarning("默认打开开关:" + GameManager.m_instance.islock);
        }
    }
コード例 #28
0
 /// <summary>
 /// 设置摸牌的位置
 /// 1 偏移UV贴图
 /// 2 检测是否是定缺的牌
 /// </summary>
 /// <param name="id"></param>
 /// <param name="go"></param>
 public void SetMoHandCard(int id, GameObject go = null)
 {
     Debug.LogWarning("摸的牌" + id);
     if (go == null)
     {
         go = Instantiate(_handCardPrefab) as GameObject;
         RuleManager.m_instance.UVoffSet(id, go);//UV偏移
     }
     _MoHand            = new HandCardItem();
     _MoHand._id        = id;
     _MoHand._obj       = go;
     _MoHand._obj.layer = m_handCard_layer;
     _MoHand._obj.tag   = tagValue;
     _MoHand._obj.transform.SetParent(null);
     _MoHand._obj.transform.rotation = _MoHandPos.rotation;
     _MoHand._obj.transform.position = _MoHandPos.TransformPoint(0.0731f * offSetX, 0, 0);
     RuleManager.m_instance.DingQue(_dingQueType, _MoHand);//检测是否需要定缺
     GameManager.m_instance.islock = false;
 }
コード例 #29
0
    public void RemoveGameObj(int id, int Number)
    {
        id = id % 100;

        int          count = 0;
        HandCardItem item  = null;

        for (int i = _handCardList.Count - 1; i >= 0; i--)
        {
            item = _handCardList[i];
            if (item.checkId(id))
            {
                count++;
                item.destroy();
                _handCardList.RemoveAt(i);
                if (count == Number)
                {
                    UpdateHandCard();
                    return;
                }
            }
        }

        item = _MoHand;

        if (item != null && item.checkId(id))
        {
            count++;
            item.destroy();
            _MoHand = null;
        }
        else
        {
            Debug.LogError("mohand id != " + id.ToString());
        }

        if (count != Number)
        {
            Debug.LogError("count < number!!!!");
        }

        UpdateHandCard();
    }
コード例 #30
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);
    }