43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class CoinScript : BJBase
|
|
{
|
|
public override void SetCoinCount()
|
|
{
|
|
tMP_CoinCount.text = NumAdd(coinCount.ToString());
|
|
|
|
// 自己爆奖显示金,别人显示银
|
|
bool isMine = IsLocalPlayer();
|
|
if (gold != null) gold.SetActive(isMine);
|
|
if (silver != null) silver.SetActive(!isMine);
|
|
}
|
|
|
|
private bool IsLocalPlayer()
|
|
{
|
|
// 优先用 userID 判断
|
|
if (!string.IsNullOrEmpty(userID)
|
|
&& GameManager.Instance != null
|
|
&& GameManager.Instance.user != null
|
|
&& userID == GameManager.Instance.user.id)
|
|
return true;
|
|
|
|
// 兜底:用 sitID 判断(boss 杀小鱼时 userID 可能为空)
|
|
if (GameManager.Instance == null || GameManager.Instance.user == null)
|
|
return false;
|
|
|
|
var sits = CreateFishManager.Instance?.currGameType?.list_Sits;
|
|
if (sits == null) return false;
|
|
|
|
foreach (var sit in sits)
|
|
{
|
|
if (sit != null && sit.user == GameManager.Instance.user.id)
|
|
return sitID == sit.posID;
|
|
}
|
|
return false;
|
|
}
|
|
}
|