Beispiel #1
0
    public void AddPai(MahjongPai pai, bool newPicked = false, bool isShow = false)
    {
        int   index = tehaiList.Count;
        float posX  = AlignLeftLocalPos.x + MahjongPai.Width * index + HaiPosOffsetX * index;

        pai.transform.parent        = transform;
        pai.transform.localPosition = new Vector3(posX, AlignLeftLocalPos.y, 0);

        if (isShow)
        {
            pai.Show();
        }
        else
        {
            pai.Hide();
        }

        if (OwnerPlayer.IsAI == false)
        {
            pai.SetOnClick(OnClickMahjong);
        }

        pai.gameObject.name = pai.ID.ToString();
        tehaiList.Add(pai);

        if (newPicked)
        {
            pai.transform.localPosition += new Vector3(NewHaiPosOffsetX, 0, 0);
        }
    }
Beispiel #2
0
    IEnumerator MoveMahjongPaiToKaze(int startID)
    {
        for (int i = 0, id = startID; i < kazePaiList.Count; i++, id++)
        {
            if (id > Hai.ID_PE)
            {
                id = Hai.ID_TON;
            }

            MahjongPai pai = kazePaiList.Find(mp => mp.ID == id);
            pai.Show();

            yield return(new WaitForSeconds(0.4f));

            TweenPosition tweener = TweenPosition.Begin(pai.gameObject, 0.3f, kazePosList[i]);
            tweener.style = UITweener.Style.Once;

            if (i == kazePaiList.Count - 1)
            {
                tweener.SetOnFinished(OnMoveEnd);
            }

            yield return(new WaitForSeconds(0.2f));
        }
    }
Beispiel #3
0
    //public override void SetParentPanelDepth( int depth ) {
    //    for( int i = 0; i < lineParents.Count; i++ ) {
    //        UIPanel panel = lineParents[i].GetComponent<UIPanel>();
    //
    //        panel.depth = depth + (lineParents.Count - i);
    //    }
    //}

    public void AddHai(MahjongPai pai)
    {
        int inLine      = _allHais.Count / MaxCoutPerLine; //inLine=0,1,2. >2 has a small chance.
        int indexInLine = _allHais.Count % MaxCoutPerLine;

        int EndingLine = Max_Lines - 1;

        if (inLine != _curLine)
        {
            if (inLine <= EndingLine)
            {
                _curLine = inLine;
                _curLineRightAligPosX = AlignLeftLocalPos.x;
            }
            else if (inLine > EndingLine)
            {
                _curLine = EndingLine;

                indexInLine           += MaxCoutPerLine;
                _curLineRightAligPosX += MahjongPai.Width + HaiPosOffsetX;
            }
        }
        else
        {
            if (indexInLine > 0)
            {
                _curLineRightAligPosX += MahjongPai.Width + HaiPosOffsetX;
            }
        }
        //pai.gameObject.layer = LayerMask.NameToLayer ("Hou");
        Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("Hou"));
        //pai.transform.parent = lineParents[_curLine];
        //pai.transform.localPosition = new Vector3(_curLineRightAligPosX, 0, 0);

        pai.transform.parent        = AllHouUI.instance.GiveHouParent();
        pai.transform.localPosition = new Vector3(AllHouUI.instance.GiveHouPoistion(_allHais.Count), 0, 0);

        pai.DisableInput();
        pai.SetEnableStateColor(true);
        _allHais.Add(pai);

        pai.Show(); //轉90度
        //lineParents[_curLine].GetComponent<UIPanel>().Update();
    }
Beispiel #4
0
    public void AddHai(MahjongPai pai)
    {
        int inLine      = _allHais.Count / MaxCoutPerLine; //inLine=0,1,2. >2 has a small chance.
        int indexInLine = _allHais.Count % MaxCoutPerLine;

        int EndingLine = Max_Lines - 1;

        if (inLine != _curLine)
        {
            if (inLine <= EndingLine)
            {
                _curLine = inLine;
                _curLineRightAligPosX = AlignLeftLocalPos.x;
            }
            else if (inLine > EndingLine)
            {
                _curLine = EndingLine;

                indexInLine           += MaxCoutPerLine;
                _curLineRightAligPosX += MahjongPai.Width + HaiPosOffsetX;
            }
        }
        else
        {
            if (indexInLine > 0)
            {
                _curLineRightAligPosX += MahjongPai.Width + HaiPosOffsetX;
            }
        }

        pai.transform.parent        = lineParents[_curLine];
        pai.transform.localPosition = new Vector3(_curLineRightAligPosX, 0, 0);

        pai.DisableInput();
        pai.SetEnableStateColor(true);
        _allHais.Add(pai);

        pai.Show();
        lineParents[_curLine].GetComponent <UIPanel>().Update();
    }
Beispiel #5
0
    public void AddPai(MahjongPai pai, bool newPicked = false, bool isShow = false)
    {
        int   index = tehaiList.Count;
        float posX  = AlignLeftLocalPos.x + MahjongPai.Width * index + HaiPosOffsetX * index;

        pai.transform.parent        = transform;
        pai.transform.localPosition = new Vector3(posX, AlignLeftLocalPos.y, 0);

        if (isShow)
        {
            pai.Show();
        }
        else
        {
            pai.Hide();
        }

        if (OwnerPlayer.IsAI == false)
        {
            //pai.gameObject.layer = LayerMask.NameToLayer("PlayerTehai");
            Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("PlayerTehai"));
            pai.SetOnClick(OnClickMahjong);
            pai.isPlayer = true;
        }
        else
        {
            Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("Default"));
        }

        pai.gameObject.name = pai.ID.ToString();
        tehaiList.Add(pai);

        if (newPicked)
        {
            pai.transform.localPosition += new Vector3(NewHaiPosOffsetX, 0, 0);
        }
    }
Beispiel #6
0
    public static MahjongPai CreateMahjongPai(Transform parent, Vector3 localPos, Hai info, bool isShow = true)
    {
        if (Hai.IsValidHai(info) == false)
        {
            Debug.LogError("PlayerUI: Invalid hai for ID == " + info.ID);
            return(null);
        }

        GameObject newInst = ResManager.CreateMahjongObject();

        newInst.transform.parent        = parent;
        newInst.transform.localScale    = Vector3.one;
        newInst.transform.localPosition = localPos;

        // set component info.
        MahjongPai pai = newInst.GetComponent <MahjongPai>();

        if (pai == null)
        {
            pai = newInst.AddComponent <MahjongPai>();
        }

        pai.SetInfo(info);
        pai.Init();
        pai.UpdateImage();

        if (isShow)
        {
            pai.Show();
        }
        else
        {
            pai.Hide();
        }

        return(pai);
    }