예제 #1
0
    public static string getShowValue(GameObject fahter, UILabel label, string mValue)
    {
        clear(fahter);
        int count = 0, spriteCount = 0;

        for (int i = 0; i < mValue.Length;)
        {
            if (mValue[i] == '#' && i + 4 < mValue.Length && mValue[i + 4] == '*' && (mValue[i + 1] >= '0' && mValue[i + 1] <= '9') && (mValue[i + 2] >= '0' && mValue[i + 2] <= '9') && (mValue[i + 3] >= '0' && mValue[i + 3] <= '9'))
            {
                string num = string.Format("{0}{1}{2}", mValue[i + 1], mValue[i + 2], mValue[i + 3]);
                for (int j = 0; j < 5; j++)
                {
                    buffer[count] = ' ';
                    count++;
                }
                char[] newchs = new char[count];
                System.Array.Copy(buffer, newchs, count);
                string newStr = new string(newchs);
                label.text = newStr;
                Vector2 v2 = MyUtilTools.compute(label);
                if (baseExpression == null)
                {
                    baseExpression = Resources.Load <GameObject>("prefabs/e1");
                }
                GameObject expression = NGUITools.AddChild(fahter, baseExpression);
                string     sn         = "e" + int.Parse(num);
                expression.name = "e" + spriteCount;
                UISprite sprite = expression.GetComponent <UISprite>();
                sprite.spriteName = sn;
                float x = v2.x;
                float y = v2.y - 20;
                expression.transform.localPosition = new Vector3(x, y, 0);
                UIButton button = expression.GetComponent <UIButton>();
                button.enabled      = false;
                button.normalSprite = sn;
                i += 5;
                spriteCount++;
            }
            else
            {
                buffer[count] = mValue[i];
                i++;
                count++;
            }
        }
        char[] nchs = new char[count];
        System.Array.Copy(buffer, nchs, count);
        return(new string (nchs));
    }