+ 화면 밖에서 손님이 요구하는 중일 때, Indicator를 통해서 Ui 표시 + Open, Closed Ui 추가 및 기능 연결 + 테이블 찾는 로직 변경 (전부 랜덤) - 기존에는 항상 같은 순서로 자리를 채움 + 통계용 데이터 CustomerVisitInfo 추가 (추후에 통계Ui 생길 때 연결) + 대화 조건 변경 + 일부 가구들 상호작용 조건 변경 + Outline shader Render Face(Front -> Both 변경 - Front면 x축 뒤집는 경우 안나옴) + GraphicMaterialOverride를 사용하는 경우, 에디터에서 전체화면 등 특정 상황에서 material이 사라지는 버그 수정 + InteractionFuniture Open, Closed 공통 기능으로 병합
142 lines
4.5 KiB
C#
142 lines
4.5 KiB
C#
using BlueWater.Interfaces;
|
|
using BlueWater.Players.Tycoons;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Tycoons
|
|
{
|
|
public abstract class InteractionFurniture : MonoBehaviour, IPlayerInteraction
|
|
{
|
|
[BoxGroup("컴포넌트")]
|
|
[field: SerializeField, BoxGroup("컴포넌트")]
|
|
public Transform CenterTransform { get; private set; }
|
|
|
|
[field: SerializeField, BoxGroup("컴포넌트")]
|
|
public SpriteRenderer VisualLook { get; private set; }
|
|
|
|
[field: SerializeField, BoxGroup("컴포넌트")]
|
|
public Canvas InteractionCanvas { get; private set; }
|
|
|
|
[field: SerializeField, BoxGroup("컴포넌트")]
|
|
public Transform InteractionUi { get; private set; }
|
|
|
|
[field: SerializeField, Required, BoxGroup("컴포넌트")]
|
|
public Material OutlineMaterial { get; private set; }
|
|
|
|
[BoxGroup("변수")]
|
|
[field: SerializeField, BoxGroup("변수")]
|
|
public bool EnableInteraction { get; private set; } = true;
|
|
|
|
[field: SerializeField, BoxGroup("변수")]
|
|
public float InteractionRadius { get; private set; } = 2f;
|
|
|
|
// TODO : 추후에 다시 활성화 하는 기능 필요
|
|
[Title("실시간 데이터")]
|
|
[SerializeField]
|
|
protected bool IsOpened;
|
|
|
|
protected TycoonPlayer CurrentTycoonPlayer;
|
|
protected bool IsQuitting;
|
|
protected Material OriginalMaterial;
|
|
|
|
private void OnDrawGizmosSelected()
|
|
{
|
|
if (!CenterTransform) return;
|
|
|
|
Gizmos.color = Color.blue;
|
|
Gizmos.DrawWireSphere(CenterTransform.position, InteractionRadius);
|
|
}
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
InitializeComponents();
|
|
OriginalMaterial = VisualLook.material;
|
|
}
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
TycoonManager.Instance.OnTycoonOpenedEvent += OpenTycoonSwitch;
|
|
TycoonManager.Instance.OnTycoonClosedEvent += ClosedTycoonSwitch;
|
|
|
|
RegisterPlayerInteraction();
|
|
}
|
|
|
|
protected virtual void OnDisable()
|
|
{
|
|
if (IsQuitting) return;
|
|
|
|
TycoonManager.Instance.OnTycoonOpenedEvent -= OpenTycoonSwitch;
|
|
TycoonManager.Instance.OnTycoonClosedEvent -= ClosedTycoonSwitch;
|
|
|
|
UnregisterPlayerInteraction();
|
|
}
|
|
|
|
private void OnApplicationQuit()
|
|
{
|
|
IsQuitting = true;
|
|
}
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
protected virtual void InitializeComponents()
|
|
{
|
|
if (!CenterTransform)
|
|
{
|
|
CenterTransform = transform;
|
|
}
|
|
|
|
VisualLook = transform.Find("VisualLook").GetComponent<SpriteRenderer>();
|
|
InteractionCanvas = transform.Find("InteractionCanvas").GetComponent<Canvas>();
|
|
InteractionCanvas.GetComponent<Canvas>().worldCamera = Camera.main;
|
|
InteractionUi = InteractionCanvas.transform.Find("InteractionUi");
|
|
InteractionUi.localScale = Vector3.one * (1 / transform.localScale.x);
|
|
|
|
CurrentTycoonPlayer = GameManager.Instance.CurrentTycoonPlayer;
|
|
}
|
|
|
|
public abstract void Interaction();
|
|
|
|
public virtual bool CanInteraction() => true;
|
|
|
|
public virtual void ShowInteractionUi()
|
|
{
|
|
if (!InteractionCanvas) return;
|
|
|
|
InteractionCanvas.gameObject.SetActive(true);
|
|
VisualLook.material = OutlineMaterial;
|
|
}
|
|
|
|
public virtual void HideInteractionUi()
|
|
{
|
|
if (!InteractionCanvas) return;
|
|
|
|
InteractionCanvas.gameObject.SetActive(false);
|
|
VisualLook.material = OriginalMaterial;
|
|
}
|
|
|
|
protected void RegisterPlayerInteraction()
|
|
{
|
|
if (EnableInteraction)
|
|
{
|
|
GameManager.Instance.CurrentTycoonPlayer.TycoonInput.RegisterPlayerInteraction(this);
|
|
}
|
|
}
|
|
|
|
protected void UnregisterPlayerInteraction()
|
|
{
|
|
if (EnableInteraction)
|
|
{
|
|
GameManager.Instance.CurrentTycoonPlayer.TycoonInput.UnregisterPlayerInteraction(this);
|
|
}
|
|
}
|
|
|
|
protected virtual void OpenTycoonSwitch()
|
|
{
|
|
IsOpened = true;
|
|
}
|
|
|
|
protected virtual void ClosedTycoonSwitch()
|
|
{
|
|
IsOpened = false;
|
|
}
|
|
}
|
|
} |