increase room diversity, improve ui

This commit is contained in:
2023-05-13 13:06:08 +02:00
parent ec094f410f
commit 033989a85e
21 changed files with 736 additions and 83 deletions

View File

@@ -0,0 +1,61 @@
using System.Collections.Generic;
using EscapeRoomEngine.Engine.Runtime.Modules.Description;
using NaughtyAttributes;
using UnityEngine;
namespace EscapeRoomEngine.Engine.Runtime.UI.Elements
{
/// <summary>
/// The puzzle plan UI component that displays the current puzzle plan in the game master window.
/// </summary>
public class PuzzlePlan : MonoBehaviour
{
/// <summary>
/// The distance from one entry to the next.
/// </summary>
[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<PuzzleModuleDescription> 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;
});
}
}
}
}