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