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

@@ -19,7 +19,7 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
/// </summary>
public class GameControl : MonoBehaviour
{
public static readonly Vector2Int DefaultRoomSize = new Vector2Int(2, 4);
private const string TargetTimeKey = "target_time";
/// <summary>
/// The active instance of the game control.
@@ -35,13 +35,15 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
[BoxGroup("Internal")] [SerializeField]
private Button startButton, stopButton, pauseButton, addTimeButton, removeTimeButton;
[BoxGroup("Internal")] [SerializeField]
private Text timeText, roomTimeText, estimateTimeText, targetTimeText, percentileText, widthText, lengthText;
private Text timeText, roomTimeText, estimateTimeText, targetTimeText, percentileText;
[BoxGroup("Internal")] [SerializeField]
private Slider roomWidth, roomLength;
private PersistedSlider roomWidth, roomLength;
[BoxGroup("Internal")] [SerializeField]
private Transform roomSizeElement;
[BoxGroup("Internal")] [SerializeField]
private PuzzlePlan puzzlePlan;
[BoxGroup("Internal")] public PersistedToggle preferLessPlayed;
[HideInInspector] public GameState gameState = GameState.Stopped;
public PuzzleModuleDescription CurrentPuzzle
@@ -73,21 +75,20 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
/// The estimated total time the player will spend in the experience.
/// </summary>
public float EstimatedTime { get; private set; }
public Vector2Int RoomSize { get; private set; }
public Vector2Int RoomSize => new(roomWidth.Value, roomLength.Value);
private float _previousUIUpdate, _previousPlanUpdate;
private void Awake()
{
Instance = this;
RoomSize = DefaultRoomSize;
}
private void Start()
{
TargetTime = Engine.Instance.initialTargetTime;
// read preferences
TargetTime = PlayerPrefs.GetFloat(TargetTimeKey, Engine.Instance.initialTargetTime);
SetTimeText();
}
@@ -121,10 +122,7 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
startButton.interactable = gameState == GameState.Stopped;
stopButton.interactable = gameState != GameState.Stopped;
pauseButton.interactable = gameState is GameState.Running or GameState.Paused;
addTimeButton.interactable = gameState is GameState.Running or GameState.Paused;
removeTimeButton.interactable = gameState is GameState.Running or GameState.Paused && TargetTime >= TimeElapsed + 60;
roomWidth.interactable = gameState == GameState.Stopped;
roomLength.interactable = gameState == GameState.Stopped;
removeTimeButton.interactable = TargetTime >= TimeElapsed + 60;
}
#region Time Controls
@@ -191,6 +189,8 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
if (TargetTime + seconds >= TimeElapsed)
{
TargetTime += seconds;
PlayerPrefs.SetFloat(TargetTimeKey, TargetTime);
PlayerPrefs.Save();
}
}
@@ -230,13 +230,6 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
#endregion
public void SetRoomSize()
{
RoomSize = new Vector2Int((int)roomWidth.value, (int)roomLength.value);
widthText.text = RoomSize.x.ToString();
lengthText.text = RoomSize.y.ToString();
}
public void ExitGame()
{
StopGame();