96 lines
3.0 KiB
C#
96 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Animancer;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1Resource;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TH1_UI.View.Outside
|
|
{
|
|
public class UIOutsideLibraryHeroPanelMono : MonoBehaviour
|
|
{
|
|
|
|
public TextMeshProUGUI TopTitle;
|
|
public Image Illustration;
|
|
public TextMeshProUGUI Name;
|
|
public TextMeshProUGUI CivName;
|
|
public Image CivBG;
|
|
public RectTransform CivRect;
|
|
public TextMeshProUGUI Desc;
|
|
public TextMeshProUGUI Dialogue;
|
|
public Image DialogueAvatar;
|
|
public List<UIOutsideLibraryAchieveItemMono> AchieveItems;
|
|
|
|
public Button CloseButton;
|
|
public AnimancerComponent Animancer;
|
|
|
|
|
|
public void Init(Action onStartClick)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public void SetContent(GiantType giantType)
|
|
{
|
|
if (!Table.Instance.LibraryDataAssets.GetLibraryInfoByGiant(giantType, out var info)) return;
|
|
if (!Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(new UnitFullType(UnitType.Giant, giantType, 0),
|
|
out var unitInfo)) return;
|
|
var empire = unitInfo.GiantEmpire;
|
|
if (!Table.Instance.PlayerDataAssets.GetPlayerInfo(empire, out var playerInfo)) return;
|
|
|
|
MultilingualManager.Instance.SetUIText(TopTitle,info.Name);
|
|
Illustration.sprite = info.Illust;
|
|
MultilingualManager.Instance.SetUIText(Name,info.Name);
|
|
MultilingualManager.Instance.SetUIText(CivName,playerInfo.CivName);
|
|
CivBG.color = playerInfo.Color;
|
|
MultilingualManager.Instance.SetUIText(Desc,info.Desc);
|
|
MultilingualManager.Instance.SetUIText(Dialogue,info.Diag);
|
|
DialogueAvatar.sprite = unitInfo.Sprite;
|
|
|
|
//Step #3 设定成就
|
|
SetAchieveItems(giantType);
|
|
|
|
|
|
CloseButton.onClick.RemoveAllListeners();
|
|
CloseButton.onClick.AddListener(Hide);
|
|
|
|
}
|
|
|
|
|
|
private void SetAchieveItems(GiantType giantType)
|
|
{
|
|
if (AchieveItems.Count != 3) return;
|
|
for (int i = 0; i < 3; i++)
|
|
if(AchievementDataManager.Instance.GetSmallIdByGiantType(giantType,out var smallid))
|
|
AchieveItems[i].SetContent(2,smallid,(uint)i + 1);
|
|
}
|
|
public void Show()
|
|
{
|
|
gameObject.SetActive(true);
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(CivRect);
|
|
Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeIn);
|
|
|
|
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
var state = Animancer.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeOut);
|
|
state.Events.OnEnd = () => { gameObject.SetActive(false); };
|
|
}
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|
|
} |