78 lines
1.9 KiB
C#
78 lines
1.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Logic.Multilingual;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.Net;
|
|
using TH1_Logic.Steam;
|
|
using TH1_UI.View.Outside;
|
|
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIOutsideSelectAvatarMono : MonoBehaviour
|
|
{
|
|
|
|
|
|
public Image AvatarImg;
|
|
public GameObject ChatBox;
|
|
public Button Button;
|
|
public TextMeshProUGUI ChatText;
|
|
public TextMeshProUGUI Title;
|
|
public GameObject SelectBG;
|
|
public Empire PlayerEmpire => _playerEmpire;
|
|
|
|
private Action<Empire> _onButtonClick;
|
|
private Empire _playerEmpire;
|
|
private bool _hasChatContent;
|
|
|
|
|
|
|
|
public void SetContent(Empire t,Action<Empire> OnButtonClick)
|
|
{
|
|
_playerEmpire = t;
|
|
if (!Table.Instance.PlayerDataAssets.GetPlayerInfo(t.Civ, t.Force, out var info)) return;
|
|
AvatarImg.sprite = info.LeaderAvatar;
|
|
_onButtonClick = OnButtonClick;
|
|
var startChat = info.GetRandomStartChat();
|
|
_hasChatContent = startChat != "0" && !string.IsNullOrEmpty(startChat);
|
|
ChatBox.SetActive(false);
|
|
if (_hasChatContent)
|
|
{
|
|
MultilingualManager.Instance.SetUIText(ChatText, startChat);
|
|
}
|
|
MultilingualManager.Instance.SetUIText(Title, info.ForceName);
|
|
SelectBG.SetActive(false);
|
|
Button.onClick.RemoveAllListeners();
|
|
Button.onClick.AddListener(()=>
|
|
{
|
|
SetShow();
|
|
_onButtonClick.Invoke(_playerEmpire);
|
|
});
|
|
}
|
|
|
|
public void SetShow()
|
|
{
|
|
ChatBox.SetActive(_hasChatContent);
|
|
SelectBG.SetActive(true);
|
|
}
|
|
|
|
public void SetHide()
|
|
{
|
|
ChatBox.SetActive(false);
|
|
SelectBG.SetActive(false);
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|