move puzzle implementations out of engine
This commit is contained in:
22
Assets/Engine/Runtime/UI/Elements/PauseButton.cs
Normal file
22
Assets/Engine/Runtime/UI/Elements/PauseButton.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.UI.Elements
|
||||
{
|
||||
/// <summary>
|
||||
/// This component is responsible to change the icon of the pause button depending on the game state.
|
||||
/// </summary>
|
||||
public class PauseButton : MonoBehaviour
|
||||
{
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private Image icon;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private Sprite pauseIcon, resumeIcon;
|
||||
|
||||
public bool Paused
|
||||
{
|
||||
set => icon.sprite = value ? resumeIcon : pauseIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Engine/Runtime/UI/Elements/PauseButton.cs.meta
Normal file
3
Assets/Engine/Runtime/UI/Elements/PauseButton.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 453c346d9a6f46828b7fc21944890efa
|
||||
timeCreated: 1671030945
|
||||
61
Assets/Engine/Runtime/UI/Elements/PuzzlePlan.cs
Normal file
61
Assets/Engine/Runtime/UI/Elements/PuzzlePlan.cs
Normal 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Engine/Runtime/UI/Elements/PuzzlePlan.cs.meta
Normal file
3
Assets/Engine/Runtime/UI/Elements/PuzzlePlan.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad95894771b8478591e5f5abbe1d0244
|
||||
timeCreated: 1671133031
|
||||
34
Assets/Engine/Runtime/UI/Elements/PuzzlePlanEntry.cs
Normal file
34
Assets/Engine/Runtime/UI/Elements/PuzzlePlanEntry.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using EscapeRoomEngine.Engine.Runtime.Measurements;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules.Description;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.UI.Elements
|
||||
{
|
||||
/// <summary>
|
||||
/// An entry in the <see cref="PuzzlePlan"/> UI component that displays the name and estimated time for a puzzle.
|
||||
/// </summary>
|
||||
public class PuzzlePlanEntry : MonoBehaviour
|
||||
{
|
||||
[BoxGroup("Internal")] [Required] [SerializeField]
|
||||
private Text puzzleName, estimatedTime;
|
||||
|
||||
public Vector2 Position
|
||||
{
|
||||
set
|
||||
{
|
||||
puzzleName.rectTransform.anchoredPosition = value;
|
||||
}
|
||||
}
|
||||
public PuzzleModuleDescription Puzzle
|
||||
{
|
||||
set
|
||||
{
|
||||
puzzleName.text = value.puzzleName;
|
||||
estimatedTime.text = $"Time Estimate: {Measure.EstimateTime(value).ToTimeSpan():mm':'ss}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ef80fc9016c4a46a190769f3b771bfa
|
||||
timeCreated: 1671136597
|
||||
Reference in New Issue
Block a user