示例#1
0
    public virtual bool Draw(TileDef def)
    {
        Debug.Log(gameObject.name + " draw -> " + def.ToString());

        _drawTile = MahjongTile.Create(def);

        _drawTile.transform.parent = null;

        _drawTile.Direction = MahjongTile.Face.STAND_POSITIVE;
        _angle = Vector3.Angle(Vector3.right, _direction);
        //Debug.Log (angle + "    " + Vector3.right + "," + _direction);
        // unity3d bug from vector3.right to vector3.forward == 90 ?
        if (_direction == Vector3.forward)
        {
            _angle = 270f;
        }

        _drawTile.transform.Rotate(Vector3.forward, _angle, Space.Self);
        _drawTile.transform.parent = PocketLocator;
        Vector3 newPos = (PocketLocator.childCount - 1 + 0.2f) * _direction * MahjongTile.Width;

        _drawTile.Draw(newPos);

        _sortPocketList.Add(_drawTile);
        _proxy.Draw(def);

        return(true);
    }
示例#2
0
        public static TileDef Create()
        {
            TileDef def = null;

            System.Random RNG   = new System.Random();
            int           kind  = RNG.Next(0, 3);
            int           point = RNG.Next(1, 10);

            def = Create((byte)(kind << 4 | point));
            UnityEngine.Debug.Log(def.ToString());
            return(def);
        }
示例#3
0
//    public void setHuPrompt(List<UIOperation.HUPROMPT_INFO> hupaiInfo)
//    {
//        UIOperation.Instance.hupai_infos = hupaiInfo;
//
//    }
//    public void setHuPromptAndOnRefresh(List<UIOperation.HUPROMPT_INFO> hupaiInfo)
//    {
//        setHuPrompt(hupaiInfo);
//        OnRefreshItem();
//    }
    public void OnRefreshItem(TileDef def)
    {
        foreach (var viewItem in _viewHuPrompt._viewHuItems)
        {
            viewItem.gameObject.SetActive(false);
        }
        Debug.Log("*****************************OnRefreshItem:" + def.ToString());


        if (UIOperation.Instance._huTipsCards != null && UIOperation.Instance._huTipsCards.Count > 0)
        {
            List <GameMessage.HuTips> huTips = null;
            foreach (var huTipsCard in UIOperation.Instance._huTipsCards)
            {
                //TileDef tdef = TileDef.Create (huTipsCard.cOutCard);
                if (huTipsCard.cOutCard == def.Value)
                {
                    huTips = huTipsCard.v_Tips;
                    break;
                }
            }
            if (huTips != null && huTips.Count > 0)
            {
                for (int n = 0; n < huTips.Count; n++)
                {
                    var              tips     = huTips[n];
                    TileDef          tempDef  = TileDef.Create(tips.cCard);
                    UIGameHuItemView viewItem = _viewHuPrompt._viewHuItems[n];
                    if (viewItem != null)
                    {
                        viewItem.gameObject.SetActive(true);
                        viewItem._img_MJ.sprite     = UIOperation.Instance.GetMJSprite(tempDef);
                        viewItem._textBeishu.text   = tips.cTimes.ToString();
                        viewItem._textZhangshu.text = tips.cLeftNum.ToString();
                    }
                }

                int   count     = huTips.Count;
                float itemSize  = 130 * count;
                float itemScape = 10 * count - 10;
                float mySize    = 105;
                float maxSize   = itemSize + itemScape + mySize;
                _viewHuPrompt._imgBg.GetComponent <RectTransform>().sizeDelta = new Vector2(maxSize, 100);
                _viewHuPrompt._imgBg.localPosition       = new Vector3(-maxSize / 2, -166, 0);
                _viewHuPrompt._objHuPrompt.localPosition = new Vector3(91 - maxSize / 2, -125, 0);
            }
            else
            {
                _prefab.gameObject.SetActive(false);
            }
        }
        else
        {
            _prefab.gameObject.SetActive(false);
        }


//		int count = 0;
//        foreach (var huPromptInfo in UIOperation.Instance.hupai_infos)
//        {
//            string keyName = huPromptInfo.mjType.ToString() + huPromptInfo.mjView.ToString();
//            UIGameHuItemView viewItem;
//            if (_viewHuPrompt._viewHuItems.TryGetValue(keyName, out viewItem))
//            {
//                count++;
//                viewItem.gameObject.SetActive(true);
//                viewItem._textBeishu.text = huPromptInfo.beishu.ToString();
//                viewItem._textZhangshu.text = huPromptInfo.zhangshu.ToString();
//            }
//        }
//        if (count > 0) {
//            _prefab.gameObject.SetActive(true);
//            float itemSize = 130 * count;
//            float itemScape = 10 * count - 10;
//            float mySize = 105;
//            float maxSize = itemSize + itemScape + mySize;
//            _viewHuPrompt._imgBg.GetComponent<RectTransform>().sizeDelta = new Vector2(maxSize, 100);
//            _viewHuPrompt._imgBg.localPosition = new Vector3( - maxSize / 2, -166, 0);
//            _viewHuPrompt._objHuPrompt.localPosition = new Vector3(91 - maxSize / 2, -125, 0);
//        } else {
//            _prefab.gameObject.SetActive(false);
//        }
    }