puzzle module framework, puzzle a ball module

This commit is contained in:
2022-11-18 02:10:05 +01:00
parent bd0934636f
commit 99e0452379
90 changed files with 4799 additions and 51 deletions

View File

@@ -0,0 +1,58 @@
using System;
using Escape_Room_Engine.Engine.Scripts.Modules;
using NaughtyAttributes;
using UnityEngine;
namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
{
[RequireComponent(typeof(Animator))]
public class Ball : PuzzleState
{
private static readonly int LightFlash = Animator.StringToHash("Light Flash");
[BoxGroup("Internal")] [Required] public RingLight 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,34 @@
using Escape_Room_Engine.Desert.Scripts;
using NaughtyAttributes;
using UnityEngine;
namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
{
[RequireComponent(typeof(EmissionToggle))]
public class Crystal : MonoBehaviour
{
[Required] public Light crystalLight;
public bool Active
{
get => _emission.active;
set
{
_emission.active = value;
crystalLight.enabled = value;
}
}
private EmissionToggle _emission;
private void Awake()
{
_emission = GetComponent<EmissionToggle>();
}
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 Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
{
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,37 @@
using Escape_Room_Engine.Desert.Scripts;
using UnityEngine;
namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
{
[RequireComponent(typeof(EmissionToggle), typeof(EmissionColor))]
public class RingLight : MonoBehaviour
{
public bool Active
{
get => _emissionToggle.active;
set
{
_emissionToggle.active = value;
}
}
public Color Color
{
get => _emissionColor.color;
set => _emissionColor.color = value;
}
private EmissionToggle _emissionToggle;
private EmissionColor _emissionColor;
private void Awake()
{
_emissionToggle = GetComponent<EmissionToggle>();
_emissionColor = GetComponent<EmissionColor>();
}
private void Start()
{
Active = false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a8f20dfd8ae64b4d87b98590269b7298
timeCreated: 1668704631

View File

@@ -0,0 +1,32 @@
using Escape_Room_Engine.Desert.Scripts;
using UnityEngine;
namespace Escape_Room_Engine.Desert.Modules.Puzzle_A.Scripts
{
[RequireComponent(typeof(EmissionToggle))]
public class Symbol : MonoBehaviour
{
public float anglePosition;
public bool Active
{
get => _emission.active;
set
{
_emission.active = value;
}
}
private EmissionToggle _emission;
private void Awake()
{
_emission = GetComponent<EmissionToggle>();
}
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: