From 674e2d77070307bd7f714fdb87a92c80bcc96a14 Mon Sep 17 00:00:00 2001 From: Amelia Date: Mon, 16 Sep 2024 18:17:37 -0500 Subject: [PATCH] populate puzzle from scriptable object --- Assets/Project/Data/Puzzles/Leo.asset | 8 +- .../Postcards/PostcardPuzzleHorizontal.prefab | 24 ++- Assets/Project/Scenes/Skybox.unity | 171 +++++++++++++++++- Assets/Project/Scripts/Data/CelestialData.cs | 20 ++ Assets/Project/Scripts/Data/PuzzleData.cs | 6 +- .../Scripts/UI/Postcard/PostcardPuzzle.cs | 16 ++ .../Scripts/UI/Postcard/PuzzleObject.cs | 14 ++ 7 files changed, 243 insertions(+), 16 deletions(-) diff --git a/Assets/Project/Data/Puzzles/Leo.asset b/Assets/Project/Data/Puzzles/Leo.asset index f1e151c..753b450 100644 --- a/Assets/Project/Data/Puzzles/Leo.asset +++ b/Assets/Project/Data/Puzzles/Leo.asset @@ -12,13 +12,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c58baf77432a10244acefb3ca320caa1, type: 3} m_Name: Leo m_EditorClassIdentifier: - m_PuzzleObjects: + m_PuzzleRefs: - RefObject: {fileID: 11400000, guid: eafaa97d14e43aa4ab8aa2c9732d0693, type: 2} - ShowProperties: 34 + ShowProperties: 10 - RefObject: {fileID: 11400000, guid: fdd8d7541758faa448f475232b13d819, type: 2} - ShowProperties: 34 + ShowProperties: 2 - RefObject: {fileID: 11400000, guid: ad82f7c67c40e7b478d7e73eabac0c05, type: 2} - ShowProperties: 42 + ShowProperties: 10 - RefObject: {fileID: 11400000, guid: 10d9d00870e69dc49a7bc5b90497791f, type: 2} ShowProperties: 6 m_Clues: diff --git a/Assets/Project/Prefabs/Postcards/PostcardPuzzleHorizontal.prefab b/Assets/Project/Prefabs/Postcards/PostcardPuzzleHorizontal.prefab index 8c7c339..095c896 100644 --- a/Assets/Project/Prefabs/Postcards/PostcardPuzzleHorizontal.prefab +++ b/Assets/Project/Prefabs/Postcards/PostcardPuzzleHorizontal.prefab @@ -607,7 +607,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Button + m_text: Finish m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -616,8 +616,8 @@ MonoBehaviour: m_fontMaterials: [] m_fontColor32: serializedVersion: 2 - rgba: 4281479730 - m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} m_enableVertexGradient: 0 m_colorMode: 3 m_fontColorGradient: @@ -640,7 +640,7 @@ MonoBehaviour: m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 - m_fontStyle: 0 + m_fontStyle: 1 m_HorizontalAlignment: 2 m_VerticalAlignment: 512 m_textAlignment: 65535 @@ -1099,7 +1099,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &8746709303137106571 RectTransform: m_ObjectHideFlags: 0 @@ -1118,8 +1118,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: -4, y: 4} - m_SizeDelta: {x: 160, y: 50} + m_AnchoredPosition: {x: -15, y: 15} + m_SizeDelta: {x: 210, y: 70} m_Pivot: {x: 1, y: 0} --- !u!222 &2998185016765499790 CanvasRenderer: @@ -1150,7 +1150,7 @@ MonoBehaviour: m_SelectOnRight: {fileID: 0} m_Transition: 1 m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_NormalColor: {r: 0.24875402, g: 0.45780137, b: 0.8113208, a: 1} m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} @@ -1169,7 +1169,7 @@ MonoBehaviour: m_SelectedTrigger: Selected m_DisabledTrigger: Disabled m_Interactable: 1 - m_TargetGraphic: {fileID: 0} + m_TargetGraphic: {fileID: 5295124876076571565} m_OnClick: m_PersistentCalls: m_Calls: [] @@ -1186,7 +1186,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.4009434, g: 0.6140097, b: 1, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -2535,6 +2535,10 @@ MonoBehaviour: - {fileID: 6651233270880856590} - {fileID: 1382012353175599924} - {fileID: 4669792757732369514} + Clues: + - {fileID: 7239627528006946004} + - {fileID: 8732284153573659785} + - {fileID: 7283120328074507190} m_FinishButton: {fileID: 8804041329015251587} --- !u!224 &3471607100287258981 stripped RectTransform: diff --git a/Assets/Project/Scenes/Skybox.unity b/Assets/Project/Scenes/Skybox.unity index a5989da..382fb70 100644 --- a/Assets/Project/Scenes/Skybox.unity +++ b/Assets/Project/Scenes/Skybox.unity @@ -2148,6 +2148,42 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: -1.1447144 objectReference: {fileID: 0} + - target: {fileID: 1345146977094083068, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1345146977094083068, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1345146977094083068, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1345146977094083068, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1362765506118912221, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: PuzzleData + value: + objectReference: {fileID: 11400000, guid: 9636f1322f95ff04ea18314a36b04707, type: 2} + - target: {fileID: 1362765506118912221, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: Clues.Array.size + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 1362765506118912221, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: Clues.Array.data[0] + value: + objectReference: {fileID: 2274155455258433594} + - target: {fileID: 1362765506118912221, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: Clues.Array.data[1] + value: + objectReference: {fileID: 2274155455258433593} + - target: {fileID: 1362765506118912221, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: Clues.Array.data[2] + value: + objectReference: {fileID: 2274155455258433592} - target: {fileID: 1362827765924626667, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -2572,6 +2608,22 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 2046148042728693542, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2046148042728693542, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2046148042728693542, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2046148042728693542, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2053382487452899574, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -3240,6 +3292,10 @@ PrefabInstance: propertyPath: m_AnchorMin.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 3168215361997660756, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3182363450244950974, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -3584,6 +3640,22 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 3925762732023910692, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3925762732023910692, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3925762732023910692, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3925762732023910692, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3981998471100249076, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -3976,6 +4048,22 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 4500690850336022560, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4500690850336022560, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4500690850336022560, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4500690850336022560, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4514669364589064069, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -3996,6 +4084,22 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 4581601237892739508, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4581601237892739508, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4581601237892739508, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4581601237892739508, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4617854793494524283, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -4294,7 +4398,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5068986546201449257, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchoredPosition.y - value: 0.08129883 + value: 0.08703613 objectReference: {fileID: 0} - target: {fileID: 5078577928483592518, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y @@ -4448,6 +4552,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 5418539812907695742, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 5486910667021444496, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -4572,6 +4680,18 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 5811394046182290451, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5811394046182290451, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5811394046182290451, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5820875086643345666, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -4876,6 +4996,22 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 6429916305000920582, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6429916305000920582, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6429916305000920582, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6429916305000920582, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 6490326604673804209, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -6354,6 +6490,39 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} +--- !u!114 &2274155455258433592 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1373104782645598674, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + m_PrefabInstance: {fileID: 2274155455258433590} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &2274155455258433593 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1095402699541872365, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + m_PrefabInstance: {fileID: 2274155455258433590} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &2274155455258433594 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1325388968946820784, guid: 005d4cd2f1886f44ea44c831dcfb1f5f, type: 3} + m_PrefabInstance: {fileID: 2274155455258433590} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &7306638882126709139 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Project/Scripts/Data/CelestialData.cs b/Assets/Project/Scripts/Data/CelestialData.cs index 1a6f480..1832a31 100644 --- a/Assets/Project/Scripts/Data/CelestialData.cs +++ b/Assets/Project/Scripts/Data/CelestialData.cs @@ -32,6 +32,26 @@ public class CelestialData : ScriptableObject [SerializeField] private bool m_useOverrideFocusVisual; [SerializeField] private GameObject m_overrideFocusVisual; + public static DataPayload ToPayload(CelestialData inData, DraggableFlags mask) { + DataPayload outData = new DataPayload(); + if (mask.HasFlag(DraggableFlags.Name)) { + outData.Name = inData.Name; + } + if (mask.HasFlag(DraggableFlags.Coords)) { + outData.Coordinates = new EqCoordinates(inData.RA, inData.Decl); + } + if (mask.HasFlag(DraggableFlags.Color)) { + outData.Color = inData.OverrideMat.color; + } + if (mask.HasFlag(DraggableFlags.Magnitude)) { + outData.Magnitude = inData.Magnitude; + } + if (mask.HasFlag(DraggableFlags.Spectrum)) { + outData.Spectrum = inData.Spectrum; + } + return outData; + } + public string Name { get { return m_name; } } public Vector3 RA { get { return m_rightAscension; } } diff --git a/Assets/Project/Scripts/Data/PuzzleData.cs b/Assets/Project/Scripts/Data/PuzzleData.cs index 3c742f6..c09c482 100644 --- a/Assets/Project/Scripts/Data/PuzzleData.cs +++ b/Assets/Project/Scripts/Data/PuzzleData.cs @@ -12,8 +12,12 @@ public struct PuzzleObjectRef { [CreateAssetMenu(menuName = "AstroLab/Create Puzzle Data")] public class PuzzleData : ScriptableObject { - [SerializeField] private PuzzleObjectRef[] m_PuzzleObjects; + [SerializeField] private PuzzleObjectRef[] m_PuzzleRefs; [SerializeField] private string[] m_Clues; + + + public PuzzleObjectRef[] PuzzleRefs { get { return m_PuzzleRefs; } } + public string[] Clues { get { return m_Clues; } } } diff --git a/Assets/Project/Scripts/UI/Postcard/PostcardPuzzle.cs b/Assets/Project/Scripts/UI/Postcard/PostcardPuzzle.cs index 4373fab..fba1777 100644 --- a/Assets/Project/Scripts/UI/Postcard/PostcardPuzzle.cs +++ b/Assets/Project/Scripts/UI/Postcard/PostcardPuzzle.cs @@ -1,4 +1,5 @@ using BeauUtil.Debugger; +using TMPro; using UnityEngine; using UnityEngine.UI; @@ -9,12 +10,26 @@ public class PostcardPuzzle : MonoBehaviour { [SerializeField] private PuzzleData PuzzleData; [SerializeField] private PuzzleObject[] PuzzleObjects; + [SerializeField] private TMP_Text[] Clues; [SerializeField] private Button m_FinishButton; public Button FinishButton { get { return m_FinishButton; }} private void Start() { m_FinishButton.onClick.AddListener(OnFinishClicked); m_FinishButton.interactable = false; + if (PuzzleData != null) { + PopulateFromPuzzleData(); + } + } + + [ContextMenu("Populate From Puzzle Data")] + public void PopulateFromPuzzleData() { + for (int i = 0; i < PuzzleObjects.Length; i++) { + PuzzleObjects[i].PuzzleRefPopulate(PuzzleData.PuzzleRefs[i]); + if (i < Clues.Length && PuzzleData.Clues[i] != null) { + Clues[i].SetText(PuzzleData.Clues[i]); + } + } } [ContextMenu("Populate Solutions from Refs")] @@ -38,6 +53,7 @@ public bool EvaluateSolved() { } } m_FinishButton.interactable = true; + m_FinishButton.gameObject.SetActive(true); return true; } diff --git a/Assets/Project/Scripts/UI/Postcard/PuzzleObject.cs b/Assets/Project/Scripts/UI/Postcard/PuzzleObject.cs index ae03d72..c65ee83 100644 --- a/Assets/Project/Scripts/UI/Postcard/PuzzleObject.cs +++ b/Assets/Project/Scripts/UI/Postcard/PuzzleObject.cs @@ -12,6 +12,20 @@ public class PuzzleObject : MonoBehaviour { [SerializeField] private CelestialData RefObject; + + public void SetRef(CelestialData data) { + RefObject = data; + } + + public void PuzzleRefPopulate(PuzzleObjectRef pObj) { + RefObject = pObj.RefObject; + StartingValues = CelestialData.ToPayload(pObj.RefObject, pObj.ShowProperties); + PopulateStartingValues(); + RefToSolutionVals(); + } + + + [ContextMenu("Populate Starting Values")] public void PopulateStartingValues() { for (int i = 0; i < Slots.Length; i++) {