public static ResultXuongItemView Create(int index, Transform parent, EsObject eso)
    {
        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/CuocU/ResultMoneyItemPrefab"));

        obj.name                    = string.Format("Result_{0:0000}", index);
        obj.transform.parent        = parent;
        obj.transform.localPosition = new Vector3(0f, 0f, -1f);
        obj.transform.localScale    = Vector3.one;
        ResultXuongItemView resultXuong = obj.GetComponent <ResultXuongItemView>();
        long   money    = long.Parse(eso.getString("moneyExchange"));
        string userName = eso.getString("userName");

        resultXuong.playerName.text = userName;
        resultXuong.money.color     = (money < 0) ? new Color(255 / 255f, 0f, 0f) : new Color(255 / 255f, 255 / 255f, 0f);
        string summary = eso.getString("description");

        //List<List<Gameplay.Summary>> groupedSummaryByAction = GameModel.game.summaryGame.GroupBy(sum => sum.action).Select(grp => grp.ToList()).ToList();
        //string summary = "";
        if (money >= 0)
        {
            //foreach (List<Gameplay.Summary> lstSum in groupedSummaryByAction)
            //{
            //    string description = "";
            //    long moneyExchage = 0;
            //    foreach (Gameplay.Summary sum in lstSum)
            //    {
            //        if (string.IsNullOrEmpty(description))
            //        {
            //            if (sum.action == Gameplay.Summary.EAction.LOSS_FINISH_TYPE)
            //                description = "Thắng" + " : ";
            //            else
            //                description = sum.description + " : ";
            //        }
            //        moneyExchage += sum.moneyExchange;
            //    }
            //    summary += description + moneyExchage + "\n";
            //}
            summary = summary + "Tổng : " + Utility.Convert.Chip(System.Math.Abs(money));
        }
        else
        {
            //foreach (List<Gameplay.Summary> lstSum in groupedSummaryByAction)
            //{
            //    Gameplay.Summary sum = lstSum.Find(s => s.sourcePlayer == userName);
            //    if (sum != null)
            //        summary += sum.description + " : -" + sum.moneyExchange + "\n";
            //}
            summary = summary + "Tổng : -" + Utility.Convert.Chip(System.Math.Abs(money));
        }
        resultXuong.money.text = summary;
        resultXuong.ReposionComponent();
        return(resultXuong);
    }
Beispiel #2
0
    void Init(string correct, string incorrect, int point, string textGa, Electrotank.Electroserver5.Api.EsObject[] listObj, string infoFullaying)
    {
        resultXuongCorrect.text  = "[FF9900]" + correct + "\n\n";
        resultXuongCorrect.text += "Tổng điểm: " + point + (string.IsNullOrEmpty(textGa) ? "" : " - " + textGa) + "[-]\n\n";
        resultXuongCorrect.text += string.IsNullOrEmpty(incorrect) ? "" : "[FF0000]" + splitMessageResultsIncorrect(incorrect) + "[-]\n\n";
        resultXuongCorrect.text += "[3B8723]" + infoFullaying + "[-]";

        int i = 0;

        foreach (Electrotank.Electroserver5.Api.EsObject obj in listObj)
        {
            i++;
            long money = long.Parse(obj.getString("moneyExchange"));
            ResultXuongItemView item = ResultXuongItemView.Create(i, panelListResult.transform, obj);
            if (money > 0)
            {
                item.gameObject.name = "__0";
            }
        }

        panelListText.Reposition();
        panelListText.transform.parent.GetComponent <UIScrollView> ().ResetPosition();
        panelListResult.Reposition();
    }