2025-10-03 00:31:34 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Data;
|
|
|
|
|
using Managers;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace UI
|
|
|
|
|
{
|
2025-10-10 14:08:23 +08:00
|
|
|
public class StartPlayUI : FullScreenUI
|
2025-10-03 00:31:34 +08:00
|
|
|
{
|
|
|
|
|
public Transform iconList;
|
|
|
|
|
|
2025-10-10 14:08:23 +08:00
|
|
|
public MapViewUI mapViewUIPrefab;
|
|
|
|
|
public List<MapViewUI> mapViewUIList = new();
|
|
|
|
|
|
2025-10-03 00:31:34 +08:00
|
|
|
private int _currentIndex;
|
|
|
|
|
|
|
|
|
|
public int CurrentDimensionIndex
|
|
|
|
|
{
|
|
|
|
|
get => _currentIndex;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_currentIndex = value;
|
|
|
|
|
if (_currentIndex < 0)
|
|
|
|
|
_currentIndex += mapViewUIList.Count;
|
2025-10-10 14:08:23 +08:00
|
|
|
else if (_currentIndex >= mapViewUIList.Count) _currentIndex %= mapViewUIList.Count;
|
2025-10-03 00:31:34 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DimensionDef CurrentDimension => mapViewUIList[CurrentDimensionIndex].DimensionDefine;
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
var dimensionDefs = DefineManager.Instance.QueryDefinesByType<DimensionDef>();
|
2025-10-10 14:08:23 +08:00
|
|
|
if (dimensionDefs == null)
|
2025-10-03 00:31:34 +08:00
|
|
|
return;
|
|
|
|
|
foreach (var d in dimensionDefs)
|
|
|
|
|
{
|
2025-10-10 14:08:23 +08:00
|
|
|
if (!d.canSelect)
|
2025-10-03 00:31:34 +08:00
|
|
|
continue;
|
2025-10-10 14:08:23 +08:00
|
|
|
var newObj = Instantiate(mapViewUIPrefab, iconList);
|
2025-10-03 00:31:34 +08:00
|
|
|
mapViewUIList.Add(newObj);
|
|
|
|
|
newObj.Init(d);
|
|
|
|
|
newObj.gameObject.SetActive(false);
|
|
|
|
|
newObj.transform.localPosition = Vector3.zero;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateUI()
|
|
|
|
|
{
|
|
|
|
|
if (mapViewUIList == null)
|
|
|
|
|
return;
|
|
|
|
|
for (var i = 0; i < mapViewUIList.Count; i++)
|
|
|
|
|
mapViewUIList[i].gameObject.SetActive(i == CurrentDimensionIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnStartGame()
|
|
|
|
|
{
|
|
|
|
|
Program.Instance.StartPlayGame(CurrentDimension);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnLeft()
|
|
|
|
|
{
|
2025-10-10 14:08:23 +08:00
|
|
|
CurrentDimensionIndex -= 1;
|
2025-10-03 00:31:34 +08:00
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnRight()
|
|
|
|
|
{
|
2025-10-10 14:08:23 +08:00
|
|
|
CurrentDimensionIndex += 1;
|
2025-10-03 00:31:34 +08:00
|
|
|
UpdateUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|