Exemple #1
0
    public void showQiaoHelp(bool status)
    {
        Transform Qiao = transform.Find("Qiao");

        if (!status)
        {
            Qiao.gameObject.SetActive(false);
            return;
        }

        Transform scroll = Qiao.Find("scroll");
        Transform grid   = scroll.Find("grid");

        UIScrollView roll = scroll.GetComponent <UIScrollView>();
        UIGrid       gd   = grid.GetComponent <UIGrid>();

        while (grid.childCount > 0)
        {
            DestroyImmediate(grid.GetChild(0).gameObject);
        }

        Qiao.gameObject.SetActive(true);

        List <TingOut> help = _options.help;

        for (int i = 0; i < help.Count; i++)
        {
            TingOut to = help[i];

            GameObject ob     = Instantiate(qiaoItem, grid) as GameObject;
            Transform  chupai = ob.transform.Find("chupai");
            chupai.localScale = new Vector3(0.7f, 0.7f, 1);
            chupai.GetComponent <Mahjong2D> ().setID(to.pai);

            HuPai     hu    = to.hus [0];
            Transform hupai = ob.transform.Find("hupai");
            hupai.localScale = new Vector3(0.6f, 0.6f, 1);
            hupai.GetComponent <Mahjong2D> ().setID(hu.pai);
            hupai.Find("score").GetComponent <UILabel>().text = hu.score + "倍";
            hupai.Find("num").GetComponent <UILabel>().text   = hu.num + "张";

            for (int j = 1; j < to.hus.Count; j++)
            {
                hu = to.hus[j];
                GameObject pai = Instantiate(hupai.gameObject, ob.transform) as GameObject;
                Transform  tm  = pai.transform;
                tm.GetComponent <Mahjong2D> ().setID(hu.pai);
                tm.localScale = new Vector3(0.6f, 0.6f, 1);
                tm.Translate(new Vector3(0.2f * j, 0, 0));
                tm.Find("score").GetComponent <UILabel>().text = hu.score + "倍";
                tm.Find("num").GetComponent <UILabel>().text   = hu.num + "张";
            }
        }

        gd.Reposition();
        roll.ResetPosition();

        //Transform btn = Qiao.Find("btn_cancel");
        //btn.localPosition = new Vector3(0, 35 - 200 * (help.Count - 1), 0);
    }
Exemple #2
0
    void showPrompt(List <HuPai> hus)
    {
        Transform prompt = transform.Find("prompt");
        Transform grid   = prompt.Find("grid");

        if (hus == null || hus.Count == 0)
        {
            prompt.gameObject.SetActive(false);
            return;
        }

        prompt.gameObject.SetActive(true);

        while (grid.childCount > 0)
        {
            DestroyImmediate(grid.GetChild(0).gameObject);
        }

        for (int i = 0; i < hus.Count; i++)
        {
            HuPai      hu = hus[i];
            GameObject ob = Instantiate(Resources.Load("Prefab/majiang/mj_prompt"), grid) as GameObject;
            Transform  tm = ob.transform;

            tm.localScale = new Vector3(0.6f, 0.6f, 1);
            tm.GetComponent <Mahjong2D> ().setID(hu.pai);
            tm.Find("score").GetComponent <UILabel>().text = hu.score >= 0 ? hu.score + "倍": "";
            tm.Find("num").GetComponent <UILabel>().text   = hu.num >= 0 ? hu.num + "张": "";
        }

        grid.GetComponent <UIGrid>().Reposition();
    }