73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
using BlueWater.Interfaces;
|
|
using BlueWater.Uis;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Tycoons
|
|
{
|
|
public class ServingTable : InteractionFurniture
|
|
{
|
|
[SerializeField]
|
|
private SpriteRenderer _cocktailGlassImage;
|
|
|
|
[SerializeField]
|
|
private BalloonUi _balloonUi;
|
|
|
|
// 서빙 테이블 기준 아이템이 있는지 없는지
|
|
private IPickup _currentPickupItem;
|
|
private Material _originalCocktailGlassMaterial;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
_originalCocktailGlassMaterial = _cocktailGlassImage.material;
|
|
}
|
|
|
|
public override void Interaction()
|
|
{
|
|
// 테이블의 칵테일을 가져가는 경우
|
|
if (_currentPickupItem != null)
|
|
{
|
|
EventManager.OnTakeFromServingTable?.Invoke();
|
|
CurrentTycoonPlayer.TycoonPickupHandler.PickupItem(_currentPickupItem);
|
|
CurrentTycoonPlayer.BalloonUi.SetItemImage(_currentPickupItem);
|
|
_cocktailGlassImage.enabled = false;
|
|
_balloonUi.DiscardItem();
|
|
_currentPickupItem = null;
|
|
}
|
|
// 테이블에 칵테일을 놓는 경우
|
|
else
|
|
{
|
|
EventManager.OnPlaceOnServingTable?.Invoke();
|
|
_currentPickupItem = CurrentTycoonPlayer.TycoonPickupHandler.GetCurrentPickupItem();
|
|
CurrentTycoonPlayer.TycoonPickupHandler.GiveItem();
|
|
CurrentTycoonPlayer.BalloonUi.DiscardItem();
|
|
_balloonUi.SetItemImage(_currentPickupItem);
|
|
_cocktailGlassImage.enabled = true;
|
|
}
|
|
}
|
|
|
|
public override bool CanInteraction()
|
|
{
|
|
// 1. 테이블에 칵테일이 있고, 플레이어가 칵테일을 들고 있지 않은 경우
|
|
// 2. 테이블에 칵테일이 없고, 플레이어가 칵테일을 들고 있는 경우 (정상적인 칵테일만)
|
|
return (_currentPickupItem != null && !CurrentTycoonPlayer.TycoonPickupHandler.IsPickedUpCocktail())||
|
|
(_currentPickupItem == null && CurrentTycoonPlayer.TycoonPickupHandler.IsServablePickupItem());
|
|
}
|
|
|
|
public override void ShowInteractionUi()
|
|
{
|
|
InteractionMessage = _currentPickupItem != null ? "음료 들기" : "음료 내려놓기";
|
|
base.ShowInteractionUi();
|
|
|
|
_cocktailGlassImage.material = OutlineMaterial;
|
|
}
|
|
|
|
public override void HideInteractionUi()
|
|
{
|
|
base.HideInteractionUi();
|
|
|
|
_cocktailGlassImage.material = _originalCocktailGlassMaterial;
|
|
}
|
|
}
|
|
} |