2024-09-10 10:25:05 +00:00
|
|
|
using BlueWater.Interfaces;
|
2024-06-18 18:16:19 +00:00
|
|
|
using BlueWater.Items;
|
2024-07-02 18:27:56 +00:00
|
|
|
using BlueWater.Tycoons;
|
2024-06-18 18:16:19 +00:00
|
|
|
using DG.Tweening;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
2024-07-02 18:27:56 +00:00
|
|
|
namespace BlueWater.Uis
|
2024-06-18 18:16:19 +00:00
|
|
|
{
|
2024-09-10 10:25:05 +00:00
|
|
|
public class BalloonUi : MonoBehaviour
|
2024-06-18 18:16:19 +00:00
|
|
|
{
|
2024-09-10 10:25:05 +00:00
|
|
|
[Title("컴포넌트")]
|
|
|
|
[SerializeField, Required]
|
|
|
|
private Image _fillImage;
|
2024-06-18 18:16:19 +00:00
|
|
|
|
2024-09-10 10:25:05 +00:00
|
|
|
[SerializeField, Required]
|
|
|
|
private Image _itemImage;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private GameObject _panel;
|
2024-06-18 18:16:19 +00:00
|
|
|
|
|
|
|
[Title("주문 정보")]
|
|
|
|
[SerializeField, DisableIf("@true")]
|
|
|
|
private bool _isOrdered;
|
|
|
|
|
|
|
|
[SerializeField, DisableIf("@true")]
|
|
|
|
private bool _isWaitTimeOver;
|
|
|
|
|
|
|
|
[SerializeField, DisableIf("@true")]
|
2024-09-10 10:25:05 +00:00
|
|
|
private bool _isItemReceived;
|
2024-06-18 18:16:19 +00:00
|
|
|
|
|
|
|
private Tween _tween;
|
|
|
|
private TableSeat _tableSeat;
|
2024-09-30 12:05:19 +00:00
|
|
|
private CocktailData _orderCocktailData;
|
2024-09-23 02:00:21 +00:00
|
|
|
private bool _isUnfinishedCocktailPickedUp;
|
2024-06-18 18:16:19 +00:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
InitializeComponents();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
_tween.Kill();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
|
|
private void InitializeComponents()
|
|
|
|
{
|
2024-09-10 10:25:05 +00:00
|
|
|
_fillImage = transform.Find("Panel/FillImage").GetComponent<Image>();
|
|
|
|
_itemImage = transform.Find("Panel/FoodImage").GetComponent<Image>();
|
|
|
|
_panel = transform.Find("Panel").gameObject;
|
2024-06-18 18:16:19 +00:00
|
|
|
}
|
|
|
|
|
2024-07-02 18:27:56 +00:00
|
|
|
public void Initialize(TableSeat tableSeat)
|
2024-06-18 18:16:19 +00:00
|
|
|
{
|
|
|
|
_tableSeat = tableSeat;
|
|
|
|
HideUi();
|
|
|
|
}
|
|
|
|
|
2024-09-10 10:25:05 +00:00
|
|
|
public void ShowUi() => _panel.SetActive(true);
|
|
|
|
public void HideUi() => _panel.SetActive(false);
|
2024-06-18 18:16:19 +00:00
|
|
|
|
2024-09-23 02:00:21 +00:00
|
|
|
public void PickupUnfinishedCocktail()
|
|
|
|
{
|
|
|
|
_isUnfinishedCocktailPickedUp = true;
|
|
|
|
}
|
|
|
|
|
2024-09-10 10:25:05 +00:00
|
|
|
public void SetItemImage(IPickup item)
|
2024-06-18 18:16:19 +00:00
|
|
|
{
|
2024-09-10 10:25:05 +00:00
|
|
|
//_orderItemData = ItemManager.Instance.GetItemDataByIdx(foodIdx);
|
|
|
|
// if (_orderItemData == null)
|
|
|
|
// {
|
|
|
|
// Debug.LogError($"{foodIdx} 해당 음식을 등록할 수 없습니다.");
|
|
|
|
// return;
|
|
|
|
// }
|
2024-06-18 18:16:19 +00:00
|
|
|
|
2024-09-10 10:25:05 +00:00
|
|
|
if (!item.Sprite)
|
2024-06-18 18:16:19 +00:00
|
|
|
{
|
2024-09-10 10:25:05 +00:00
|
|
|
Debug.LogWarning($"{item.Sprite} 해당 음식의 이미지가 없습니다.");
|
2024-06-18 18:16:19 +00:00
|
|
|
}
|
2024-09-10 10:25:05 +00:00
|
|
|
|
2024-09-23 02:00:21 +00:00
|
|
|
_isUnfinishedCocktailPickedUp = false;
|
2024-09-10 10:25:05 +00:00
|
|
|
SetItemSprite(item.Sprite);
|
|
|
|
ShowUi();
|
2024-06-18 18:16:19 +00:00
|
|
|
}
|
2024-09-23 02:00:21 +00:00
|
|
|
|
2024-10-14 11:13:08 +00:00
|
|
|
public void ResetUi()
|
|
|
|
{
|
|
|
|
_isOrdered = false;
|
|
|
|
_isWaitTimeOver = false;
|
|
|
|
_isItemReceived = false;
|
|
|
|
}
|
|
|
|
|
2024-09-23 02:00:21 +00:00
|
|
|
public void SetEmpty()
|
|
|
|
{
|
|
|
|
SetItemSprite(null);
|
|
|
|
}
|
2024-07-20 11:32:54 +00:00
|
|
|
|
2024-09-10 10:25:05 +00:00
|
|
|
public void SetItemSprite(Sprite sprite)
|
|
|
|
{
|
|
|
|
_itemImage.sprite = sprite;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DiscardItem()
|
2024-07-20 11:32:54 +00:00
|
|
|
{
|
2024-09-23 02:00:21 +00:00
|
|
|
_isUnfinishedCocktailPickedUp = false;
|
2024-09-10 10:25:05 +00:00
|
|
|
HideUi();
|
2024-09-23 02:00:21 +00:00
|
|
|
SetEmpty();
|
2024-07-20 11:32:54 +00:00
|
|
|
}
|
2024-10-06 23:41:09 +00:00
|
|
|
|
|
|
|
public void GiveItem(IPickup item)
|
|
|
|
{
|
|
|
|
_isUnfinishedCocktailPickedUp = false;
|
|
|
|
HideUi();
|
|
|
|
SetEmpty();
|
|
|
|
}
|
2024-06-18 18:16:19 +00:00
|
|
|
|
2024-09-10 10:25:05 +00:00
|
|
|
public void OrderItem(string itemIdx, int waitTime, int hurryTime)
|
2024-06-18 18:16:19 +00:00
|
|
|
{
|
2024-09-30 12:05:19 +00:00
|
|
|
_orderCocktailData = ItemManager.Instance.CocktailDataSo.GetDataByIdx(itemIdx);
|
2024-06-18 18:16:19 +00:00
|
|
|
_isOrdered = true;
|
|
|
|
_isWaitTimeOver = false;
|
2024-09-10 10:25:05 +00:00
|
|
|
_isItemReceived = false;
|
2024-09-30 12:05:19 +00:00
|
|
|
SetItemImage(_orderCocktailData);
|
2024-10-06 23:41:09 +00:00
|
|
|
|
2024-10-15 18:01:16 +00:00
|
|
|
SetTween(waitTime, hurryTime);
|
2024-10-06 23:41:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OrderItem(Sprite sprite, int waitTime, int hurryTime)
|
|
|
|
{
|
|
|
|
_isOrdered = true;
|
|
|
|
_isWaitTimeOver = false;
|
|
|
|
_isItemReceived = false;
|
|
|
|
SetItemSprite(sprite);
|
2024-06-18 18:16:19 +00:00
|
|
|
ShowUi();
|
2024-10-15 18:01:16 +00:00
|
|
|
|
|
|
|
SetTween(waitTime, hurryTime);
|
|
|
|
}
|
2024-06-18 18:16:19 +00:00
|
|
|
|
2024-10-15 18:01:16 +00:00
|
|
|
public void SetTween(int waitTime, int hurryTime)
|
|
|
|
{
|
|
|
|
_tween?.Kill();
|
2024-09-10 10:25:05 +00:00
|
|
|
_tween = _fillImage.DOFillAmount(1f, hurryTime)
|
2024-07-20 11:32:54 +00:00
|
|
|
.From(0f)
|
|
|
|
.SetEase(Ease.Linear)
|
|
|
|
.SetDelay(waitTime)
|
|
|
|
.OnComplete(OnTweenComplete)
|
|
|
|
.SetAutoKill(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PayMoney(int waitTime, int hurryTime)
|
|
|
|
{
|
|
|
|
_isOrdered = true;
|
|
|
|
_isWaitTimeOver = false;
|
2024-09-10 10:25:05 +00:00
|
|
|
_isItemReceived = false;
|
|
|
|
SetItemSprite(DataManager.Instance.SpriteDataSo.Gold);
|
2024-07-20 11:32:54 +00:00
|
|
|
ShowUi();
|
|
|
|
|
2024-09-10 10:25:05 +00:00
|
|
|
_tween = _fillImage.DOFillAmount(1f, hurryTime)
|
2024-07-20 11:32:54 +00:00
|
|
|
.From(0f)
|
2024-06-18 18:16:19 +00:00
|
|
|
.SetEase(Ease.Linear)
|
2024-07-06 12:13:58 +00:00
|
|
|
.SetDelay(waitTime)
|
2024-06-18 18:16:19 +00:00
|
|
|
.OnComplete(OnTweenComplete)
|
|
|
|
.SetAutoKill(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTweenComplete()
|
|
|
|
{
|
|
|
|
_isWaitTimeOver = true;
|
|
|
|
HideUi();
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsWaitTimeOver() => _isOrdered && _isWaitTimeOver;
|
2024-09-10 10:25:05 +00:00
|
|
|
public bool IsFoodReceive() => _isItemReceived;
|
2024-06-18 18:16:19 +00:00
|
|
|
|
2024-10-06 23:41:09 +00:00
|
|
|
public void ReceiveItem(IPickup pickupItem)
|
2024-07-02 18:27:56 +00:00
|
|
|
{
|
|
|
|
_tween.Kill();
|
|
|
|
HideUi();
|
2024-09-10 10:25:05 +00:00
|
|
|
_isItemReceived = true;
|
2024-07-02 18:27:56 +00:00
|
|
|
}
|
2024-06-18 18:16:19 +00:00
|
|
|
}
|
|
|
|
}
|