relate terminal and ball
This commit is contained in:
@@ -24,7 +24,7 @@ MonoBehaviour:
|
||||
spawnDoor: {fileID: 11400000, guid: 6e937b2e9f774999b5962c4b40947165, type: 2}
|
||||
exitDoorTypes:
|
||||
- {fileID: 11400000, guid: 29e2ae36585f4e65966bc9ea2f95ac4a, type: 2}
|
||||
puzzleCount: {x: 2, y: 3}
|
||||
puzzleCount: {x: 2, y: 4}
|
||||
puzzleTypes:
|
||||
- {fileID: 11400000, guid: 2a6dd6683bdc4db9b200ccfab1dd4bed, type: 2}
|
||||
- {fileID: 11400000, guid: 3f79d37154e44ca47b54bb43bbe8d9aa, type: 2}
|
||||
|
||||
@@ -7,7 +7,7 @@ AnimationClip:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Light Flash
|
||||
serializedVersion: 6
|
||||
serializedVersion: 7
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
@@ -52,70 +52,70 @@ AnimationClip:
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events:
|
||||
- time: 0
|
||||
functionName: TurnOnRingLight
|
||||
functionName: TurnOnLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.1
|
||||
functionName: TurnOffRingLight
|
||||
functionName: TurnOffLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.2
|
||||
functionName: TurnOnRingLight
|
||||
functionName: TurnOnLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.3
|
||||
functionName: TurnOffRingLight
|
||||
functionName: TurnOffLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.4
|
||||
functionName: TurnOnRingLight
|
||||
functionName: TurnOnLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.5
|
||||
functionName: TurnOffRingLight
|
||||
functionName: TurnOffLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.6
|
||||
functionName: TurnOnRingLight
|
||||
functionName: TurnOnLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.7
|
||||
functionName: TurnOffRingLight
|
||||
functionName: TurnOffLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.8
|
||||
functionName: TurnOnRingLight
|
||||
functionName: TurnOnLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 0.9
|
||||
functionName: TurnOffRingLight
|
||||
functionName: TurnOffLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
|
||||
@@ -7,7 +7,7 @@ AnimationClip:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Light On
|
||||
serializedVersion: 6
|
||||
serializedVersion: 7
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
@@ -52,7 +52,7 @@ AnimationClip:
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events:
|
||||
- time: 0
|
||||
functionName: TurnOnRingLight
|
||||
functionName: TurnOnLights
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
|
||||
@@ -115,7 +115,7 @@ AnimatorController:
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_Controller: {fileID: 0}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
|
||||
@@ -12,4 +12,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 6e3f3bf07aae4a03834a7943c255f37d, type: 3}
|
||||
m_Name: Ball Relation
|
||||
m_EditorClassIdentifier:
|
||||
relatedModule: {fileID: 11400000, guid: bd8605f18a5175146b6518413ead986d, type: 2}
|
||||
relatedModule: {fileID: 11400000, guid: 13174855ef6a14a47b47933e9ebbf192, type: 2}
|
||||
|
||||
@@ -535,7 +535,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 17de1e2991b64847bceea06f966f0560, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
color: {r: 0, g: 0, b: 0, a: 0}
|
||||
color: {r: 8, g: 3.5137255, b: 0, a: 1}
|
||||
--- !u!1 &3629096364680104226
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -691,7 +691,7 @@ Light:
|
||||
serializedVersion: 10
|
||||
m_Type: 2
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 0.44059038, b: 0, a: 1}
|
||||
m_Color: {r: 1, g: 0.4392157, b: 0, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 0.35
|
||||
m_SpotAngle: 30
|
||||
@@ -927,7 +927,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: b9b2d31478f94735a2e19e7c07a27f05, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
theme: {fileID: 11400000, guid: 568d9a7d70f3edb4cb6db66a0010f105, type: 2}
|
||||
ringLight: {fileID: 1320470883464003968}
|
||||
ring: {fileID: 5086091638728871387}
|
||||
--- !u!95 &2153737246840746917
|
||||
|
||||
@@ -9,12 +9,13 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f928b97941e3469a9015316bb5ac1309, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: abf4a405f6c64073995bded39977563e, type: 3}
|
||||
m_Name: Puzzle A Ball
|
||||
m_EditorClassIdentifier:
|
||||
types: 02000000
|
||||
types: 03000000
|
||||
modulePrefab: {fileID: 52047582856427545, guid: aaf5267c4c61b8b49a2258d7c0e7f56f,
|
||||
type: 3}
|
||||
preconditionRequirements: []
|
||||
placementRequirements:
|
||||
- {fileID: 11400000, guid: 43eb2a566a244964aa3a3319eaafe1a8, type: 2}
|
||||
- {fileID: 11400000, guid: ed4830127e9381245a6af07e42c52422, type: 2}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd8605f18a5175146b6518413ead986d
|
||||
guid: 13174855ef6a14a47b47933e9ebbf192
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
|
||||
@@ -1,58 +1,13 @@
|
||||
using System;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
public class Ball : PuzzleState
|
||||
public class Ball : ModuleState
|
||||
{
|
||||
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;
|
||||
}
|
||||
public override void SetModule(Module module) {}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -15,6 +16,7 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
[BoxGroup("Internal")] public List<SymbolButton> symbols;
|
||||
|
||||
private Animator _animator;
|
||||
private Ball _ball;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -28,33 +30,55 @@ namespace EscapeRoomEngine.Desert.Runtime.Puzzle_A
|
||||
switch (type)
|
||||
{
|
||||
case PuzzleEventType.Restarted:
|
||||
_ball.ringLight.color = theme.puzzleColor;
|
||||
terminalLight.color = theme.puzzleColor;
|
||||
symbols.ForEach(symbol => symbol.Enable());
|
||||
_ball.ring.Solved = false;
|
||||
break;
|
||||
case PuzzleEventType.Solved:
|
||||
_ball.ringLight.color = theme.solvedColor;
|
||||
terminalLight.color = theme.solvedColor;
|
||||
symbols.ForEach(symbol => symbol.Disable());
|
||||
_ball.ring.Solved = true;
|
||||
break;
|
||||
case PuzzleEventType.WrongInput:
|
||||
terminalLight.color = theme.puzzleColor;
|
||||
_animator.SetTrigger(LightFlash);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||
}
|
||||
};
|
||||
|
||||
TurnOnRingLight();
|
||||
}
|
||||
|
||||
public void TurnOnRingLight()
|
||||
public override void SetModule(Module module)
|
||||
{
|
||||
base.SetModule(module);
|
||||
|
||||
var firstRelatedModule = Module.relatedModules[0];
|
||||
if (firstRelatedModule.State is Ball ball)
|
||||
{
|
||||
_ball = ball;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EngineException("Terminal was not assigned a related Ball.");
|
||||
}
|
||||
|
||||
TurnOnLights();
|
||||
}
|
||||
|
||||
// required in animation
|
||||
internal void TurnOnLights()
|
||||
{
|
||||
terminalLight.active = true;
|
||||
_ball.ringLight.active = true;
|
||||
}
|
||||
|
||||
public void TurnOffRingLight()
|
||||
// required in animation
|
||||
internal void TurnOffLights()
|
||||
{
|
||||
terminalLight.active = false;
|
||||
_ball.ringLight.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1648,7 +1648,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
loggingEnabled: 1
|
||||
typeFilter: 000000000100000002000000030000000400000005000000
|
||||
typeFilter: 0000000005000000
|
||||
--- !u!1 &1718957584
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
Reference in New Issue
Block a user