Ejemplo n.º 1
0
        public void jump()
        {
            int len = orgStr.Length;

            if (len < 2)
            {
                return;
            }
            index++;
            if (index >= len)
            {
                index = 0;
            }
            string left  = StrEx.Left(orgStr, index);
            string mid   = StrEx.Mid(orgStr, index, 1);
            string right = StrEx.Right(orgStr, len - index - 1);
            string str   = PStr.b()
                           .a("[sub]")
                           .a(left)
                           .a("[/sup]")
                           .a("[sup]").a(mid).a("[/sup]")
                           .a("[sub]")
                           .a(right)
                           .a("[/sup]")
                           .e();

            base.text = str;
            timeCount = Time.time + speed;
        }
Ejemplo n.º 2
0
        public static string trimIntZero(string nStr)
        {
            if (string.IsNullOrEmpty(nStr))
            {
                return("");
            }
            string flag   = StrEx.Left(nStr, 1);
            string tmpStr = nStr;

            if (flag == "+" || flag == "-")
            {
                tmpStr = StrEx.Mid(nStr, 1);
            }
            else
            {
                flag = "";
            }
            int len   = tmpStr.Length;
            int index = 0;

            for (int i = 0; i < len; i++)
            {
                if (tmpStr [i] != '0')
                {
                    break;
                }
                index++;
            }

            return(flag + StrEx.Mid(tmpStr, index));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Encoder the specified str and scrtkey.加密
        /// </summary>
        /// <param name='str'>要加密的串
        /// String.
        /// </param>
        /// <param name='scrtkey'>密钥secretkey
        /// Scrtkey.
        /// </param>
        public static string encoder(string str, string scrtkey)
        {
            if (string.IsNullOrEmpty(str))
            {
                return("");
            }
            string unicodestr = "";
            string posstr     = "";
            string tmpstr     = "";
            string uniscrtkey = "";
            string ret        = "";
            int    i;

            int[] poslist = new int[str.Length];
            for (i = 0; i < str.Length; i++)
            {
                unicodestr  = unicodestr + (int)(str [i]);
                poslist [i] = unicodestr.Length;
            }
            for (i = 0; i < str.Length; i++)
            {
                tmpstr     = StrEx.Mid(unicodestr, poslist [i] - 1, 1);
                unicodestr = tmpstr + StrEx.Left(unicodestr, poslist [i] - 1) + StrEx.Mid(unicodestr, poslist [i]);
                posstr     = posstr + NumEx.nStrForLen(poslist [i], 4);              //每4位表示一个位置
            }
            for (i = 0; i < scrtkey.Length; i++)
            {
                uniscrtkey = uniscrtkey + (int)(scrtkey [i]);
            }
            string flag = "+";

            posstr = trimIntZero(posstr);
            string sub = bgnusub(uniscrtkey, posstr);

            if (!string.IsNullOrEmpty(sub) && sub.Length > 0 && sub [0] == '-')
            {
                sub  = StrEx.Mid(sub, 1);
                flag = "-";
            }
            //每四位中把前面为0的用+号代表
            string enSub = "";
            int    tmpN  = 0;

            for (i = sub.Length - 4; i >= 0; i = i - 4)
            {
                tmpN  = NumEx.stringToInt(StrEx.Mid(sub, i, 4));
                enSub = (tmpN.ToString().Length < 4 ? "+" : "") + tmpN + enSub;
            }
            if (i != -4)
            {
                tmpN  = NumEx.stringToInt(StrEx.Left(sub, i + 4));
                enSub = (tmpN.ToString().Length < 4 ? "+" : "") + tmpN + enSub;
            }

            ret = unicodestr + flag + enSub;
            return(ret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Filters the path.过滤路径
        /// </summary>
        /// <returns>
        /// The path.
        /// </returns>
        /// <param name='path'>
        /// Path.
        /// </param>
        public static string filterPath(string path)
        {
            string r = path;

            if (path.IndexOf("Assets/") == 0)
            {
                r = StrEx.Mid(path, 7);
            }
            r = r.Replace("\\", "/");
            r = r.Replace("/upgradeRes4Dev", "/upgradeRes");
            r = r.Replace("/upgradeRes4Publish/", "/upgradeRes/");
            return(r);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Decoder the specified encodestr and scrtkey.解密
        /// </summary>
        /// <param name='encodestr'>要解密的串
        /// Encodestr.
        /// </param>
        /// <param name='scrtkey'>密钥secretkey
        /// Scrtkey.
        /// </param>
        public static string decoder(string encodestr, string scrtkey)
        {
            if (string.IsNullOrEmpty(encodestr) || string.IsNullOrEmpty(scrtkey))
            {
                return("");
            }
            string result     = "";
            string unicodestr = "";
            string posstr     = "";
            string tmpstr     = "";
            string uniscrtkey = "";
            int    sizepos    = 0;
            int    i          = 0;
            char   splitChar  = '-';
            int    splitPos   = encodestr.IndexOf('-');

            if (splitPos < 0)
            {
                splitChar = '+';
                splitPos  = encodestr.IndexOf('+');
            }
            if (splitPos < 0)
            {
                return("");
            }
            unicodestr = StrEx.Left(encodestr, splitPos);
            posstr     = StrEx.Right(encodestr, encodestr.Length - splitPos - 1);
            string[] ss = posstr.Split('+');
            posstr = "";
            for (i = 0; i < ss.Length; i++)
            {
                int j = 0;
                tmpstr = "";
                for (j = ss [i].Length - 4; j >= 0; j = j - 4)
                {
                    tmpstr = StrEx.Mid(ss [i], j, 4) + tmpstr;
                }
                if (j != -4)
                {
                    int tmpN = NumEx.stringToInt(StrEx.Mid(ss [i], 0, j + 4));
                    tmpstr = NumEx.nStrForLen(tmpN, 4) + tmpstr;
                }
                posstr += tmpstr;
            }
            //去掉面前的0
            posstr = trimIntZero(posstr);

            if (splitChar == '-')
            {
                posstr = "-" + posstr;
            }
            for (i = 0; i < scrtkey.Length; i++)
            {
                uniscrtkey = uniscrtkey + (int)(scrtkey [i]);
            }
            posstr = bgnusub(uniscrtkey, posstr);
            if (posstr.Length % 4 == 0)
            {
                sizepos = posstr.Length / 4;
            }
            else
            {
                sizepos = posstr.Length / 4 + 1;
            }
            int[] poslist = new int[sizepos];
            for (i = 0; i < sizepos; i++)
            {
                int tmpN = 0;
                if (posstr.Length >= 4)
                {
                    tmpN = NumEx.stringToInt(StrEx.Right(posstr, 4));
                }
                else
                {
                    tmpN = NumEx.stringToInt(posstr);
                }
                if (tmpN == 0)
                {
                    break;
                }
                poslist [i] = tmpN;
                if (posstr.Length > 4)
                {
                    posstr = StrEx.Left(posstr, posstr.Length - 4);
                }
            }
            sizepos = i;
            for (i = 0; i < sizepos; i++)
            {
                unicodestr = StrEx.Left(unicodestr, poslist [i]) + StrEx.Mid(unicodestr, 0, 1) + StrEx.Mid(unicodestr, poslist [i]);
                unicodestr = StrEx.Mid(unicodestr, 1);
            }
            for (i = 0; i < sizepos; i++)
            {
                if (i != sizepos - 1)
                {
                    result = (char)(NumEx.stringToInt(StrEx.Mid(unicodestr, poslist [i + 1], poslist [i] - poslist [i + 1]))) + result;
                }
                else
                {
                    result = (char)(NumEx.stringToInt(StrEx.Mid(unicodestr, 0, poslist [i]))) + result;
                }
            }
            return(result);
        }