2024-05-11 21:29:16 +00:00
|
|
|
using System.Collections.Generic;
|
2023-12-13 07:14:31 +00:00
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
namespace BlueWaterProject
|
|
|
|
{
|
2024-05-11 21:29:16 +00:00
|
|
|
public class OceanUiManager : Singleton<OceanUiManager>
|
2023-12-13 07:14:31 +00:00
|
|
|
{
|
2023-12-17 19:50:44 +00:00
|
|
|
[field: Title("UI")]
|
2023-12-13 07:14:31 +00:00
|
|
|
[field: SerializeField] public ProcessBar ProcessBar { get; set; }
|
2023-12-17 19:50:44 +00:00
|
|
|
[SerializeField] private Vector3 processBarOffset = Vector3.zero;
|
|
|
|
|
2023-12-19 12:46:06 +00:00
|
|
|
[field: SerializeField] public Slider ShipBoostSlider { get; set; }
|
|
|
|
|
2024-01-14 17:24:48 +00:00
|
|
|
[field: SerializeField] public GameObject SpeedLines { get; set; }
|
2024-01-21 17:42:31 +00:00
|
|
|
|
|
|
|
[field: SerializeField] public DropItemGroupController DropItemGroupController { get; set; }
|
2024-03-25 04:24:33 +00:00
|
|
|
[field: SerializeField] public WeatherUi WeatherUi { get; private set; }
|
2024-05-12 10:47:18 +00:00
|
|
|
[field: SerializeField] public OceanItemInventoryUi OceanItemInventoryUi { get; set; }
|
2024-03-17 19:21:42 +00:00
|
|
|
|
2024-01-21 17:42:31 +00:00
|
|
|
public Canvas MainCanvas { get; private set; }
|
2023-12-13 07:14:31 +00:00
|
|
|
|
2024-02-04 15:33:41 +00:00
|
|
|
public Transform InstantiateUi { get; private set; }
|
|
|
|
|
|
|
|
public Transform ItemsLoot { get; private set; }
|
|
|
|
|
2024-05-11 21:29:16 +00:00
|
|
|
[SerializeField] private List<PopupUi> popupUiList = new();
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnAwake()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
|
|
|
|
ProcessBar.SetActive(false);
|
|
|
|
}
|
2024-05-12 10:47:18 +00:00
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
PopupUi.OnPopupUiOpenEvent += RegisterPopup;
|
|
|
|
PopupUi.OnPopupUiCloseEvent += UnregisterPopup;
|
|
|
|
}
|
2024-05-11 21:29:16 +00:00
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
if (ProcessBar.Obj.activeSelf)
|
|
|
|
{
|
|
|
|
var mousePos = Input.mousePosition;
|
|
|
|
var result = mousePos + processBarOffset;
|
|
|
|
ProcessBar.SetPosition(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-12 10:47:18 +00:00
|
|
|
private void OnDisable()
|
|
|
|
{
|
|
|
|
PopupUi.OnPopupUiOpenEvent -= RegisterPopup;
|
|
|
|
PopupUi.OnPopupUiCloseEvent -= UnregisterPopup;
|
|
|
|
}
|
|
|
|
|
2023-12-18 07:00:06 +00:00
|
|
|
[Button("셋팅 초기화")]
|
|
|
|
private void Init()
|
|
|
|
{
|
2024-01-21 17:42:31 +00:00
|
|
|
MainCanvas = GetComponent<Canvas>();
|
|
|
|
if (!MainCanvas)
|
2023-12-18 07:00:06 +00:00
|
|
|
{
|
|
|
|
Debug.LogError("canvas is null error");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-21 17:42:31 +00:00
|
|
|
var processBar = MainCanvas.transform.Find("ProcessBar").gameObject;
|
2023-12-18 07:00:06 +00:00
|
|
|
var fill = processBar.transform.Find("Fill").GetComponent<Image>();
|
|
|
|
var previousGaugeLine = processBar.transform.Find("PreviousGaugeLine").transform;
|
2024-01-21 17:42:31 +00:00
|
|
|
var reloadSlider = MainCanvas.transform.Find("ReloadSlider").GetComponent<Slider>();
|
2023-12-18 07:00:06 +00:00
|
|
|
ProcessBar = new ProcessBar(processBar, fill, previousGaugeLine, reloadSlider);
|
|
|
|
ProcessBar.SetActiveReloadSlider(false);
|
2023-12-19 12:46:06 +00:00
|
|
|
|
2024-01-21 17:42:31 +00:00
|
|
|
ShipBoostSlider = MainCanvas.transform.Find("ShipBoostSlider").GetComponent<Slider>();
|
2023-12-19 12:46:06 +00:00
|
|
|
ShipBoostSlider.value = 0f;
|
2024-01-14 17:24:48 +00:00
|
|
|
|
2024-01-21 17:42:31 +00:00
|
|
|
SpeedLines = MainCanvas.transform.Find("SpeedLines").gameObject;
|
2024-01-14 17:24:48 +00:00
|
|
|
SpeedLines.SetActive(false);
|
2024-01-18 07:21:07 +00:00
|
|
|
|
2024-01-21 17:42:31 +00:00
|
|
|
DropItemGroupController = MainCanvas.transform.Find("DropItemGroup").GetComponent<DropItemGroupController>();
|
2024-03-25 04:24:33 +00:00
|
|
|
WeatherUi = MainCanvas.transform.Find("WeatherUi").GetComponent<WeatherUi>();
|
2024-05-12 10:47:18 +00:00
|
|
|
OceanItemInventoryUi = MainCanvas.transform.Find("OceanItemInventoryUi").GetComponent<OceanItemInventoryUi>();
|
2024-02-04 15:33:41 +00:00
|
|
|
|
|
|
|
InstantiateUi = MainCanvas.transform.Find("InstantiateUi");
|
|
|
|
if (!InstantiateUi)
|
|
|
|
{
|
|
|
|
InstantiateUi = new GameObject("InstantiateUi").transform;
|
|
|
|
InstantiateUi.parent = MainCanvas.transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemsLoot = InstantiateUi.transform.Find("ItemsLoot");
|
|
|
|
if (!ItemsLoot)
|
|
|
|
{
|
|
|
|
ItemsLoot = new GameObject("ItemsLoot").transform;
|
|
|
|
ItemsLoot.parent = InstantiateUi.transform;
|
|
|
|
}
|
2024-05-11 21:29:16 +00:00
|
|
|
|
|
|
|
popupUiList = new List<PopupUi>(8);
|
2023-12-18 07:00:06 +00:00
|
|
|
}
|
|
|
|
|
2024-05-11 21:29:16 +00:00
|
|
|
private void RegisterPopup(PopupUi popup)
|
2023-12-13 07:14:31 +00:00
|
|
|
{
|
2024-05-11 21:29:16 +00:00
|
|
|
if (!popupUiList.Contains(popup))
|
2023-12-17 19:50:44 +00:00
|
|
|
{
|
2024-05-11 21:29:16 +00:00
|
|
|
popupUiList.Add(popup);
|
2023-12-17 19:50:44 +00:00
|
|
|
}
|
2023-12-13 07:14:31 +00:00
|
|
|
}
|
2023-12-14 17:45:54 +00:00
|
|
|
|
2024-05-11 21:29:16 +00:00
|
|
|
private void UnregisterPopup(PopupUi popup)
|
2023-12-14 17:45:54 +00:00
|
|
|
{
|
2024-05-11 21:29:16 +00:00
|
|
|
if (popupUiList.Contains(popup))
|
2023-12-14 17:45:54 +00:00
|
|
|
{
|
2024-05-11 21:29:16 +00:00
|
|
|
popupUiList.Remove(popup);
|
2023-12-14 17:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-18 07:21:07 +00:00
|
|
|
|
2024-05-12 10:47:18 +00:00
|
|
|
public void CloseLastPopup()
|
2024-05-11 21:29:16 +00:00
|
|
|
{
|
|
|
|
if (popupUiList.Count <= 0) return;
|
2024-05-12 10:47:18 +00:00
|
|
|
|
|
|
|
popupUiList[^1].Close();
|
|
|
|
}
|
2024-05-11 21:29:16 +00:00
|
|
|
|
2024-05-12 10:47:18 +00:00
|
|
|
public void CloseAllPopup()
|
|
|
|
{
|
|
|
|
var tempList = new List<PopupUi>(popupUiList);
|
|
|
|
|
|
|
|
foreach (var popup in tempList)
|
|
|
|
{
|
|
|
|
popup.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
popupUiList.Clear();
|
2024-05-11 21:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsPopupListEmpty() => popupUiList.Count == 0;
|
|
|
|
|
2024-01-14 17:24:48 +00:00
|
|
|
public void SetActiveSpeedLine(bool value) => SpeedLines.SetActive(value);
|
2023-12-13 07:14:31 +00:00
|
|
|
}
|
|
|
|
}
|