+ ItemTable excel, json, so 수정 + 손님 추가 -> 빈 자리 찾기 -> 음료 주문 -> 퇴장 구현 + 일부 BehaviorTree Action 변경
182 lines
5.7 KiB
C#
182 lines
5.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BlueWater.Items;
|
|
using BlueWater.Maps;
|
|
using DG.Tweening;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
namespace BlueWater.Uis
|
|
{
|
|
public class CombatUiManager : Singleton<CombatUiManager>
|
|
{
|
|
[field: Title("UI")]
|
|
[field: SerializeField]
|
|
public Canvas MainCanvas { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public CombatSkillUi CombatSkillUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public FieldBossHealthPointUi FieldBossHealthPointUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public PlayerHealthPointUi PlayerHealthPointUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public ItemLootUi ItemLootUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public CombatItemInventoryUi CombatItemInventoryUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public GameOverPopupUi GameOverPopupUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public ClearPopupUi ClearPopupUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public MenuPopupUi CombatMenuPopupUi { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public CombatTutorialUi CombatTutorialUi { get; private set; }
|
|
|
|
[SerializeField]
|
|
private Image _fadeImage;
|
|
|
|
[Title("효과")]
|
|
[SerializeField]
|
|
private Vector2 _fadeInOutDuration = new(0.2f, 0.3f);
|
|
|
|
public List<PopupUi> PopupUiList { get; private set; }
|
|
|
|
protected override void OnAwake()
|
|
{
|
|
InitializeComponents();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
PopupUi.OnPopupUiOpenEvent += RegisterPopup;
|
|
PopupUi.OnPopupUiCloseEvent += UnregisterPopup;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
Invoke(nameof(StartTutorial), 0.1f);
|
|
}
|
|
|
|
private void StartTutorial()
|
|
{
|
|
CombatTutorialUi.ShowFirstTutorialUi();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
PopupUi.OnPopupUiOpenEvent -= RegisterPopup;
|
|
PopupUi.OnPopupUiCloseEvent -= UnregisterPopup;
|
|
}
|
|
|
|
[Button("셋팅 초기화")]
|
|
private void InitializeComponents()
|
|
{
|
|
MainCanvas = GetComponent<Canvas>();
|
|
CombatSkillUi = MainCanvas.transform.Find("CombatSkillUi").GetComponent<CombatSkillUi>();
|
|
FieldBossHealthPointUi = MainCanvas.transform.Find("FieldBossHealthPointUi").GetComponent<FieldBossHealthPointUi>();
|
|
PlayerHealthPointUi = MainCanvas.transform.Find("PlayerHealthPointUi").GetComponent<PlayerHealthPointUi>();
|
|
ItemLootUi = MainCanvas.transform.Find("ItemLootUi").GetComponent<ItemLootUi>();
|
|
CombatItemInventoryUi = MainCanvas.transform.Find("CombatItemInventoryUi").GetComponent<CombatItemInventoryUi>();
|
|
GameOverPopupUi = MainCanvas.transform.Find("GameOverPopupUi").GetComponent<GameOverPopupUi>();
|
|
ClearPopupUi = MainCanvas.transform.Find("ClearPopupUi").GetComponent<ClearPopupUi>();
|
|
CombatMenuPopupUi = MainCanvas.transform.Find("CombatMenuPopupUi").GetComponent<MenuPopupUi>();
|
|
CombatTutorialUi = MainCanvas.transform.Find("CombatTutorialUi").GetComponent<CombatTutorialUi>();
|
|
_fadeImage = MainCanvas.transform.Find("FadeImage").GetComponent<Image>();
|
|
|
|
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 void FadeInOut()
|
|
{
|
|
_fadeImage.enabled = true;
|
|
_fadeImage.color = new Color(1, 1, 1, 0);
|
|
_fadeImage.DOFade(1f, _fadeInOutDuration.x).OnComplete(() =>
|
|
{
|
|
_fadeImage.DOFade(0f, _fadeInOutDuration.y).OnComplete(() =>
|
|
{
|
|
_fadeImage.enabled = false;
|
|
});
|
|
});
|
|
}
|
|
|
|
public void RestartCurrentStage()
|
|
{
|
|
MapManager.Instance.InitializeMap();
|
|
CloseAllPopup();
|
|
}
|
|
|
|
public void MoveNextStage()
|
|
{
|
|
DataManager.Instance.CurrentSaveStage++;
|
|
RestartCurrentStage();
|
|
}
|
|
|
|
public void MoveSelectStage(int stage)
|
|
{
|
|
DataManager.Instance.CurrentSaveStage = (SaveStage)stage;
|
|
RestartCurrentStage();
|
|
}
|
|
|
|
public void MoveTitleScene()
|
|
{
|
|
PostProcessingManager.Instance.ToggleRendererFeature(RendererFeatureName.GrayscaleRenderPassFeature, false);
|
|
VisualFeedbackManager.Instance.SetBaseTimeScale(1f);
|
|
SceneManager.LoadScene("00.CombatTitle");
|
|
}
|
|
|
|
public void QuitGame()
|
|
{
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
#else
|
|
Application.Quit();
|
|
#endif
|
|
}
|
|
}
|
|
} |