62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using System;
|
|
using asap.core;
|
|
using Event1v1Battle.Data;
|
|
using game;
|
|
using GameCore;
|
|
using UnityEngine;
|
|
|
|
namespace Event1v1Battle.Panel
|
|
{
|
|
/// <summary>
|
|
/// 1v1扇耳光大赛加载面板 Event1v1BattleSlapLoadingPanel
|
|
/// </summary>
|
|
public class Event1v1BattleSlapLoadingPanel : BasePanel
|
|
{
|
|
#region UI Elements
|
|
|
|
private DuelMatchPlayer _myself;
|
|
private DuelMatchPlayer _enemy;
|
|
|
|
#endregion
|
|
private Event1v1BattleSlapData _data;
|
|
private Event1v1BattleSlapManager _manager;
|
|
[SerializeField] private float transitionTime = 0.5f;
|
|
public void SetData(Event1v1BattleSlapManager manager, Event1v1BattleSlapData data)
|
|
{
|
|
_manager = manager;
|
|
_data = data;
|
|
ShowUI();
|
|
PlayEndTransition();
|
|
}
|
|
private void Awake()
|
|
{
|
|
_myself = gameObject.FindChildGameObject("myself").GetComponentInChildren<DuelMatchPlayer>();
|
|
_enemy = gameObject.FindChildGameObject("enemy").GetComponentInChildren<DuelMatchPlayer>();
|
|
}
|
|
|
|
private void ShowUI()
|
|
{
|
|
IUserService userService = GContext.container.Resolve<IUserService>();
|
|
var uiService = GContext.container.Resolve<IUIService>();
|
|
uiService.SetHeadImage(_myself.icon_head, userService.AvatarUrl);
|
|
_myself.text_name.text = userService.DisplayName;
|
|
if(_data==null) return;
|
|
uiService.SetHeadImage(_enemy.icon_head, _data.NpcIcon);
|
|
_enemy.text_name.text = _data.NpcName;
|
|
}
|
|
private async void PlayEndTransition()
|
|
{
|
|
try
|
|
{
|
|
await Awaiters.Seconds(transitionTime);
|
|
UIManager.Instance.DestroyUI(UITypes.Event1v1BattleSlapLoadingPanel);
|
|
await _manager.ShowTvPanel(_data);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogError(e);
|
|
}
|
|
}
|
|
}
|
|
}
|