Example #1
0
    void unittest()
    {
        GameOverPlayerInfo info = new GameOverPlayerInfo();

        info.angangs = new List <int> ();
        info.angangs.Add(11);

        info.diangangs = new List <int> ();
        info.wangangs  = new List <int> ();
        info.chis      = new List <int> ();
        info.chis.Add(133);
        info.pengs = new List <int> ();

        info.button = 0;
        info.holds  = new List <int> ();
        info.holds.Add(21);
        info.holds.Add(22);
        info.holds.Add(23);
        info.holds.Add(24);
        info.holds.Add(25);
        info.holds.Add(26);
        info.holds.Add(27);
        info.ma     = 31;
        info.userid = 2;

        HuInfo hu = new HuInfo();

        hu.fangpao = false;
        hu.zimo    = true;
        hu.hued    = true;
        hu.pai     = 39;

        info.hu    = hu;
        info.score = -9000;
        info.name  = "小叶子";

        ResultDetail detail = new ResultDetail();

        detail.tips = "底1花300 抢杠胡";
        info.detail = detail;


        List <GameOverPlayerInfo> results = new List <GameOverPlayerInfo> ();

        results.Add(info);
        results.Add(info);
        results.Add(info);
        results.Add(info);

        showResults(results);
    }
Example #2
0
    void initSeat(Transform seat, GameOverPlayerInfo info)
    {
        int x = 160;
        int y = -20;

        Debug.Log("initSeat");

        Mahjong2D[] mjs = seat.GetComponentsInChildren <Mahjong2D>();
        foreach (Mahjong2D mj in mjs)
        {
            Destroy(mj.gameObject);
        }

        foreach (int i in info.angangs)
        {
            initPengGangs(seat, i, "angang", x);
            x += 55 * 3 + 10;
        }

        foreach (int i in info.wangangs)
        {
            initPengGangs(seat, i, "wangang", x);
            x += 55 * 3 + 10;
        }

        foreach (int i in info.diangangs)
        {
            initPengGangs(seat, i, "diangang", x);
            x += 55 * 3 + 10;
        }

        foreach (int i in info.pengs)
        {
            initPengGangs(seat, i, "peng", x);
            x += 55 * 3 + 10;
        }

        foreach (int i in info.chis)
        {
            initChis(seat, i, x);
            x += 55 * 3 + 10;
        }

        ResultDetail detail = info.detail;
        UILabel      tips   = seat.Find("tips").GetComponent <UILabel> ();

        tips.text = detail == null ? "" : detail.tips;
        //tips.transform.localPosition = new Vector3 (x - 27, 50, 0);

        List <int> holds = info.holds;

        holds.Sort();

        for (int i = 0; i < holds.Count; i++)
        {
            initMahjong(seat, holds [i], new Vector2(x, y), 4);

            x += 55;
        }

        HuInfo hu   = info.hu;
        bool   hued = false;

        if (hu != null && hu.hued)
        {
            hued = true;
            x   += 80;
            initMahjong(seat, hu.pai, new Vector2(x, y), 4);
            x += 55;
        }

        int ma = info.ma;

        seat.Find("lbl").gameObject.SetActive(ma > 0);
        seat.Find("ma").gameObject.SetActive(ma > 0);
        if (ma > 0)
        {
            UILabel lbl = seat.Find("ma").GetComponent <UILabel> ();
            lbl.text = "+" + ma;
        }

        SpriteMgr huinfo = seat.Find("huinfo").GetComponent <SpriteMgr>();

        int huid = -1;

        if (hu != null)
        {
            if (hu.zimo)
            {
                huid = 1;                 // TODO
            }
            else if (hu.hued)
            {
                huid = 1;
            }
            else if (hu.fangpao)
            {
                huid = 0;
            }
        }

        Debug.Log("huid=" + huid);
        huinfo.setIndex(huid);
        //huinfo.transform.localPosition = new Vector2 (1142, 0);

        string score = info.score >= 0 ? "+" + info.score : "" + info.score;

        seat.Find("score").GetComponent <UILabel>().text = score;
#if !UNIT_TEST
        seat.Find("bghead/icon").GetComponent <IconLoader>().setUserID(info.userid);
#endif
        seat.Find("name").GetComponent <UILabel>().text = info.name;
    }