수정 내역 1. 아이템 인벤토리 씬별로 스크립트 구분 2. 전투씬에 GameOver, Clear, Menu Ui 추가 버그 수정 내역 1. 팝업UI 간의 충돌 버그 수정
144 lines
4.8 KiB
C#
144 lines
4.8 KiB
C#
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class OceanUiManager : Singleton<OceanUiManager>
|
|
{
|
|
[field: Title("UI")]
|
|
[field: SerializeField] public ProcessBar ProcessBar { get; set; }
|
|
[SerializeField] private Vector3 processBarOffset = Vector3.zero;
|
|
|
|
[field: SerializeField] public Slider ShipBoostSlider { get; set; }
|
|
|
|
[field: SerializeField] public GameObject SpeedLines { get; set; }
|
|
|
|
[field: SerializeField] public DropItemGroupController DropItemGroupController { get; set; }
|
|
[field: SerializeField] public WeatherUi WeatherUi { get; private set; }
|
|
[field: SerializeField] public OceanItemInventoryUi OceanItemInventoryUi { get; set; }
|
|
|
|
public Canvas MainCanvas { get; private set; }
|
|
|
|
public Transform InstantiateUi { get; private set; }
|
|
|
|
public Transform ItemsLoot { get; private set; }
|
|
|
|
[SerializeField] private List<PopupUi> popupUiList = new();
|
|
|
|
|
|
protected override void OnAwake()
|
|
{
|
|
Init();
|
|
|
|
ProcessBar.SetActive(false);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
PopupUi.OnPopupUiOpenEvent += RegisterPopup;
|
|
PopupUi.OnPopupUiCloseEvent += UnregisterPopup;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (ProcessBar.Obj.activeSelf)
|
|
{
|
|
var mousePos = Input.mousePosition;
|
|
var result = mousePos + processBarOffset;
|
|
ProcessBar.SetPosition(result);
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
PopupUi.OnPopupUiOpenEvent -= RegisterPopup;
|
|
PopupUi.OnPopupUiCloseEvent -= UnregisterPopup;
|
|
}
|
|
|
|
[Button("셋팅 초기화")]
|
|
private void Init()
|
|
{
|
|
MainCanvas = GetComponent<Canvas>();
|
|
if (!MainCanvas)
|
|
{
|
|
Debug.LogError("canvas is null error");
|
|
return;
|
|
}
|
|
|
|
var processBar = MainCanvas.transform.Find("ProcessBar").gameObject;
|
|
var fill = processBar.transform.Find("Fill").GetComponent<Image>();
|
|
var previousGaugeLine = processBar.transform.Find("PreviousGaugeLine").transform;
|
|
var reloadSlider = MainCanvas.transform.Find("ReloadSlider").GetComponent<Slider>();
|
|
ProcessBar = new ProcessBar(processBar, fill, previousGaugeLine, reloadSlider);
|
|
ProcessBar.SetActiveReloadSlider(false);
|
|
|
|
ShipBoostSlider = MainCanvas.transform.Find("ShipBoostSlider").GetComponent<Slider>();
|
|
ShipBoostSlider.value = 0f;
|
|
|
|
SpeedLines = MainCanvas.transform.Find("SpeedLines").gameObject;
|
|
SpeedLines.SetActive(false);
|
|
|
|
DropItemGroupController = MainCanvas.transform.Find("DropItemGroup").GetComponent<DropItemGroupController>();
|
|
WeatherUi = MainCanvas.transform.Find("WeatherUi").GetComponent<WeatherUi>();
|
|
OceanItemInventoryUi = MainCanvas.transform.Find("OceanItemInventoryUi").GetComponent<OceanItemInventoryUi>();
|
|
|
|
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;
|
|
}
|
|
|
|
popupUiList = new List<PopupUi>(8);
|
|
}
|
|
|
|
private void RegisterPopup(PopupUi popup)
|
|
{
|
|
if (!popupUiList.Contains(popup))
|
|
{
|
|
popupUiList.Add(popup);
|
|
}
|
|
}
|
|
|
|
private void UnregisterPopup(PopupUi popup)
|
|
{
|
|
if (popupUiList.Contains(popup))
|
|
{
|
|
popupUiList.Remove(popup);
|
|
}
|
|
}
|
|
|
|
public void CloseLastPopup()
|
|
{
|
|
if (popupUiList.Count <= 0) return;
|
|
|
|
popupUiList[^1].Close();
|
|
}
|
|
|
|
public void CloseAllPopup()
|
|
{
|
|
var tempList = new List<PopupUi>(popupUiList);
|
|
|
|
foreach (var popup in tempList)
|
|
{
|
|
popup.Close();
|
|
}
|
|
|
|
popupUiList.Clear();
|
|
}
|
|
|
|
public bool IsPopupListEmpty() => popupUiList.Count == 0;
|
|
|
|
public void SetActiveSpeedLine(bool value) => SpeedLines.SetActive(value);
|
|
}
|
|
} |