Files
HauntedBloodlines/Assets/Scripts/Puzzles/Mannequin/MannequinBodyPartsPuzzle.cs
2025-05-29 22:31:40 +03:00

42 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using InfallibleCode;
using UnityEngine.Events;
public class MannequinBodyPartsPuzzle : MonoBehaviour
{
[SerializeField] private List<BodyPartJointHole> bodyPartJointHole;
[SerializeField] private UnityEvent afterSolutionEvent;
[SerializeField] private UnityEvent solutionIsFalseEvent;
public bool shouldFireFalseSolutionEvent;
public void CheckPuzzleCombination()
{
// Check if all switches are in the correct position
bool allSwitchesMatch = true;
for (int i = 0; i < bodyPartJointHole.Count; i++)
{
if (bodyPartJointHole[i].hasCorrectBodyPartInserted != true)
{
allSwitchesMatch = false;
}
}
// If all switches match, fire the afterSolutionEvent
if (allSwitchesMatch)
{
afterSolutionEvent.Invoke();
shouldFireFalseSolutionEvent = true;
}
else
{
if (shouldFireFalseSolutionEvent)
{
// If switches don't match, fire the whenSwitchesDontMatchEvent
solutionIsFalseEvent.Invoke();
}
}
}
}