Finish Puzzle C
This commit is contained in:
39
Assets/Desert/Runtime/Puzzle C/DispenserLights.cs
Normal file
39
Assets/Desert/Runtime/Puzzle C/DispenserLights.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Desert.Runtime.Puzzle_C
|
||||
{
|
||||
[Serializable]
|
||||
public struct DispenserLightRow
|
||||
{
|
||||
public bool[] lights;
|
||||
}
|
||||
|
||||
public class DispenserLights : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private DispenserLightRow[] lights;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private GameObject lightPrefab;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private Vector2Int gridDimensions;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private Vector2 lightOffset;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var position = transform.localPosition;
|
||||
for (var y = 0; y < gridDimensions.y; y++)
|
||||
{
|
||||
var row = lights[y].lights;
|
||||
for (var x = 0; x < gridDimensions.x; x++)
|
||||
{
|
||||
var instance = Instantiate(lightPrefab, transform, false);
|
||||
instance.transform.localPosition = new Vector3(-x * lightOffset.x, 0, y * lightOffset.y);
|
||||
instance.GetComponent<Emission>().active = row[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user