コード例 #1
0
ファイル: CLUIJumpLabel.cs プロジェクト: coolape/mibao
        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;
        }
コード例 #2
0
        /// <summary>
        /// Bignumberadditive the specified nu1 and nu2.
        /// 大数相加,以4位长的数字分段计算两个参数是不代符号的
        /// </summary>
        /// <param name='nu1'>
        /// Nu1.
        /// </param>
        /// <param name='nu2'>
        /// Nu2.
        /// </param>
        static string bignumberadditive(string nu1, string nu2)
        {
            string result = "";
            string a      = "";
            string b      = "";
            int    sizea  = 0;
            int    sizeb  = 0;
            string tmpstr;
            int    i = 0;

            a = nu1;
            b = nu2;

            if (a.Length < b.Length)
            {
                tmpstr = a;
                a      = b;
                b      = tmpstr;
            }

            if (a.Length % 4 == 0)
            {
                sizea = a.Length / 4;
            }
            else
            {
                sizea = a.Length / 4 + 1;
            }

            if (b.Length % 4 == 0)
            {
                sizeb = b.Length / 4;
            }
            else
            {
                sizeb = b.Length / 4 + 1;
            }
            string[] lista     = new string[sizea];
            string[] tmpresult = new string[sizea];
            string[] listb     = new string[sizeb];

            for (i = 0; i < sizea; i++)
            {
                if (a.Length > 4)
                {
                    lista[i] = StrEx.Right(a, 4);
                    a        = StrEx.Left(a, a.Length - 4);
                }
                else
                {
                    lista[i] = StrEx.Right(a, a.Length);
                    a        = StrEx.Left(a, a.Length);
                }
            }
            for (i = 0; i < sizeb; i++)
            {
                if (b.Length > 4)
                {
                    listb[i] = StrEx.Right(b, 4);
                    b        = StrEx.Left(b, b.Length - 4);
                }
                else
                {
                    listb[i] = StrEx.Right(b, b.Length);
                    b        = StrEx.Left(b, b.Length);
                }
            }

            for (i = 0; i < sizea; i++)
            {
                if (i < sizeb)
                {
                    tmpresult[i] = (NumEx.stringToInt(lista[i]) + NumEx.stringToInt(listb[i])).ToString();
                }
                else
                {
                    tmpresult[i] = lista[i];
                }
                if (i != 0)
                {
                    if ((tmpresult[i - 1]).Length == 5)
                    {
                        tmpresult[i] = (NumEx.stringToInt(tmpresult[i]) + 1).ToString();
                    }
                }
                if (i != sizea - 1)
                {
                    int tmpN = 0;
                    if (tmpresult[i].Length >= 4)
                    {
                        tmpN = NumEx.stringToInt(StrEx.Right(tmpresult[i], 4));
                    }
                    else
                    {
                        tmpN = NumEx.stringToInt(tmpresult[i]);
                    }
                    result = NumEx.nStrForLen(tmpN, 4) + result;
                }
                else
                {
                    result = tmpresult[i] + result;
                }
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Bignumbersubduct the specified nu1 and nu2.
        /// 大数相减,以4位长的数字分段计算
        /// 两个参数是不代符号的
        /// </summary>
        /// <param name='nu1'>
        /// Nu1.
        /// </param>
        /// <param name='nu2'>
        /// Nu2.
        /// </param>
        static string bignumbersubduct(string nu1, string nu2)
        {
            string result = "";
            string a;
            string b;
            string tmpstr;
            int    sizea = 0;
            int    sizeb = 0;

            int    i    = 0;
            string flag = "";

            a = nu1;
            b = nu2;
            if (a.Length < b.Length)
            {
                tmpstr = a;
                a      = b;
                b      = tmpstr;
                flag   = "-";
            }
            else if (a.Length == b.Length)
            {
                if (a.CompareTo(b) == -1)
                {
                    tmpstr = a;
                    a      = b;
                    b      = tmpstr;
                    flag   = "-";
                }
            }

            if (a.Length % 4 == 0)
            {
                sizea = a.Length / 4;
            }
            else
            {
                sizea = a.Length / 4 + 1;
            }

            if (b.Length % 4 == 0)
            {
                sizeb = b.Length / 4;
            }
            else
            {
                sizeb = b.Length / 4 + 1;
            }
            string[] lista     = new string[sizea];
            string[] tmpresult = new string[sizea];
            string[] listb     = new string[sizeb];
            for (i = 0; i < sizea; i++)
            {
                if (a.Length > 4)
                {
                    lista[i] = StrEx.Right(a, 4);
                    a        = StrEx.Left(a, a.Length - 4);
                }
                else
                {
                    lista[i] = StrEx.Right(a, a.Length);
                    a        = StrEx.Left(a, a.Length);
                }
            }

            for (i = 0; i < sizeb; i++)
            {
                if (b.Length > 4)
                {
                    listb[i] = StrEx.Right(b, 4);
                    b        = StrEx.Left(b, b.Length - 4);
                }
                else
                {
                    listb[i] = StrEx.Right(b, b.Length);
                    b        = StrEx.Left(b, b.Length);
                }
            }
            for (i = 0; i < sizea; i++)
            {
                if (i < sizeb)
                {
                    if (i != sizea - 1)
                    {
                        tmpresult[i] = (NumEx.stringToInt("1" + lista[i]) - NumEx.stringToInt(listb[i])).ToString();
                    }
                    else
                    {
                        tmpresult[i] = (NumEx.stringToInt(lista[i]) - NumEx.stringToInt(listb[i])).ToString();
                    }
                }
                else
                {
                    if (i != sizea - 1)
                    {
                        tmpresult[i] = "1" + lista[i];
                    }
                    else
                    {
                        tmpresult[i] = lista[i];
                    }
                }
                if (i != 0)
                {
                    if (tmpresult[i - 1].Length < 5)
                    {
                        tmpresult[i] = (NumEx.stringToInt(tmpresult[i]) - 1).ToString();
                    }
                }
                if (i != sizea - 1)
                {
                    int tempN = 0;
                    if (tmpresult[i].Length >= 4)
                    {
                        tempN = NumEx.stringToInt(StrEx.Right(tmpresult[i], 4));
                    }
                    else
                    {
                        tempN = NumEx.stringToInt(tmpresult[i]);
                    }

                    result = NumEx.nStrForLen(tempN, 4) + result;
                }
                else
                {
                    result = tmpresult[i] + result;
                }
            }
            result = flag + result;
            return(result);
        }
コード例 #4
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);
        }