52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
public class HidingSpot : MonoBehaviour, IInteractable
|
|
{
|
|
public string spotName;
|
|
public List<HidingStep> steps;
|
|
|
|
private int currentStepIndex = 0;
|
|
public bool IsFullyHidden => currentStepIndex >= steps.Count;
|
|
public bool ContainsContraband { get; private set; }
|
|
|
|
public string GetInteractionText(PlayerInteraction player)
|
|
{
|
|
if (IsFullyHidden) return "Kész!";
|
|
|
|
HidingStep nextStep = steps[currentStepIndex];
|
|
ItemType playerHeldItem = player.GetHeldItemType();
|
|
|
|
if (playerHeldItem == nextStep.requiredItem)
|
|
{
|
|
return nextStep.promptText;
|
|
}
|
|
|
|
return $"Szükséged van erre: {nextStep.requiredItem}";
|
|
}
|
|
|
|
public void Interact(PlayerInteraction player)
|
|
{
|
|
if (IsFullyHidden) return;
|
|
|
|
HidingStep nextStep = steps[currentStepIndex];
|
|
Evidence heldEvidence = player.GetHeldEvidence();
|
|
|
|
if (heldEvidence != null && heldEvidence.type == nextStep.requiredItem)
|
|
{
|
|
if (heldEvidence.isContraband) ContainsContraband = true;
|
|
|
|
// Tárgy eltávolítása a kézből
|
|
if (nextStep.consumeItem)
|
|
{
|
|
player.RemoveHeldItem();
|
|
Destroy(heldEvidence.gameObject);
|
|
}
|
|
|
|
nextStep.OnStepCompleted?.Invoke();
|
|
|
|
currentStepIndex++;
|
|
Debug.Log($"{spotName}: Lépés teljesítve! ({currentStepIndex}/{steps.Count})");
|
|
}
|
|
}
|
|
} |