clean up ui

This commit is contained in:
2022-12-14 16:50:42 +01:00
parent 14098e1d73
commit db5123278d
24 changed files with 1591 additions and 700 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a410f34b59ec77a4e812d864531e5873
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Engine/Assets/Materials/Icons/pause.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: fe459a26e8015fc408ef300566fb121a
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Engine/Assets/Materials/Icons/play.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: 61f7b49a6c0a2214d9baa5d8ddcf31b2
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Engine/Assets/Materials/Icons/stop.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,124 @@
fileFormatVersion: 2
guid: 695e50e2c676ca44784c3c8ddbe0d61d
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -183,7 +183,7 @@ MonoBehaviour:
m_HighlightedColor: {r: 0.5058824, g: 0.77254903, b: 1, a: 1}
m_PressedColor: {r: 0.2509804, g: 0.654902, b: 1, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.15686275}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:

View File

@@ -0,0 +1,212 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5404868147474641561
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4377243557369981293}
- component: {fileID: 2356888293442629535}
- component: {fileID: 2677713198330469630}
m_Layer: 5
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4377243557369981293
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5404868147474641561}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5840570772713645737}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 16, y: 16}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2356888293442629535
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5404868147474641561}
m_CullTransparentMesh: 1
--- !u!114 &2677713198330469630
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5404868147474641561}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1001 &7167958961676502264
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3635623840709501520, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_Name
value: Icon Button
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_Pivot.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_SizeDelta.x
value: 30
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_SizeDelta.y
value: 30
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects:
- {fileID: 3635623839229914391, guid: c7b840466ebfae1468d75282ab9334f5, type: 3}
m_AddedGameObjects:
- targetCorrespondingSourceObject: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
insertIndex: -1
addedObject: {fileID: 4377243557369981293}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c7b840466ebfae1468d75282ab9334f5, type: 3}
--- !u!224 &5840570772713645737 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 3635623840709501521, guid: c7b840466ebfae1468d75282ab9334f5,
type: 3}
m_PrefabInstance: {fileID: 7167958961676502264}
m_PrefabAsset: {fileID: 0}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a0d402627dc805e42ab9e84487b9871b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -29,8 +29,10 @@ namespace EscapeRoomEngine.Engine.Runtime
public event UpdateUIHandler UpdateUIEvent;
[InfoBox("If a space was generated without any puzzles in it, the engine will try generating another new space. To prevent infinite loops, the amount of retries is bound.")]
public int maxSpaceGenerationTries;
public Vector3 roomOffset;
public int maxSpaceGenerationTries = 1000;
[Tooltip("The engine will try to generate a room that takes approximately this many seconds to complete.")]
public float initialTargetTime = 5 * 60;
public Vector3 roomOffset = new(0, 1000, 0);
[Required] public EngineTheme theme;
public int NumberOfRooms => _rooms.Count;

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using EscapeRoomEngine.Engine.Runtime.Measurements;
using EscapeRoomEngine.Engine.Runtime.Modules;
using EscapeRoomEngine.Engine.Runtime.UI;
using UnityEngine;
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType;

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 62339e229fef456eb708b30d13ec8d91
timeCreated: 1671030929

View File

@@ -1,10 +1,11 @@
using System;
using EscapeRoomEngine.Engine.Runtime.Measurements;
using EscapeRoomEngine.Engine.Runtime.Utilities;
using NaughtyAttributes;
using UnityEngine;
using UnityEngine.UI;
namespace EscapeRoomEngine.Engine.Runtime
namespace EscapeRoomEngine.Engine.Runtime.UI
{
public enum GameState
{
@@ -26,20 +27,23 @@ namespace EscapeRoomEngine.Engine.Runtime
}
private static GameControl _foundGameControl;
[BoxGroup("Internal")]
[SerializeField]
private Button startButton, stopButton, pauseButton, resumeButton, addTimeButton, removeTimeButton;
[BoxGroup("Internal")]
[SerializeField]
private Text timeText;
[BoxGroup("Internal")] [SerializeField]
private Button startButton, stopButton, pauseButton, addTimeButton, removeTimeButton;
[BoxGroup("Internal")] [SerializeField]
private Text timeText, targetTimeText, estimateTimeText;
[HideInInspector] public GameState gameState = GameState.Stopped;
private float _timeElapsed;
private float _timeElapsed, _targetTime;
private void Awake()
{
_targetTime = Engine.DefaultEngine.initialTargetTime;
}
private void Start()
{
SetGamemasterTimeText(_timeElapsed);
SetTimeText();
}
private void Update()
@@ -49,16 +53,15 @@ namespace EscapeRoomEngine.Engine.Runtime
{
_timeElapsed += Time.deltaTime;
SetGamemasterTimeText(_timeElapsed);
SetTimeText();
}
// Enable or disable buttons
startButton.interactable = gameState == GameState.Stopped;
stopButton.interactable = gameState != GameState.Stopped;
pauseButton.interactable = gameState == GameState.Running;
resumeButton.interactable = gameState == GameState.Paused;
pauseButton.interactable = gameState is GameState.Running or GameState.Paused;
addTimeButton.interactable = gameState != GameState.Stopped;
removeTimeButton.interactable = gameState != GameState.Stopped && _timeElapsed >= 10;
removeTimeButton.interactable = gameState != GameState.Stopped && _targetTime >= _timeElapsed + 60;
}
#region Time Controls
@@ -89,12 +92,18 @@ namespace EscapeRoomEngine.Engine.Runtime
public void PauseGame()
{
gameState = GameState.Paused;
}
public void ResumeGame()
{
gameState = GameState.Running;
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
switch (gameState)
{
case GameState.Running:
gameState = GameState.Paused;
pauseButton.GetComponent<PauseButton>().Paused = true;
break;
case GameState.Paused:
gameState = GameState.Running;
pauseButton.GetComponent<PauseButton>().Paused = false;
break;
}
}
/// <summary>
@@ -103,32 +112,20 @@ namespace EscapeRoomEngine.Engine.Runtime
/// <param name="seconds">The amount of seconds that will be added to the time. Can be negative to remove time.</param>
public void ChangeTime(int seconds)
{
if (_timeElapsed + seconds >= 0)
if (_targetTime + seconds >= _timeElapsed)
{
_timeElapsed += seconds;
_targetTime += seconds;
}
}
private void SetGamemasterTimeText(float time)
private void SetTimeText()
{
if (timeText != null)
{
timeText.text = TimeToText(time);
}
timeText.text = TimeToText(_timeElapsed);
targetTimeText.text = TimeToText(_targetTime);
estimateTimeText.text = TimeToText(_timeElapsed);
}
private static string TimeToText(float time)
{
var minutes = (int) (time / 60);
var seconds = (int) Math.Ceiling(time - minutes * 60);
if (seconds == 60)
{
minutes += 1;
seconds = 0;
}
return $"{minutes:D2}:{seconds:D2}";
}
private static string TimeToText(float time) => $"{time.ToTimeSpan():mm':'ss}";
#endregion

View File

@@ -0,0 +1,19 @@
using NaughtyAttributes;
using UnityEngine;
using UnityEngine.UI;
namespace EscapeRoomEngine.Engine.Runtime.UI
{
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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 453c346d9a6f46828b7fc21944890efa
timeCreated: 1671030945