+ 전투에서 사용되는 Item 오브젝트의 InteractionUi의 camera를 UiCamera로 연동 + Item의 드랍 방식을 같은 위치에서 랜덤한 위치로 흩뿌리는 방식으로 변경 + 술통, 쓰레기통 상호작용 추가 + 손님이 음료를 요구할 때, 음료 전달 기능 추가 + 가구 Opaque Unlit으로 재질 변경
120 lines
3.3 KiB
C#
120 lines
3.3 KiB
C#
using BlueWater.Items;
|
|
using Sirenix.OdinInspector;
|
|
using Spine.Unity;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace BlueWater.Players.Tycoons
|
|
{
|
|
public enum TycoonPlayerSpineAnimation
|
|
{
|
|
idle = 0,
|
|
run
|
|
}
|
|
|
|
public class TycoonPlayer : MonoBehaviour
|
|
{
|
|
// Variables
|
|
#region Variables
|
|
|
|
// Components
|
|
[field: SerializeField]
|
|
public Rigidbody Rigidbody { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public CapsuleCollider CharacterCollider { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public PlayerInput PlayerInput { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public Transform VisualLook { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public SkeletonAnimation SkeletonAnimation { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public TycoonInput TycoonInput { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public TycoonMovement TycoonMovement { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public TycoonFoodHandler TycoonFoodHandler { get; private set; }
|
|
|
|
#endregion
|
|
|
|
// Unity events
|
|
#region Unity events
|
|
|
|
private void Awake()
|
|
{
|
|
InitializeComponents();
|
|
InitializeChileComponents();
|
|
|
|
if (!GameManager.Instance.CurrentTycoonPlayer)
|
|
{
|
|
GameManager.Instance.SetCurrentTycoonPlayer(this);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
SubscribeEvents();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
UnSubscribeEvents();
|
|
}
|
|
|
|
#endregion
|
|
|
|
// Initialize methods
|
|
#region Initialize methods
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
private void InitializeComponents()
|
|
{
|
|
Rigidbody = GetComponent<Rigidbody>();
|
|
CharacterCollider = GetComponent<CapsuleCollider>();
|
|
PlayerInput = GetComponent<PlayerInput>();
|
|
VisualLook = transform.Find("VisualLook");
|
|
SkeletonAnimation = VisualLook.GetComponent<SkeletonAnimation>();
|
|
|
|
TycoonInput = GetComponent<TycoonInput>();
|
|
TycoonMovement = GetComponent<TycoonMovement>();
|
|
TycoonFoodHandler = GetComponent<TycoonFoodHandler>();
|
|
}
|
|
|
|
private void InitializeChileComponents()
|
|
{
|
|
TycoonMovement.InitializeComponents(Rigidbody, VisualLook);
|
|
}
|
|
|
|
#endregion
|
|
|
|
// Methods
|
|
#region Methods
|
|
|
|
private void SubscribeEvents()
|
|
{
|
|
// Input
|
|
TycoonInput.OnMoveInputReceived += TycoonMovement.HandleInputMovement;
|
|
}
|
|
|
|
private void UnSubscribeEvents()
|
|
{
|
|
// Input
|
|
TycoonInput.OnMoveInputReceived -= TycoonMovement.HandleInputMovement;
|
|
}
|
|
|
|
// Wrapping
|
|
public void CarryFood(int foodIdx) => TycoonFoodHandler.CarryFood(foodIdx);
|
|
public void GiveFood() => TycoonFoodHandler.GiveFood();
|
|
public void DiscardFood() => TycoonFoodHandler.DiscardFood();
|
|
public ItemData GetCurrentFoodData() => TycoonFoodHandler.GetCurrentFoodData();
|
|
|
|
#endregion
|
|
}
|
|
} |