diff --git a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs index be559e6908f333aec6a714b2298cfd947aea247c..d5a27cf2240894c0bafe08dd1782076d394950cf 100644 --- a/Assets/Scripts/InteractionEngine/CommunicationEvents.cs +++ b/Assets/Scripts/InteractionEngine/CommunicationEvents.cs @@ -16,16 +16,17 @@ public static class CommunicationEvents public static UnityEvent<Fact> RemoveFactEvent = new(); public static UnityEvent<Fact, FactObject.FactMaterials> PushoutFactEvent = new(); - public static UnityEvent<Fact> PushoutFactFailEvent = new(); + public static UnityEvent<Fact, Scroll.ScrollApplicationInfo> PushoutFactFailEvent = new(); public static UnityEvent gameSucceededEvent = new(); public static UnityEvent gameNotSucceededEvent = new(); public static UnityEvent NewAssignmentEvent = new(); public static UnityEvent<GameObject, string> ScrollFactHintEvent = new(); - public static UnityEvent<Fact> AnimateExistingFactEvent = new(); + public static UnityEvent<Fact, FactObject.FactMaterials> AnimateExistingFactEvent = new(); public static UnityEvent<Fact> AnimateNonExistingFactEvent = new(); public static UnityEvent<List<string>> HintAvailableEvent = new(); + //------------------------------------------------------------------------------------ diff --git a/Assets/Scripts/InteractionEngine/ShinyThings.cs b/Assets/Scripts/InteractionEngine/ShinyThings.cs index 9c8c7038ee47aa5b223162391e80f195253763b9..6266f018da1ddf6bcb1f8ed0af40001a128fee56 100644 --- a/Assets/Scripts/InteractionEngine/ShinyThings.cs +++ b/Assets/Scripts/InteractionEngine/ShinyThings.cs @@ -1,6 +1,5 @@ using System.Collections; using System.Collections.Generic; -using System.Linq; using UnityEngine; public class ShinyThings : MonoBehaviour @@ -17,7 +16,7 @@ public class ShinyThings : MonoBehaviour private IEnumerator rain; public Light directionalLight; - private Color darkColor = new (0.2f, 0.2f, 0.2f); + private Color darkColor = new(0.2f, 0.2f, 0.2f); private Color light_colour; private GameObject active_rainwork; @@ -29,8 +28,10 @@ public GameObject private void Awake() { CommunicationEvents.PushoutFactEvent.AddListener(HighlightFact); + CommunicationEvents.PushoutFactEvent.AddListener(HighlightWithFireworks); + CommunicationEvents.AnimateExistingFactEvent.AddListener(HighlightFact); CommunicationEvents.PushoutFactFailEvent.AddListener(LetItRain); - CommunicationEvents.AnimateExistingFactEvent.AddListener(HighlightWithFireworks); + //CommunicationEvents.AnimateExistingAsSolutionEvent.AddListener(HighlightWithFireworks); rain = rain_wait = 0f.LerpInTime(0, 0, -1); // yield return break } @@ -83,7 +84,13 @@ void ApplyMaterial(FactObject root, Material new_mat) => } public static void HighlightFact(Fact startFact, FactObject.FactMaterials tmp_mat) - { + { + //this happens, but it should not! TODO: Fix Fact Hint creation + if (startFact == null) + { + Debug.Log("FEHLER! fact = null"); + return; + } if (startFact.Representation == null) return; FactObject selected_fact_obj = startFact.Representation.GetComponentInChildren<FactObject>(); @@ -97,7 +104,8 @@ public static void HighlightFact(Fact startFact, FactObject.FactMaterials tmp_ma ); } - public void HighlightWithFireworks(Fact fact) + //Highlight winning fact with fireworks. material is not used; + public void HighlightWithFireworks(Fact fact, FactObject.FactMaterials material) { while (rain_wait.MoveNext()) ; //stop rain @@ -107,7 +115,7 @@ public void HighlightWithFireworks(Fact fact) IEnumerator BlossomAndDie() { GameObject firework = GameObject.Instantiate - ( Fireworks_Animation + (Fireworks_Animation , fact.Representation.transform ); @@ -127,11 +135,13 @@ IEnumerator BlossomAndDie() } } - public void LetItRain(Fact startFact) + public void LetItRain(Fact startFact, Scroll.ScrollApplicationInfo info) { + //----------------- bool restart = !rain_wait.MoveNext(); - if (restart) { + if (restart) + { StopCoroutine(rain); StartCoroutine(rain = BlossomAndDie()); } diff --git a/Assets/Scripts/InventoryStuff/DisplayFacts.cs b/Assets/Scripts/InventoryStuff/DisplayFacts.cs index b077f7469b08622a5c1f2b9ae28396efe0f927ac..f8fbf04fde89851d153ce2012af9f25ef1da01fc 100644 --- a/Assets/Scripts/InventoryStuff/DisplayFacts.cs +++ b/Assets/Scripts/InventoryStuff/DisplayFacts.cs @@ -85,7 +85,7 @@ void Start() AddFactEvent.AddListener(AddFact); RemoveFactEvent.AddListener(RemoveFact); - AnimateExistingFactEvent.AddListener(AnimateFact); + //AnimateExistingFactEvent.AddListener(AnimateFact); } public void AddFact(Fact fact) { diff --git a/Assets/Scripts/Loading/Stage.cs b/Assets/Scripts/Loading/Stage.cs index 9d2ebd23d0f0348606f00b3931831beeddd28816..76713274249490dafb15fcc19373ae5064ae4b2c 100644 --- a/Assets/Scripts/Loading/Stage.cs +++ b/Assets/Scripts/Loading/Stage.cs @@ -438,7 +438,7 @@ public bool CheckSolved() { foreach (var hitlist in hits) foreach (var hit in hitlist) - AnimateExistingFactEvent.Invoke(factState[hit]); + AnimateExistingFactEvent.Invoke(factState[hit], FactObject.FactMaterials.Solution); player_record.solved = true; push_record(time_s); diff --git a/Assets/Scripts/StageStatic.cs b/Assets/Scripts/StageStatic.cs index c1427d5fa02974d05d47678f249e8049d8e92bfb..f0bdcbadb614d25d5a175a74dca2f37b414f3e93 100644 --- a/Assets/Scripts/StageStatic.cs +++ b/Assets/Scripts/StageStatic.cs @@ -194,17 +194,19 @@ public StageErrorStruct(bool category, bool id, bool name, bool description, boo /// <param name="gameObject"> which children will be checked</param> public static void SetMode(Mode mode, GameObject gameObject = null) { - gameObject ??= new GameObject(); + //gameObject ??= new GameObject(); // handle StageStatic.mode - switch (StageStatic.mode = mode) - { - case Mode.Play: - gameObject.SetActiveByTagRecursive("CreatorMode", false); - break; - case Mode.Create: - gameObject.SetActiveByTagRecursive("CreatorMode", true); - break; + if(gameObject != null) { + switch (StageStatic.mode = mode) + { + case Mode.Play: + gameObject.SetActiveByTagRecursive("CreatorMode", false); + break; + case Mode.Create: + gameObject.SetActiveByTagRecursive("CreatorMode", true); + break; + } } // handle stage mode