This commit is contained in:
2026-06-27 00:48:44 +08:00
parent 0ca378f42f
commit 84e247ce10
9 changed files with 70 additions and 169 deletions
@@ -31,6 +31,31 @@ public class ChineseChessMainPanel : GameMainPanel_Base
public TextMeshProUGUI tmp_CoinCount_Top;
public Image img_Title_Top;
public static string FormatGold(long gold)
{
if (gold >= 100000000)
{
// 截取两位小数,不四舍五入
long yi = gold / 100000000;
long remainder = gold % 100000000;
long decimals = remainder * 100 / 100000000;
if (decimals > 0)
return $"{yi}.{decimals:D2}亿";
return $"{yi}亿";
}
if (gold >= 10000)
{
// 截取两位小数,不四舍五入
long wan = gold / 10000;
long remainder = gold % 10000;
long decimals = remainder * 100 / 10000; // 两位小数
if (decimals > 0)
return $"{wan}.{decimals:D2}万";
return $"{wan}万";
}
return gold.ToString();
}
public void StartGame(string msg)
{
@@ -44,8 +69,8 @@ public class ChineseChessMainPanel : GameMainPanel_Base
case 1:
{
//等待加入 文字显示
tmp_Name_Top.text = "";
tmp_CoinCount_Top.text = "金币:" + "";
tmp_Name_Top.text = "ID:";
tmp_CoinCount_Top.text = "";
img_Title_Top.gameObject.SetActive(false);
}
break;
@@ -79,8 +104,8 @@ public class ChineseChessMainPanel : GameMainPanel_Base
{
if (item.userId == GameManager.Instance.user.BaseInfo.number)
{
tmp_Name_Bottom.text = item.userId;
tmp_CoinCount_Bottom.text = "金币:" + item.gold.ToString();
tmp_Name_Bottom.text ="ID:" + item.userId;
tmp_CoinCount_Bottom.text = FormatGold(item.gold);
StartCoroutine(item.DownTexture2d((t2d) =>
{
img_Title_Bottom.sprite = Sprite.Create(t2d, new Rect(0, 0, t2d.width, t2d.height), new Vector2(0.5f, 0.5f));
@@ -88,8 +113,8 @@ public class ChineseChessMainPanel : GameMainPanel_Base
}
else
{
tmp_Name_Top.text = item.userId;
tmp_CoinCount_Top.text = "金币:" + item.gold.ToString();
tmp_Name_Top.text ="ID:" + item.userId;
tmp_CoinCount_Top.text = FormatGold(item.gold);
StartCoroutine(item.DownTexture2d((t2d) =>
{
img_Title_Top.sprite = Sprite.Create(t2d, new Rect(0, 0, t2d.width, t2d.height), new Vector2(0.5f, 0.5f));