예제 #1
0
파일: Axis.cs 프로젝트: thehall45/GGNet
            public _Axis(bool dark, Position axisY)
            {
                axisY = axisY == Right ? Right : Left;

                Y     = axisY;
                Text  = new _Text(dark, axisY);
                Title = new _Title(dark, axisY);
            }
예제 #2
0
    public static Dictionary <int, List <int> > textOutputSpeedList; //保存播放字速度的列表

    //自动销毁文本信息
    public static void Destroy(_Text text)
    {
        textId--;           //减少一个文本的引用
        if (textId != -1)
        {
            richTextList.Remove(text.id);
        }
        else
        {
            richTextList.Clear();
        }

        Object.Destroy(_root.GetChild(text.id).gameObject);
        Object.Destroy(text);
    }
예제 #3
0
    //通过WWW来读取文件
    static IEnumerator LoadFromWWW(_Text t, string fileName, Action callback)
    {
        //读取保存在streamingAssets下的txt文件
        string          path  = "file://" + Application.streamingAssetsPath + '/' + fileName;
        List <string[]> lines = new List <string[]>();
        WWW             www   = new WWW(path);

        yield return(www);

        t.msg = www.text;
        t.msg = t.msg.Trim((char)65279);

        string[] arrs = t.msg.Split('\n');

        SplitString(lines, arrs);
        t.Resize(maxRowWordNum * t.textInfo.fontSize, lines.Count * (t.textInfo.fontSize + 5));           //重新调整文本域大小
        t.wordArray = lines;

        callback();
    }
예제 #4
0
    //解析登陆响应
    public static void ParseLoginInResponse(Message Info)
    {
        object obj    = Info.jsonObj["status"];
        int    status = int.Parse(obj.ToString());

        switch (status)
        {
        //登陆成功状态码
        case 200:

            TextManager.displayModeOpen = false;

            _Text t = TextManager.Show("登陆成功");
            t.SetMoveOpen(true).SetColor(Color.black)
            .SetCallback(() => {
                TextManager.Destroy(t);
                GameEntry.gameState = GameState.GameState_LOADING;
            });
            Debug.Log("登陆成功");
            break;

        //用户名不存在
        case 301:

            AlertManager.ShowYes().SetYesButtonText("确认").SetAlertInfo("该用户名不存在")
            .SetYesButtonEvent(() => {
                AlertManager.Destroy();
            });
            Debug.Log("用户名不存在");
            break;

        //登陆密码错误
        case 302:
            AlertManager.ShowYes().SetYesButtonText("确认").SetAlertInfo("登录密码错误")
            .SetYesButtonEvent(() => {
                AlertManager.Destroy();
            });
            Debug.Log("登陆密码错误");
            break;
        }
    }
예제 #5
0
파일: Strip.cs 프로젝트: thehall45/GGNet
 public _Strip(bool dark)
 {
     Text = new _Text(dark);
 }
예제 #6
0
    //可以直接是文本信息,或者是文本文件的名字(包含.txt)
    public static _Text Show(string msg)
    {
        if (_root == null)
        {
            _root = GameEntry.textRoot.transform;
        }

        GameObject obj = (GameObject)Object.Instantiate(Resources.Load <GameObject>("Text"), _root);

        obj.GetComponent <RectTransform>().localPosition = Vector3.zero;
        _Text t = obj.GetComponent <_Text>();

        t.id   = ++textId;
        t.name = t.id.ToString();               //挂载在TextManager根节点下的文本名字即为其id

        if (richTextList == null)
        {
            richTextList = new Dictionary <int, List <int> >();
        }

        if (textOutputSpeedList == null)
        {
            textOutputSpeedList = new Dictionary <int, List <int> >();
        }

        List <int> tmpList   = new List <int>();        //tmpList
        List <int> speedList = new List <int>();        //记录一句话中的速度点

        int i = 0, index = 0;

        //是否要展示文本文件中的信息
        if (msg.Contains(".txt"))
        {
            if (t.type == Type.None)
            {
                t.type = Type.TXT;
            }

            t.textInfo.text = msg;
            t.StartCoroutine(LoadFromWWW(t, msg, () =>
            {
                //把富文本开始索引下标添加到richTextList中
                while ((index = t.msg.IndexOf('<', i)) != -1)
                {
                    //进行标签预测(如果出现speed)
                    if (t.msg[index + 1] == 's' && t.msg[index + 2] == 'p')
                    {
                        speedList.Add(index);       //如果出现这个情况, 基本上可以判定该标签为标记文本输出速率的标签
                    }
                    else
                    {
                        tmpList.Add(index);
                    }
                    i = index + 1;
                }


                textOutputSpeedList.Add(t.id, speedList);
                richTextList.Add(t.id, tmpList);

                t.displayTextOnScreen = true;
            }));
        }
        else
        {
            //设置成
            if (t.type == Type.None)
            {
                t.type = Type.Message;
            }

            List <string[]> lines = new List <string[]>();
            t.msg = msg;
            SplitString(lines, msg);
            t.wordArray = lines;

            //把富文本开始索引下标添加到richTextList中
            while ((index = t.msg.IndexOf('<', i)) != -1)
            {
                //进行标签预测(如果出现speed)
                if (t.msg[index + 1] == 's' && t.msg[index + 2] == 'p')
                {
                    //Debug.Log(speedList.Count);
                    speedList.Add(index);       //如果出现这个情况, 基本上可以判定该标签为标记文本输出速率的标签
                }
                else
                {
                    tmpList.Add(index);
                }
                i = index + 1;
            }

            textOutputSpeedList.Add(t.id, speedList);
            richTextList.Add(t.id, tmpList);

            t.displayTextOnScreen = true;           //开启将文本展示在屏幕上
            t.textInfo.text       = msg;
        }

        return(t);
    }