12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using UnityEngine;
- namespace GFGGame
- {
- public class NumberUtil
- {
-
- public static string GetChiniseNumberText(int num)
- {
- int numInUnit = 0;
- int numInTen = 0;
- string strInUnit = "";
- string strInTen = "";
- if (num <= 10)
- {
- return GameConst.CHINESE_NUMBER[num - 1];
- }
- else if(num < 20)
- {
- numInUnit = num - 10;
- strInUnit = GameConst.CHINESE_NUMBER[numInUnit - 1];
- return "十" + strInUnit;
- }
- else if(num < 100)
- {
- numInTen = Mathf.FloorToInt(num / 10);
- strInTen = GameConst.CHINESE_NUMBER[numInTen - 1];
- numInUnit = num % 10;
- if(numInUnit == 0)
- {
- return strInTen + "十";
- }
- else
- {
- strInUnit = GameConst.CHINESE_NUMBER[numInUnit - 1];
- return strInTen + "十" + strInUnit;
- }
- }
- return "未知";
- }
- }
- }
|