Files
HauntedBloodlines/Assets/Scripts/Pickups/KeyHoleCurrentKey.cs
2025-05-29 22:31:40 +03:00

56 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using InfallibleCode;
public class KeyHoleCurrentKey : MonoBehaviour
{
[SerializeField] private DoorBehaviour _door;
[SerializeField] private KeyHole _keyhole;
[SerializeField] private KeyPickup[] _key;
[Header("Debugging")]
public int CurrentKeyID;
public bool _CollectedKey;
public bool _Done;
int _arrayLength;
private void Awake()
{
_arrayLength = _key.Length;
}
private void Start()
{
_arrayLength -= 1;
}
private void Update()
{
if (!_CollectedKey && !_Done)
{
if (_key[CurrentKeyID].hasKey)
{
_keyhole.KeyPickup = _key[CurrentKeyID];
_CollectedKey = true;
print("Has key");
}
}
if (!_door.DoorRequiresKey && _CollectedKey)
{
if (CurrentKeyID < _arrayLength)
{
CurrentKeyID += 1;
}
else
{
_Done = true;
}
_CollectedKey = false;
print("Current Key ID increacead");
}
}
}