using System.Collections.Generic; using EscapeRoomEngine.Engine.Runtime.Modules; using NaughtyAttributes; using UnityEngine; using UnityEngine.UI; namespace EscapeRoomEngine.Engine.Runtime.UI { public class PuzzlePlan : MonoBehaviour { [SerializeField] private Vector2 entryOffset; [BoxGroup("Internal")] [SerializeField] private RectTransform plan; [BoxGroup("Internal")] [SerializeField] private PuzzlePlanEntry currentPuzzle, entryPrefab; [BoxGroup("Internal")] [SerializeField] private GameObject currentPuzzleTitle, planTitle; public PuzzleModuleDescription CurrentPuzzle { set { currentPuzzleTitle.SetActive(true); currentPuzzle.gameObject.SetActive(true); // set the current puzzle currentPuzzle.Puzzle = value; } } public List Puzzles { set { planTitle.SetActive(true); plan.gameObject.SetActive(true); // remove the old children foreach (RectTransform child in plan) { Destroy(child.gameObject); } // add the new children var offset = Vector2.zero; value.ForEach(puzzle => { var entry = Instantiate(entryPrefab, plan, false); entry.Position = offset; entry.Puzzle = puzzle; offset += entryOffset; }); } } } }