Exemplo n.º 1
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();
    }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
0
    public void UpdateFuuro(Fuuro[] fuuros)
    {
        if (fuuros == null)
        {
            return;
        }

        // clear all fuuro.
        Clear();

        // create new.
        for (int i = 0; i < fuuros.Length; i++)
        {
            Fuuro      fuu       = fuuros[i];
            EFuuroType fuuroType = fuu.Type;

            if (i > 0)
            {
                curMaxPosX -= FuuroOffsetX;
            }

            int   newPickIndex = fuu.NewPickIndex;
            Hai[] hais         = fuu.Hais;
            //int relation = fuu.Relation;

            bool shouldSetLand = false;

            switch (fuuroType)
            {
            case EFuuroType.MinShun:     //Chii.
            case EFuuroType.MinKou:      // Pon.
            case EFuuroType.KaKan:       // 加杠.
            case EFuuroType.DaiMinKan:   // 大明杠.
            {
                for (int j = 0; j < hais.Length; j++)
                {
                    if (hais[j].ID < 0)
                    {
                        continue;
                    }

                    shouldSetLand = (j == newPickIndex);

                    float   posX     = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f;
                    Vector3 localPos = new Vector3(posX, 0, 0);

                    MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], true);

                    if (shouldSetLand)
                    {
                        pai.SetOrientation(EOrientation.Landscape_Left);

                        pai.transform.localPosition += new Vector3(0, MahjongPai.LandHaiPosOffsetY, 0);
                    }

                    pai.DisableInput();
                    fuuroHais.Add(pai);

                    // update curMaxPosX.
                    curMaxPosX -= GetMahjongRange(shouldSetLand);
                }
            }
            break;

            case EFuuroType.AnKan:     // 暗杠.
            {
                for (int j = 0; j < hais.Length; j++)
                {
                    if (hais[j].ID < 0)
                    {
                        continue;
                    }

                    shouldSetLand = false;

                    float   posX     = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f;
                    Vector3 localPos = new Vector3(posX, 0, 0);

                    bool isShow = (j != 0 && j != hais.Length - 1);     // 2 sides hide.

                    MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], isShow);

                    fuuroHais.Add(pai);

                    // update curMaxPosX.
                    curMaxPosX -= GetMahjongRange(shouldSetLand);
                }
            }
            break;
            }
        } // end for().
    }
Exemplo n.º 4
0
    public void UpdateFuuro(Fuuro[] fuuros, bool isAI)
    {
        if (fuuros == null)
        {
            return;
        }

        // clear all fuuro.
        Clear();

        // create new.
        for (int i = 0; i < fuuros.Length; i++)
        {
            Fuuro      fuu       = fuuros[i];
            EFuuroType fuuroType = fuu.Type;

            if (i > 0)
            {
                curMaxPosX -= FuuroOffsetX;
            }

            int   newPickIndex = fuu.NewPickIndex;
            Hai[] hais         = fuu.Hais;
            //int relation = fuu.Relation;

            bool shouldSetLand = false;

            switch (fuuroType)
            {
            case EFuuroType.MinShun:     //Chii.
            case EFuuroType.MinKou:      // Pon.
            case EFuuroType.KaKan:       // 加杠.
            case EFuuroType.DaiMinKan:   // 大明杠.
            {
                for (int j = 0; j < hais.Length; j++)
                {
                    if (hais[j].ID < 0)
                    {
                        continue;
                    }

                    shouldSetLand = (j == newPickIndex);     //是否擺橫的

                    float   posX     = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f;
                    Vector3 localPos = new Vector3(posX, 0, 0);

                    //吃牌要擺中間
                    if (j == 0)
                    {
                        localPos = new Vector3(posX - GetMahjongRange(shouldSetLand), 0, 0);
                    }
                    else if (j == 1)
                    {
                        localPos = new Vector3(posX + GetMahjongRange(shouldSetLand), 0, 0);
                    }
                    else if (j == 3)
                    {
                        localPos = new Vector3(posX + GetMahjongRange(shouldSetLand) * 2, 0.4f, 0);
                    }

                    MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], true);

                    if (!isAI)
                    {
                        Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("PlayerFuuro"));
                    }
                    else
                    {
                        Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("Default"));
                    }

                    //if( shouldSetLand ) {
                    //    //pai.SetOrientation(EOrientation.Landscape_Left);

                    //    pai.transform.localPosition += new Vector3(0, MahjongPai.LandHaiPosOffsetY, 0);
                    //}

                    pai.DisableInput();
                    fuuroHais.Add(pai);

                    // update curMaxPosX.
                    if (j != 3)
                    {
                        curMaxPosX -= GetMahjongRange(shouldSetLand);
                    }
                }
            }
            break;

            case EFuuroType.AnKan:     // 暗杠.
            {
                for (int j = 0; j < hais.Length; j++)
                {
                    if (hais[j].ID < 0)
                    {
                        continue;
                    }

                    shouldSetLand = false;

                    float   posX     = curMaxPosX - GetMahjongRange(shouldSetLand) * 0.5f;
                    Vector3 localPos = new Vector3(posX, 0, 0);

                    //bool isShow = (j != 0 && j != hais.Length - 1); // 2 sides hide.
                    bool isShow = (j == 3);     // 2 sides hide.

                    //第四張擺上面
                    if (j == 3)
                    {
                        localPos = new Vector3(posX + GetMahjongRange(shouldSetLand) * 2, 0.4f, 0);
                    }

                    MahjongPai pai = PlayerUI.CreateMahjongPai(transform, localPos, hais[j], isShow);

                    if (!isAI)
                    {
                        Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("PlayerFuuro"));
                    }
                    else
                    {
                        Utils.SetLayerRecursively(pai.gameObject, LayerMask.NameToLayer("Default"));
                    }

                    fuuroHais.Add(pai);

                    // update curMaxPosX.
                    if (j != 3)
                    {
                        curMaxPosX -= GetMahjongRange(shouldSetLand);
                    }
                }
            }
            break;
            }
        } // end for().
    }