+ 화면 밖에서 손님이 요구하는 중일 때, Indicator를 통해서 Ui 표시 + Open, Closed Ui 추가 및 기능 연결 + 테이블 찾는 로직 변경 (전부 랜덤) - 기존에는 항상 같은 순서로 자리를 채움 + 통계용 데이터 CustomerVisitInfo 추가 (추후에 통계Ui 생길 때 연결) + 대화 조건 변경 + 일부 가구들 상호작용 조건 변경 + Outline shader Render Face(Front -> Both 변경 - Front면 x축 뒤집는 경우 안나옴) + GraphicMaterialOverride를 사용하는 경우, 에디터에서 전체화면 등 특정 상황에서 material이 사라지는 버그 수정 + InteractionFuniture Open, Closed 공통 기능으로 병합
87 lines
2.5 KiB
C#
87 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using Random = System.Random;
|
|
|
|
namespace BlueWater.Tycoons
|
|
{
|
|
public class CustomerTable : InteractionFurniture
|
|
{
|
|
[SerializeField]
|
|
private List<TableSeat> _tableSeats;
|
|
|
|
private TycoonManager _tycoonManager;
|
|
private TableSeat _tableSeat;
|
|
private Random _random = new();
|
|
private bool _isCleaning;
|
|
|
|
protected override void OnEnable()
|
|
{
|
|
base.OnEnable();
|
|
|
|
_tycoonManager = TycoonManager.Instance;
|
|
_tycoonManager.CustomerTableController.RegisterTable(this);
|
|
}
|
|
|
|
protected override void OnDisable()
|
|
{
|
|
base.OnDisable();
|
|
|
|
_tycoonManager.CustomerTableController.UnregisterTable(this);
|
|
}
|
|
|
|
public override void Interaction()
|
|
{
|
|
StartCoroutine(CleanUpTable(_tableSeat));
|
|
}
|
|
|
|
public override bool CanInteraction()
|
|
{
|
|
if (_isCleaning) return false;
|
|
|
|
_tableSeat = _tableSeats.Find(table => !table.IsOccupied && !table.IsCleaned);
|
|
if (_tableSeat == null) return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public TableSeat FindEmptySeat()
|
|
{
|
|
var seatCount = _tableSeats.Count;
|
|
var indices = new List<int>(Enumerable.Range(0, seatCount));
|
|
|
|
while (indices.Count > 0)
|
|
{
|
|
var randomIndex = _random.Next(indices.Count);
|
|
var seatIndex = indices[randomIndex];
|
|
indices.RemoveAt(randomIndex);
|
|
|
|
var tableSeat = _tableSeats[seatIndex];
|
|
if (!tableSeat.IsReserved && !tableSeat.IsOccupied && tableSeat.IsCleaned)
|
|
{
|
|
return tableSeat;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private IEnumerator CleanUpTable(TableSeat tableSeat)
|
|
{
|
|
// TODO : n초간 테이블 청소 애니메이션 (청소 중에 키 작동 금지)
|
|
_isCleaning = true;
|
|
PlayerInputKeyManager.Instance.DisableCurrentPlayerInput();
|
|
|
|
var elapsedTime = 0f;
|
|
while (elapsedTime <= 2f)
|
|
{
|
|
elapsedTime += Time.deltaTime;
|
|
yield return null;
|
|
}
|
|
|
|
tableSeat.CleanUpFood();
|
|
PlayerInputKeyManager.Instance.EnableCurrentPlayerInput();
|
|
_isCleaning = false;
|
|
}
|
|
}
|
|
} |