split into multiple assemblies

This commit is contained in:
2022-11-20 12:52:22 +01:00
parent def03954a0
commit 9fdfafc3eb
373 changed files with 380 additions and 119 deletions

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b9b2d31478f94735a2e19e7c07a27f05
timeCreated: 1668705636

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3b9480c87b3b4def9c85adb088dab147
timeCreated: 1668703088

View 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;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7902f6a7fa0fd844f8ed93e3debd7778
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e099fd852792c34188dcf102aa895e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3d6620bee0f14224b11a19808d537cbd
timeCreated: 1668813872

View 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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7c5df397607f423a8cde06954f22a2bd
timeCreated: 1668762976