80 lines
2.6 KiB
C#
80 lines
2.6 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 = MultilingualManager.Instance.GetMultilingualTextSafe(info2.ForceName);
|
|
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 =
|
|
MultilingualManager.Instance.GetMultilingualTextSafe(info1.ForceName) + " (您)";
|
|
Avatar2.sprite = info2.LeaderAvatar;
|
|
AvatarTextRight.text = MultilingualManager.Instance.GetMultilingualTextSafe(info2.ForceName);
|
|
MultilingualManager.Instance.SetUIText(BubbleChatText,Table.Instance.DiplomacyDataAssets.GetDiplomacyTextByAction((Forces)(player2.PlayerForceId),PlayerActionType.OfferAlly));
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(BubbleChat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|