73 lines
2.6 KiB
C#
73 lines
2.6 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()
|
||
|
{
|
||
|
if (!InteractionCanvas) return;
|
||
|
|
||
|
VisualLook.material = OutlineMaterial;
|
||
|
_cocktailGlassImage.material = OutlineMaterial;
|
||
|
}
|
||
|
|
||
|
public override void HideInteractionUi()
|
||
|
{
|
||
|
if (!InteractionCanvas) return;
|
||
|
|
||
|
VisualLook.material = OriginalMaterial;
|
||
|
_cocktailGlassImage.material = _originalCocktailGlassMaterial;
|
||
|
}
|
||
|
}
|
||
|
}
|