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
    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 #3
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);
    }