hiding place sctipts and player interaction
This commit is contained in:
52
Assets/Scripts/HidingSpot.cs
Normal file
52
Assets/Scripts/HidingSpot.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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})");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user