93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using DDD.Audios;
|
|
using DDD.ScriptableObjects;
|
|
using DDD.Utility;
|
|
using UnityEngine;
|
|
|
|
namespace DDD.Tycoons
|
|
{
|
|
public class ServingTableSeat : InteractionFurniture
|
|
{
|
|
[SerializeField]
|
|
private List<SpriteRenderer> _outlineRenderers = new();
|
|
|
|
[SerializeField]
|
|
private string _putDownSfxName = "PutDownCocktail";
|
|
|
|
public CraftRecipeData CurrentCraftRecipeData { get; private set; }
|
|
|
|
private List<Material> _originalMaterials;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
VisualLook.sprite = null;
|
|
VisualLook.enabled = false;
|
|
|
|
_originalMaterials = new List<Material>(_outlineRenderers.Count);
|
|
for (int i = 0; i < _outlineRenderers.Count; i++)
|
|
{
|
|
_originalMaterials.Add(_outlineRenderers[i].material);
|
|
}
|
|
}
|
|
|
|
public override void Interaction()
|
|
{
|
|
// 테이블의 칵테일을 가져가는 경우
|
|
if (CurrentCraftRecipeData != null)
|
|
{
|
|
CurrentTycoonPlayer.PickupCook(CurrentCraftRecipeData);
|
|
VisualLook.sprite = null;
|
|
VisualLook.enabled = false;
|
|
CurrentCraftRecipeData = null;
|
|
}
|
|
// 테이블에 칵테일을 놓는 경우
|
|
else
|
|
{
|
|
AudioManager.Instance.PlaySfx(_putDownSfxName);
|
|
CurrentCraftRecipeData = CurrentTycoonPlayer.TycoonPickupHandler.CurrentCraftRecipeData;
|
|
VisualLook.sprite = CurrentCraftRecipeData.Sprite;
|
|
VisualLook.enabled = true;
|
|
CurrentTycoonPlayer.ServedCook();
|
|
}
|
|
}
|
|
|
|
public override bool CanInteraction()
|
|
{
|
|
// 1. 테이블에 음식이 있고, 플레이어가 음식을 들고 있지 않은 경우
|
|
// 2. 테이블에 음식이 없고, 플레이어가 음식을 들고 있는 경우
|
|
return (CurrentCraftRecipeData != null && !CurrentTycoonPlayer.TycoonPickupHandler.IsPickedUpCook) ||
|
|
(CurrentCraftRecipeData == null && CurrentTycoonPlayer.TycoonPickupHandler.IsPickedUpCook);
|
|
}
|
|
|
|
public override void ShowInteractionUi()
|
|
{
|
|
if (CurrentCraftRecipeData != null)
|
|
{
|
|
InteractionMessage = Utils.GetLocalizedString("InteractionServingTablePickUp");
|
|
}
|
|
else
|
|
{
|
|
InteractionMessage = Utils.GetLocalizedString("InteractionServingTablePutDown");
|
|
}
|
|
|
|
base.ShowInteractionUi();
|
|
|
|
for (int i = 0; i < _outlineRenderers.Count; i++)
|
|
{
|
|
_outlineRenderers[i].material = OutlineMaterial;
|
|
}
|
|
}
|
|
|
|
public override void HideInteractionUi()
|
|
{
|
|
base.HideInteractionUi();
|
|
|
|
for (int i = 0; i < _outlineRenderers.Count; i++)
|
|
{
|
|
_outlineRenderers[i].material = _originalMaterials[i];
|
|
}
|
|
}
|
|
}
|
|
} |