50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using BriarQueen.Data.Identifiers;
|
|
using BriarQueen.Framework.Managers.Levels.Data;
|
|
using BriarQueen.Framework.Managers.Player.Data;
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
namespace BriarQueen.Game.Puzzles.ChapterOne.Fountain
|
|
{
|
|
public class FountainGemSlot : BaseItem
|
|
{
|
|
private FountainGemBasePuzzle _puzzle;
|
|
|
|
private readonly string _firstPieceKey = ItemIDs.Get(ItemKey.Sapphire);
|
|
private readonly string _secondPieceKey = ItemIDs.Get(ItemKey.Emerald);
|
|
private readonly string _thirdPieceKey = ItemIDs.Get(ItemKey.Ruby);
|
|
|
|
public override string InteractableName => "Hole";
|
|
|
|
public void Initialize(FountainGemBasePuzzle puzzle)
|
|
{
|
|
_puzzle = puzzle;
|
|
}
|
|
|
|
public override UniTask OnInteract(ItemDataSo item = null)
|
|
{
|
|
if (_puzzle == null || item == null || _puzzle.IsCompleted)
|
|
{
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
if (!CheckEmptyHands())
|
|
return UniTask.CompletedTask;
|
|
|
|
var itemID = item.UniqueID;
|
|
if (!IsValidGem(itemID))
|
|
{
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
_puzzle.TryInsertGem(item);
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
private bool IsValidGem(string itemID)
|
|
{
|
|
return itemID == _firstPieceKey ||
|
|
itemID == _secondPieceKey ||
|
|
itemID == _thirdPieceKey;
|
|
}
|
|
}
|
|
} |