62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using BITKit.UX;
|
|
using Cysharp.Threading.Tasks;
|
|
using Project.B.Map;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace Net.Like.Xue.Tokyo.UX
|
|
{
|
|
public class UXLevel : UIToolKitPanel
|
|
{
|
|
private readonly IGameMapService _gameMapService;
|
|
private readonly IEntitiesService _entitiesService;
|
|
|
|
public UXLevel(IUXService uxService, IGameMapService gameMapService, IEntitiesService entitiesService) : base(uxService)
|
|
{
|
|
_gameMapService = gameMapService;
|
|
_entitiesService = entitiesService;
|
|
}
|
|
|
|
public override async UniTask EntryAsync()
|
|
{
|
|
await base.EntryAsync();
|
|
|
|
_levelContainer.Clear();
|
|
|
|
foreach (var gameMapData in _entitiesService.QueryComponents<ScriptableGameMapData>())
|
|
{
|
|
var button = _levelContainer.Create<Button>();
|
|
|
|
if (gameMapData.Overview is Sprite sprite)
|
|
{
|
|
button.style.backgroundImage = new(sprite);
|
|
}else if (gameMapData.Overview is Texture2D texture2D)
|
|
{
|
|
button.style.backgroundImage = new(texture2D);
|
|
}
|
|
|
|
button.text = gameMapData.MapName;
|
|
button.clicked += () =>
|
|
{
|
|
_gameMapService.StartMapAsync(gameMapData.MapAddress).Forget();
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
protected override string DocumentPath => "ui_level";
|
|
public override bool IsWindow => true;
|
|
public override bool CloseWhenClickOutside => true;
|
|
[UXBindPath("level-container")]
|
|
private VisualElement _levelContainer;
|
|
private string _confirmMap;
|
|
}
|
|
|
|
}
|