104 lines
3.5 KiB
C#
104 lines
3.5 KiB
C#
using System.Collections.Generic;
|
||
using Logic;
|
||
using Logic.CrashSight;
|
||
using Logic.Multilingual;
|
||
using RuntimeData;
|
||
using TH1_Core.Events;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
namespace TH1_UI.View.Announce
|
||
{
|
||
public class UIAnnounceMajorEventView : Base.View
|
||
{
|
||
public Button closeButton;
|
||
public TextMeshProUGUI Title;
|
||
public TextMeshProUGUI Content;
|
||
public Transform ChatBubble;
|
||
public Transform CharImage;
|
||
public Transform WonderImage;
|
||
public ViDelegateAssisstant.Dele OnBtnCloseClick;
|
||
protected override void InitStart()
|
||
{
|
||
base.InitStart();
|
||
closeButton.onClick.RemoveAllListeners();
|
||
closeButton.onClick.AddListener(() => { OnBtnCloseClick.Invoke(); });
|
||
}
|
||
|
||
public void SetContent(UIAnnounceMajorEventType eventType, int param1, int param2)
|
||
{
|
||
if (Title == null || Content == null || CharImage == null || WonderImage == null)
|
||
{
|
||
LogSystem.LogError("UIAnnounceMajorEventView.SetContent(): Title or Content or Image or Image is null");
|
||
return;
|
||
}
|
||
|
||
UICenterMessageInfo info;
|
||
PlayerData player;
|
||
switch (eventType)
|
||
{
|
||
case UIAnnounceMajorEventType.StartGame:
|
||
|
||
//step #1 获取界面的文本info,以及真人玩家data和playerInfo
|
||
if (!Table.Instance.UICenterMessageDataAssets.GetUICenterMessageInfo(UICenterMessageID.StartGame, out info)) break;
|
||
player = Main.MapData.PlayerMap.SelfPlayerData;
|
||
Table.Instance.PlayerDataAssets.GetPlayerInfo(player, out var playerInfo);
|
||
|
||
//step #2 设置文字和图片
|
||
Content.text = MultilingualManager.Instance.GetMultilingualText(uint.Parse(info.Message));
|
||
Title.text = MultilingualManager.Instance.GetMultilingualText(uint.Parse(info.Title));
|
||
CharImage.gameObject.SetActive(true);
|
||
WonderImage.gameObject.SetActive(false);
|
||
if (CharImage.GetComponent<Image>() != null)
|
||
CharImage.GetComponent<Image>().sprite = playerInfo.LeaderIllustration;
|
||
|
||
//step #3 设置领袖的对话气泡内容
|
||
if (ChatBubble != null)
|
||
{
|
||
ChatBubble.gameObject.SetActive(true);
|
||
var txt = ChatBubble.Find("Text")?.GetComponent<TextMeshProUGUI>();
|
||
MultilingualManager.Instance.SetUIText(txt,playerInfo.GetRandomStartChat());
|
||
//ChatBubble.color = playerInfo.Color;
|
||
}
|
||
|
||
break;
|
||
case UIAnnounceMajorEventType.FirstMeet:
|
||
Title.text = "FirstMeet";
|
||
Content.text = "Test";
|
||
break;
|
||
case UIAnnounceMajorEventType.CivLose:
|
||
Title.text = "CivLose";
|
||
Content.text = "Test";
|
||
break;
|
||
case UIAnnounceMajorEventType.WonderStart:
|
||
case UIAnnounceMajorEventType.WonderEnd:
|
||
//step #1 获取各种info信息
|
||
if (!Table.Instance.UICenterMessageDataAssets.GetUICenterMessageInfo(eventType,(uint)param1,out info))break;
|
||
player = Main.MapData.PlayerMap.SelfPlayerData;
|
||
if (!Table.Instance.GridAndResourceDataAssets.GetWonderInfoByType(info.WonderType, player, out var wonderInfo)) break;
|
||
|
||
//step #2 设置界面信息
|
||
|
||
CharImage.gameObject.SetActive(false);
|
||
WonderImage.gameObject.SetActive(true);
|
||
if (WonderImage.GetComponent<Image>() != null)
|
||
WonderImage.GetComponent<Image>().sprite = wonderInfo.Sprite;
|
||
|
||
string nameParam = MultilingualManager.Instance.GetMultilingualText(uint.Parse(wonderInfo.Name));
|
||
MultilingualManager.Instance.SetUIText(Content,info.Message,new List<string>{nameParam});
|
||
MultilingualManager.Instance.SetUIText(Title ,info.Title);
|
||
|
||
//step #3 关闭bubble
|
||
if (ChatBubble != null) ChatBubble.gameObject.SetActive(false);
|
||
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
}
|