63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.Net;
|
|
using TH1_Logic.Steam;
|
|
using TH1_UI.HintUI;
|
|
using TH1_UI.View.Outside;
|
|
using TH1Resource;
|
|
using TMPro;
|
|
using UI.HintUI;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIOutsideSelectHeroPackMono : MonoBehaviour
|
|
{
|
|
|
|
|
|
public GiantType GiantType;
|
|
public TextMeshProUGUI HeroName;
|
|
public Image ChessIcon;
|
|
public Image ChessBG;
|
|
public RectTransform HeroNameRect;
|
|
public HintTrigger HintTrigger;
|
|
|
|
public void SetContent()
|
|
{
|
|
var fullType = new UnitFullType(UnitType.Giant, GiantType, 1);
|
|
if (!Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(fullType, out var info) || info == null)
|
|
{
|
|
Debug.LogWarning($"[UIOutsideSelectHeroPackMono] Missing UnitTypeInfo: GiantType={GiantType}, Level=1");
|
|
return;
|
|
}
|
|
|
|
if (!Table.Instance.PlayerDataAssets.GetPlayerInfo(info.GiantEmpire, out var playerInfo) || playerInfo == null)
|
|
{
|
|
Debug.LogWarning(
|
|
$"[UIOutsideSelectHeroPackMono] Missing PlayerInfo: GiantType={GiantType}, Civ={info.GiantEmpire.Civ}, Force={info.GiantEmpire.Force}");
|
|
return;
|
|
}
|
|
|
|
if (ChessBG == null || ChessIcon == null || HeroName == null || HeroNameRect == null || HintTrigger == null)
|
|
{
|
|
Debug.LogWarning($"[UIOutsideSelectHeroPackMono] Missing UI binding: GiantType={GiantType}");
|
|
return;
|
|
}
|
|
|
|
ChessBG.color = playerInfo.Color;
|
|
if (ResourceCache.Instance.SpriteCache.ChessSpriteDict.TryGetValue(info.ChessType, out var chessSprite))
|
|
ChessIcon.sprite = chessSprite;
|
|
var name = MultilingualManager.Instance.GetMultilingualText(info.Name);
|
|
name = name.Replace(" Lv.1", "");
|
|
HeroName.text = name;
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(HeroNameRect);
|
|
HintTrigger.DataProvider.HintDataType = HintDataType.TextDataGiantUpgrate;
|
|
HintTrigger.DataProvider.UnitFullType.GiantType = GiantType;
|
|
}
|
|
|
|
}
|