104 lines
3.2 KiB
C#
104 lines
3.2 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 UIOutsideLibraryWonderPanelMono : MonoBehaviour
|
|
{
|
|
|
|
public TextMeshProUGUI TopTitle;
|
|
public Image WonderImage;
|
|
public Image GroundImage;
|
|
public TextMeshProUGUI Name;
|
|
public TextMeshProUGUI CivName;
|
|
public Image CivBG;
|
|
public RectTransform CivRect;
|
|
public TextMeshProUGUI Desc;
|
|
public List<UIOutsideLibraryAchieveItemMono> AchieveItems;
|
|
|
|
public Button CloseButton;
|
|
public AnimancerComponent Animancer;
|
|
|
|
|
|
public void Init(Action onStartClick)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public void SetContent(Empire empire,WonderTypeEnum wonderType)
|
|
{
|
|
|
|
if (!Table.Instance.LibraryDataAssets.GetLibraryInfoByWonder(empire, wonderType,out var info)) return;
|
|
if (!Table.Instance.PlayerDataAssets.GetPlayerInfo(empire, out var playerInfo)) return;
|
|
var groundSprite = Table.Instance.GridAndResourceDataAssets.GetGroundSprite(empire.Civ, GridSpType.None);
|
|
var wonderSprite = Table.Instance.GridAndResourceDataAssets.GetWonderSprite( empire,wonderType);
|
|
MultilingualManager.Instance.SetUIText(TopTitle,info.Name);
|
|
WonderImage.sprite = wonderSprite;
|
|
GroundImage.sprite = groundSprite;
|
|
MultilingualManager.Instance.SetUIText(Name,info.Name);
|
|
MultilingualManager.Instance.SetUIText(CivName,playerInfo.CivName);
|
|
CivBG.color = playerInfo.Color;
|
|
MultilingualManager.Instance.SetUIText(Desc,info.Desc);
|
|
|
|
|
|
//Step #3 设定成就
|
|
SetAchieveItems(empire,wonderType);
|
|
|
|
|
|
CloseButton.onClick.RemoveAllListeners();
|
|
CloseButton.onClick.AddListener(Hide);
|
|
|
|
}
|
|
|
|
private void SetAchieveItems(Empire empire ,WonderTypeEnum wonderType)
|
|
{
|
|
if (AchieveItems.Count != 3) return;
|
|
if (!AchievementDataManager.Instance.GetSmallIdByWonderAndEmpire(empire ,wonderType,out var smallid))
|
|
{
|
|
for (int i = 0; i < AchieveItems.Count; i++)
|
|
AchieveItems[i].gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
AchieveItems[i].gameObject.SetActive(true);
|
|
AchieveItems[i].SetContent(3,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()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|