using System.Collections; using System.Collections.Generic; using UnityEngine; using InfallibleCode; using UnityEngine.Events; public class BookPuzzle : MonoBehaviour { [SerializeField] private List _bookSwitch; [SerializeField] private List bookSwitchShouldBePushedIn; [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 < _bookSwitch.Count; i++) { if (_bookSwitch[i].bookSwitchIsPushedIn != bookSwitchShouldBePushedIn[i]) { 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(); } } } }