Files

104 lines
3.1 KiB
C#

using UnityEngine;
using UnityEngine.UI;
public class settleTeamPrefab : MonoBehaviour
{
[Header("Ally Basic Information")]
public Image ally_profile;
public Text ally_name;
public Image ally_healthBar;
public Material grayM;
[Header("this_Ally_settlement")]
public Text thisAlly_earnExp;
public Text this_allyIdolScore;
[Header("Inspector")]
public Text this_allyDamageDealt;
public Text this_allyDamageTook;
public Text this_allyHealthRestored;
public Text this_allyManaRestored;
[Header("Inspector")]
public Button displayDetailContributionButton;
public GameObject detailContributionGO;
public void SetEmptyState()
{
// 1. Ally profile to transparent
if (ally_profile != null)
{
ally_profile.color = new Color(1f, 1f, 1f, 0f);
}
// 2. Name to "——"
if (ally_name != null)
{
ally_name.text = "——";
}
// 3. Health bar to 0
if (ally_healthBar != null)
{
ally_healthBar.fillAmount = 0f;
}
// 4. Statistics to "-"
if (thisAlly_earnExp != null) thisAlly_earnExp.text = "-";
if (this_allyIdolScore != null) this_allyIdolScore.text = "-";
if (this_allyDamageDealt != null) this_allyDamageDealt.text = "-";
if (this_allyDamageTook != null) this_allyDamageTook.text = "-";
if (this_allyHealthRestored != null) this_allyHealthRestored.text = "-";
if (this_allyManaRestored != null) this_allyManaRestored.text = "-";
// 5. Hide buttons/details
if (displayDetailContributionButton != null)
{
displayDetailContributionButton.gameObject.SetActive(false);
}
if (detailContributionGO != null)
{
detailContributionGO.SetActive(false);
}
}
private void Start()
{
// Documentation text normalized.
if (detailContributionGO != null)
{
detailContributionGO.SetActive(false);
}
// Documentation text normalized.
if (displayDetailContributionButton != null)
{
displayDetailContributionButton.onClick.AddListener(OnDisplayDetailContributionButtonClicked);
}
}
private void OnDestroy()
{
// Documentation text normalized.
if (displayDetailContributionButton != null)
{
displayDetailContributionButton.onClick.RemoveListener(OnDisplayDetailContributionButtonClicked);
}
}
private void OnDisplayDetailContributionButtonClicked()
{
if (detailContributionGO == null)
{
Debug.LogWarning("[settleTeamPrefab] detailContributionGO is not assigned");
return;
}
// Documentation text normalized.
bool isCurrentlyActive = detailContributionGO.activeSelf;
detailContributionGO.SetActive(!isCurrentlyActive);
if (GameConfig.verboseLogs)
{
Debug.Log($"[settleTeamPrefab] Detail contribution panel toggled: {!isCurrentlyActive}");
}
}
}