split into multiple assemblies
This commit is contained in:
53
Assets/Desert/Runtime/Button.cs
Normal file
53
Assets/Desert/Runtime/Button.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
public class Button : MonoBehaviour
|
||||
{
|
||||
public bool Active
|
||||
{
|
||||
get => _active;
|
||||
private set
|
||||
{
|
||||
_active = value;
|
||||
Pressed = Pressed; // check whether is still pressed
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Pressed
|
||||
{
|
||||
get => _pressed;
|
||||
protected set
|
||||
{
|
||||
_pressed = Active && value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _active, _pressed;
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Enable()
|
||||
{
|
||||
Active = true;
|
||||
}
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Disable()
|
||||
{
|
||||
Active = false;
|
||||
}
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Press()
|
||||
{
|
||||
Pressed = true;
|
||||
}
|
||||
|
||||
[Button(enabledMode: EButtonEnableMode.Playmode)]
|
||||
public void Release()
|
||||
{
|
||||
Pressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Desert/Runtime/Button.cs.meta
Normal file
3
Assets/Desert/Runtime/Button.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0388274fd30c44089477f6bed40e1e23
|
||||
timeCreated: 1668813709
|
||||
17
Assets/Desert/Runtime/Desert.asmdef
Normal file
17
Assets/Desert/Runtime/Desert.asmdef
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "Desert",
|
||||
"rootNamespace": "EscapeRoomEngine",
|
||||
"references": [
|
||||
"GUID:2d68e204354e44f2a2ecf3cfa9213c5f",
|
||||
"GUID:776d03a35f1b52c4a9aed9f56d7b4229"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
3
Assets/Desert/Runtime/Desert.asmdef.meta
Normal file
3
Assets/Desert/Runtime/Desert.asmdef.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20d0c4bd521546c7859e37019a165e38
|
||||
timeCreated: 1668940232
|
||||
29
Assets/Desert/Runtime/DesertFloor.cs
Normal file
29
Assets/Desert/Runtime/DesertFloor.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using NaughtyAttributes;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
public class DesertFloor : MonoBehaviour
|
||||
{
|
||||
[Required] public GameObject floor;
|
||||
[Required] public Transform floorParent;
|
||||
public Vector2 tileSize;
|
||||
public Vector2Int tileCount;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
for (var z = -tileCount.y; z <= tileCount.y; z++)
|
||||
{
|
||||
for (var x = -tileCount.x; x <= tileCount.x; x++)
|
||||
{
|
||||
var f = Instantiate(floor, floorParent);
|
||||
f.transform.localPosition = new Vector3(x * tileSize.x, 0, z * tileSize.y);
|
||||
f.isStatic = true;
|
||||
}
|
||||
}
|
||||
|
||||
SceneVisibilityManager.instance.DisablePicking(floorParent.gameObject, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Desert/Runtime/DesertFloor.cs.meta
Normal file
11
Assets/Desert/Runtime/DesertFloor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d4fe6d2e6d5cac42aed108734e128f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
59
Assets/Desert/Runtime/Emission.cs
Normal file
59
Assets/Desert/Runtime/Emission.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime
|
||||
{
|
||||
public class Emission : MonoBehaviour
|
||||
{
|
||||
private static readonly int EmissionColorNameID = Shader.PropertyToID("_EmissionColor");
|
||||
|
||||
internal bool active;
|
||||
[ColorUsage(false, true)] public Color color;
|
||||
|
||||
private bool _previousActive;
|
||||
private Color _previousColor;
|
||||
private Material _material;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_material = GetComponent<Renderer>().material;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
ChangedToggle();
|
||||
ChangedColor();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_previousActive != active)
|
||||
{
|
||||
ChangedToggle();
|
||||
_previousActive = active;
|
||||
}
|
||||
|
||||
if (!_previousColor.Equals(color))
|
||||
{
|
||||
ChangedColor();
|
||||
_previousColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangedToggle()
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
_material.EnableKeyword("_EMISSION");
|
||||
}
|
||||
else
|
||||
{
|
||||
_material.DisableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangedColor()
|
||||
{
|
||||
_material.SetColor(EmissionColorNameID, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Desert/Runtime/Emission.cs.meta
Normal file
3
Assets/Desert/Runtime/Emission.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17de1e2991b64847bceea06f966f0560
|
||||
timeCreated: 1668704065
|
||||
8
Assets/Desert/Runtime/Puzzle A.meta
Normal file
8
Assets/Desert/Runtime/Puzzle A.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6aa1e96d6564ba419a84d5bcb635568
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
Assets/Desert/Runtime/Puzzle A/Ball.cs
Normal file
58
Assets/Desert/Runtime/Puzzle A/Ball.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class Ball : PuzzleState
|
||||
{
|
||||
private static readonly int LightFlash = Animator.StringToHash("Light Flash");
|
||||
|
||||
[BoxGroup("Internal")] [Required] public Emission ringLight;
|
||||
[BoxGroup("Internal")] [Required] public Ring ring;
|
||||
|
||||
private Animator _animator;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PuzzleEvent += (_, type) =>
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PuzzleEventType.Restarted:
|
||||
ring.Solved = false;
|
||||
TurnOffRingLight();
|
||||
break;
|
||||
case PuzzleEventType.Solved:
|
||||
ring.Solved = true;
|
||||
ringLight.color = theme.solvedColor;
|
||||
TurnOnRingLight();
|
||||
break;
|
||||
case PuzzleEventType.WrongInput:
|
||||
ringLight.color = theme.puzzleColor;
|
||||
_animator.SetTrigger(LightFlash);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void TurnOnRingLight()
|
||||
{
|
||||
ringLight.active = true;
|
||||
}
|
||||
|
||||
public void TurnOffRingLight()
|
||||
{
|
||||
ringLight.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Desert/Runtime/Puzzle A/Ball.cs.meta
Normal file
3
Assets/Desert/Runtime/Puzzle A/Ball.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9b2d31478f94735a2e19e7c07a27f05
|
||||
timeCreated: 1668705636
|
||||
33
Assets/Desert/Runtime/Puzzle A/Crystal.cs
Normal file
33
Assets/Desert/Runtime/Puzzle A/Crystal.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
[RequireComponent(typeof(Emission))]
|
||||
public class Crystal : MonoBehaviour
|
||||
{
|
||||
[Required] public Light crystalLight;
|
||||
|
||||
public bool Active
|
||||
{
|
||||
get => _emission.active;
|
||||
set
|
||||
{
|
||||
_emission.active = value;
|
||||
crystalLight.enabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Emission _emission;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_emission = GetComponent<Emission>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Desert/Runtime/Puzzle A/Crystal.cs.meta
Normal file
3
Assets/Desert/Runtime/Puzzle A/Crystal.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b9480c87b3b4def9c85adb088dab147
|
||||
timeCreated: 1668703088
|
||||
44
Assets/Desert/Runtime/Puzzle A/Ring.cs
Normal file
44
Assets/Desert/Runtime/Puzzle A/Ring.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
public class Ring : MonoBehaviour
|
||||
{
|
||||
public float rotationAngle;
|
||||
[MinMaxSlider(-180, 180)] public Vector2 activeRange;
|
||||
[Required] public Crystal crystal;
|
||||
public List<Symbol> symbols;
|
||||
|
||||
public bool Solved
|
||||
{
|
||||
set
|
||||
{
|
||||
_solved = value;
|
||||
crystal.Active = !_solved;
|
||||
symbols.ForEach(symbol => symbol.Active = !_solved);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _solved;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(!_solved)
|
||||
{
|
||||
transform.localRotation = Quaternion.AngleAxis(rotationAngle, Vector3.forward);
|
||||
|
||||
var activeSymbol = false;
|
||||
symbols.ForEach(symbol =>
|
||||
{
|
||||
var angle = (rotationAngle - symbol.anglePosition) % 360;
|
||||
var active = angle > activeRange.x && angle < activeRange.y || angle > 360 + activeRange.x;
|
||||
symbol.Active = active;
|
||||
activeSymbol |= active;
|
||||
});
|
||||
crystal.Active = activeSymbol;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Desert/Runtime/Puzzle A/Ring.cs.meta
Normal file
11
Assets/Desert/Runtime/Puzzle A/Ring.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7902f6a7fa0fd844f8ed93e3debd7778
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Desert/Runtime/Puzzle A/Symbol.cs
Normal file
31
Assets/Desert/Runtime/Puzzle A/Symbol.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
[RequireComponent(typeof(Emission))]
|
||||
public class Symbol : MonoBehaviour
|
||||
{
|
||||
public float anglePosition;
|
||||
|
||||
public bool Active
|
||||
{
|
||||
get => _emission.active;
|
||||
set
|
||||
{
|
||||
_emission.active = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Emission _emission;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_emission = GetComponent<Emission>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Desert/Runtime/Puzzle A/Symbol.cs.meta
Normal file
11
Assets/Desert/Runtime/Puzzle A/Symbol.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e099fd852792c34188dcf102aa895e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
37
Assets/Desert/Runtime/Puzzle A/SymbolButton.cs
Normal file
37
Assets/Desert/Runtime/Puzzle A/SymbolButton.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using EscapeRoomEngine.Engine.Runtime;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
[RequireComponent(typeof(MeshRenderer))]
|
||||
public class SymbolButton : Button
|
||||
{
|
||||
private static readonly int FresnelPower = Shader.PropertyToID("_FresnelPower");
|
||||
private static readonly int Color = Shader.PropertyToID("_Color");
|
||||
|
||||
public EngineTheme theme;
|
||||
|
||||
public override bool Pressed
|
||||
{
|
||||
get => base.Pressed;
|
||||
protected set
|
||||
{
|
||||
base.Pressed = value;
|
||||
|
||||
var color =
|
||||
Pressed ? theme.activeColor
|
||||
: Active ? theme.puzzleColor
|
||||
: theme.solvedColor;
|
||||
_material.SetColor(FresnelPower, color);
|
||||
_material.SetColor(Color, color);
|
||||
}
|
||||
}
|
||||
|
||||
private Material _material;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_material = GetComponent<MeshRenderer>().material;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Desert/Runtime/Puzzle A/SymbolButton.cs.meta
Normal file
3
Assets/Desert/Runtime/Puzzle A/SymbolButton.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d6620bee0f14224b11a19808d537cbd
|
||||
timeCreated: 1668813872
|
||||
60
Assets/Desert/Runtime/Puzzle A/Terminal.cs
Normal file
60
Assets/Desert/Runtime/Puzzle A/Terminal.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class Terminal : PuzzleState
|
||||
{
|
||||
private static readonly int LightFlash = Animator.StringToHash("Light Flash");
|
||||
|
||||
[BoxGroup("Internal")] [Required] public Emission light;
|
||||
[BoxGroup("Internal")] public List<SymbolButton> symbols;
|
||||
|
||||
private Animator _animator;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PuzzleEvent += (_, type) =>
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PuzzleEventType.Restarted:
|
||||
light.color = theme.puzzleColor;
|
||||
symbols.ForEach(symbol => symbol.Enable());
|
||||
break;
|
||||
case PuzzleEventType.Solved:
|
||||
light.color = theme.solvedColor;
|
||||
symbols.ForEach(symbol => symbol.Disable());
|
||||
break;
|
||||
case PuzzleEventType.WrongInput:
|
||||
light.color = theme.puzzleColor;
|
||||
_animator.SetTrigger(LightFlash);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||
}
|
||||
};
|
||||
|
||||
TurnOnRingLight();
|
||||
}
|
||||
|
||||
public void TurnOnRingLight()
|
||||
{
|
||||
light.active = true;
|
||||
}
|
||||
|
||||
public void TurnOffRingLight()
|
||||
{
|
||||
light.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Desert/Runtime/Puzzle A/Terminal.cs.meta
Normal file
3
Assets/Desert/Runtime/Puzzle A/Terminal.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c5df397607f423a8cde06954f22a2bd
|
||||
timeCreated: 1668762976
|
||||
Reference in New Issue
Block a user