Esempio n. 1
0
    public static SmsSyntax Create(string text, UITable table, string name, bool isSpaceHide)
    {
        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/HeaderMenu/Recharge/smsSyntax"));

        obj.name                    = name;
        obj.transform.parent        = table.transform;
        obj.transform.localPosition = new Vector3(0f, 0f, -1f);
        obj.transform.localScale    = Vector3.one;
        SmsSyntax syntax = obj.GetComponent <SmsSyntax>();

        syntax.SetData(text, isSpaceHide);
        int   length     = syntax.label.text.Length;
        float scaleLable = syntax.label.transform.localScale.x - 4f;

        SmsSyntax.ListSmsSyntax.Add(syntax);
        return(syntax);
    }
Esempio n. 2
0
    private void ShowSMSTemplate()
    {
        if (model != null)
        {
            string   template       = model.Template;
            string[] smsTemplateArr = Regex.Split(template, regexSMSTemplate[0]);

            foreach (string sms in smsTemplateArr)
            {
                if (!string.IsNullOrEmpty(sms))
                {
                    if (Regex.IsMatch(sms, regexSMSTemplate[1]))
                    {
                        string user     = Regex.Match(sms, regexSMSTemplate[2]).Groups[1].Value;
                        string username = "";
                        switch (user)
                        {
                        case "username":
                            username = GameManager.Instance.mInfo.username;
                            break;

                        case "id":
                            username = GameManager.Instance.mInfo.id + "";
                            break;
                        }
                        SmsSyntax.Create(username, tableSynTax, 100 + " " + username, true);
                    }
                    else
                    {
                        string[] syntaxArr = Regex.Split(sms, " ");
                        for (int i = 0; i < syntaxArr.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(syntaxArr[i]))
                            {
                                SmsSyntax.Create(syntaxArr[i].ToUpper(), tableSynTax, i + " " + syntaxArr[i], false);
                            }
                        }
                    }
                }
            }
            numberPrefix.text         = model.Code;
            tableSynTax.repositionNow = true;
            float widthTable = 0f;

            for (int i = 0; i < tableSynTax.transform.childCount; i++)
            {
                NGUITools.AddWidgetCollider(tableSynTax.transform.GetChild(i).gameObject);
                if (i != tableSynTax.transform.childCount - 1)
                {
                    widthTable += tableSynTax.transform.GetChild(i).gameObject.GetComponent <BoxCollider>().size.x + 10f;
                }
                else
                {
                    widthTable += tableSynTax.transform.GetChild(i).gameObject.GetComponent <BoxCollider>().size.x;
                }

                GameObject.Destroy(tableSynTax.transform.GetChild(i).GetComponent <BoxCollider>());
            }
            tableSynTax.transform.localPosition = new Vector3(-widthTable / 2, tableSynTax.transform.localPosition.y, tableSynTax.transform.localPosition.z);
        }
    }