91 lines
2.8 KiB
C#
91 lines
2.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Threading.Tasks;
|
|
using DDD.ScriptableObjects;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace DDD.Tycoons
|
|
{
|
|
[Serializable]
|
|
public class Frying : InteractionFurniture
|
|
{
|
|
[SerializeField]
|
|
private AnimationController _animationController;
|
|
|
|
[Title("연출")]
|
|
[SerializeField]
|
|
private Color _enableColor = Color.white;
|
|
|
|
[SerializeField]
|
|
private Color _disableColor = Color.gray;
|
|
|
|
private Material _instanceMaterial;
|
|
private CraftingTool _craftingTool = CraftingTool.Frying;
|
|
|
|
private const string IsEnabledHash = "isEnabled";
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
|
|
HoldingAction = SuccessHoldingAction;
|
|
_instanceMaterial = VisualLook.material;
|
|
VisualLook.material = Instantiate(_instanceMaterial);
|
|
|
|
EventManager.OnChangedCraftingTool += ChangeColor;
|
|
}
|
|
|
|
protected override void OnDestroy()
|
|
{
|
|
base.OnDestroy();
|
|
|
|
EventManager.OnChangedCraftingTool -= ChangeColor;
|
|
}
|
|
|
|
public override void Interaction()
|
|
{
|
|
base.Interaction();
|
|
|
|
GameManager.Instance.CurrentTycoonPlayer.IsCookingFried = true;
|
|
//_animationController.SetAnimationParameter(IsEnabledHash, true);
|
|
}
|
|
|
|
public override void CancelInteraction()
|
|
{
|
|
base.CancelInteraction();
|
|
|
|
GameManager.Instance.CurrentTycoonPlayer.IsCookingFried = false;
|
|
//_animationController.SetAnimationParameter(IsEnabledHash, false);
|
|
}
|
|
|
|
public override bool CanInteraction()
|
|
{
|
|
CraftRecipeData playerCraftRecipeData = CurrentTycoonPlayer.TycoonPickupHandler.CurrentCraftRecipeData;
|
|
if (playerCraftRecipeData == null || playerCraftRecipeData.CraftingToolQueue.Count <= 0) return false;
|
|
|
|
CraftingTool playerCraftingTool = playerCraftRecipeData.CraftingToolQueue.Peek();
|
|
return IsOpened && playerCraftingTool == _craftingTool;
|
|
}
|
|
|
|
private void SuccessHoldingAction()
|
|
{
|
|
CurrentTycoonPlayer.TycoonPickupHandler.InteractionCraftingTool();
|
|
CancelInteraction();
|
|
}
|
|
|
|
private async void ChangeColor(CraftingTool? playerCraftingTool)
|
|
{
|
|
await Task.Delay(100);
|
|
|
|
if (playerCraftingTool == null)
|
|
{
|
|
VisualLook.material.color = _enableColor;
|
|
}
|
|
else
|
|
{
|
|
VisualLook.material.color = (CraftingTool)playerCraftingTool == _craftingTool ? _enableColor : _disableColor;
|
|
}
|
|
}
|
|
}
|
|
} |