86 lines
2.8 KiB
C#
86 lines
2.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Policy;
|
|
using BITFALL.Game;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using BITKit;
|
|
using BITKit.Game;
|
|
using BITKit.SceneManagement;
|
|
using BITKit.UX;
|
|
using INetClient = BITKit.INetClient;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace BITFALL.UX
|
|
{
|
|
public class UXMenu : UIToolKitPanel
|
|
{
|
|
[Header(Constant.Header.Services)]
|
|
[SerializeReference, SubclassSelector] private IReference[] mapTags;
|
|
|
|
[Header(Constant.Header.Providers)]
|
|
[SerializeReference, SubclassSelector] private ISceneService SceneService;
|
|
|
|
[Header(Constant.Header.Components)]
|
|
[SerializeField] private UXButton playButton;
|
|
[SerializeField] private UXButton stopButton;
|
|
[SerializeField] private UXButton exitButton;
|
|
[SerializeField] private UXButton returnButton;
|
|
[SerializeField] private UXImage backgroundImage;
|
|
[SerializeField] private UXDropdown mapDropdown;
|
|
|
|
[Header(Constant.Header.Providers)]
|
|
[SerializeReference,SubclassSelector] private IGameService gameService;
|
|
|
|
[Header(Constant.Header.Input)]
|
|
[SerializeField] private InputActionReference returnAction;
|
|
[SerializeField] private InputActionReference inventoryAction;
|
|
|
|
protected override void Start()
|
|
{
|
|
inputActionGroup.RegisterCallback(returnAction, OnReturn);
|
|
inputActionGroup.RegisterCallback(inventoryAction, OnReturn);
|
|
|
|
SceneService.OnLoadScene +=(_)=> OnConnected();
|
|
SceneService.OnUnloadScene +=(_)=>
|
|
{
|
|
Entry();
|
|
OnDisconnected();
|
|
};
|
|
OnDisconnected();
|
|
|
|
var tags = mapTags.Select(x => x.Value).ToArray();
|
|
mapDropdown.visualElement.choices = SceneService.GetScenes(tags).ToList();
|
|
mapDropdown.visualElement.RegisterValueChangedCallback(x =>
|
|
{
|
|
gameService.ExpectMap = x.newValue;
|
|
});
|
|
}
|
|
private void OnConnected()
|
|
{
|
|
backgroundImage.SetActive(false);
|
|
playButton.SetActive(false);
|
|
stopButton.SetActive(true);
|
|
exitButton.SetActive(false);
|
|
returnButton.SetActive(true);
|
|
}
|
|
private void OnDisconnected()
|
|
{
|
|
backgroundImage.SetActive(true);
|
|
playButton.SetActive(true);
|
|
stopButton.SetActive(false);
|
|
exitButton.SetActive(true);
|
|
returnButton.SetActive(false);
|
|
}
|
|
private void OnReturn(InputAction.CallbackContext context)
|
|
{
|
|
if (context.ReadValueAsButton())
|
|
{
|
|
UXService.Entry<UXHud>();
|
|
}
|
|
}
|
|
}
|
|
} |