89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Logic;
|
|
using Logic.Action;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1_Core.Events;
|
|
using TH1_Logic.Action;
|
|
using TH1_Logic.Core;
|
|
using TH1_UI.View.Announce;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TH1_UI.View.Interaction
|
|
{
|
|
public class UIInteractionDiplomacyOfferAllyView : Base.View
|
|
{
|
|
|
|
public TextMeshProUGUI Title;
|
|
public TextMeshProUGUI Content;
|
|
public Image Avatar1;
|
|
public TextMeshProUGUI AvatarTextLeft;
|
|
public Image Avatar2;
|
|
public TextMeshProUGUI AvatarTextRight;
|
|
|
|
public Button YesButton;
|
|
public Button NoButton;
|
|
|
|
|
|
public RectTransform BubbleChat;
|
|
public TextMeshProUGUI BubbleChatText;
|
|
public ViDelegateAssisstant.Dele OnYesChoiceMade;
|
|
public ViDelegateAssisstant.Dele OnNoChoiceMade;
|
|
protected override void OnInit()
|
|
{
|
|
base.OnInit();
|
|
|
|
YesButton.onClick.RemoveAllListeners();
|
|
YesButton.onClick.AddListener(()=> { OnYesChoiceMade?.Invoke(); });
|
|
NoButton.onClick.RemoveAllListeners();
|
|
NoButton.onClick.AddListener(()=> { OnNoChoiceMade?.Invoke(); });
|
|
|
|
}
|
|
|
|
public void SetContent(ShowUIInteractionDiplomacyOfferAlly evt)
|
|
{
|
|
//Step #1 判断鲁棒性
|
|
if (Avatar1 == null || Avatar2 == null || YesButton == null || NoButton == null || Title == null)
|
|
{
|
|
return;
|
|
}
|
|
var player1 = Main.MapData.PlayerMap.SelfPlayerData;
|
|
if(!Table.Instance.PlayerDataAssets.GetPlayerInfo(player1,out var info1)) return;
|
|
|
|
//step #2 设置title
|
|
if (!Main.MapData.PlayerMap.GetPlayerDataByPlayerID(evt.PlayerId, out var player2)) return;
|
|
if(!Table.Instance.PlayerDataAssets.GetPlayerInfo(player2,out var info2)) return;
|
|
var forceName = Logic.PlayerLogic.GetDisplayForceName(Main.MapData, player2);
|
|
MultilingualManager.Instance.SetUIText(Title,Table.Instance.DiplomacyDataAssets.DiplomacyUIAnnounceOfferAllyTitle);
|
|
MultilingualManager.Instance.SetUIText(Content,Table.Instance.DiplomacyDataAssets.DiplomacyUIAnnounceOfferAlly,new List<string>(){forceName});
|
|
//Step #3 设置Avatar和bubble chat
|
|
|
|
Avatar1.sprite = info1.LeaderAvatar;
|
|
AvatarTextLeft.text =
|
|
Logic.PlayerLogic.GetDisplayForceName(Main.MapData, player1) + " (" + MultilingualManager.Instance.GetMultilingualTextSafe(Table.Instance.TextDataAssets.PresentationUIDiplomacyYouText) +")";
|
|
Avatar2.sprite = info2.LeaderAvatar;
|
|
AvatarTextRight.text = Logic.PlayerLogic.GetDisplayForceName(Main.MapData, player2);
|
|
var offerChatText = Table.Instance.DiplomacyDataAssets.GetDiplomacyTextByAction((Forces)(player2.PlayerForceId),PlayerActionType.OfferAlly);
|
|
if (string.IsNullOrEmpty(offerChatText))
|
|
{
|
|
BubbleChat.gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
BubbleChat.gameObject.SetActive(true);
|
|
MultilingualManager.Instance.SetUIText(BubbleChatText, offerChatText);
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(BubbleChat);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|