From 5f01d5b9def820782a8f046ba3c418f63fb96822 Mon Sep 17 00:00:00 2001 From: unknown <john.schihada@hotmail.com> Date: Fri, 15 Jan 2021 22:56:49 +0100 Subject: [PATCH] Fixed bug occuring when assigning fact during hint-animation + Set default of selected scroll to OppositeLen --- .../Scenes/Release/TreeWorld_Release_02.unity | 5 +++++ Assets/Scenes/TreeWorld.unity | 5 +++++ .../InteractionEngine/ImageHintAnimation.cs | 21 +++++++++++++++---- .../Scripts/InventoryStuff/DisplayScrolls.cs | 9 +++++++- Assets/Scripts/InventoryStuff/DropHandling.cs | 4 ++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Assets/Scenes/Release/TreeWorld_Release_02.unity b/Assets/Scenes/Release/TreeWorld_Release_02.unity index 303118f9..238adf0d 100644 --- a/Assets/Scenes/Release/TreeWorld_Release_02.unity +++ b/Assets/Scenes/Release/TreeWorld_Release_02.unity @@ -44005,6 +44005,11 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 75 objectReference: {fileID: 0} + - target: {fileID: 293934904814280933, guid: b996060e27da25c498842defc1996d84, + type: 3} + propertyPath: preferredStartScrollName + value: OppositeLen + objectReference: {fileID: 0} - target: {fileID: 293934904949885392, guid: b996060e27da25c498842defc1996d84, type: 3} propertyPath: m_AnchoredPosition.y diff --git a/Assets/Scenes/TreeWorld.unity b/Assets/Scenes/TreeWorld.unity index 5c3aaff2..a9583721 100644 --- a/Assets/Scenes/TreeWorld.unity +++ b/Assets/Scenes/TreeWorld.unity @@ -44328,6 +44328,11 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 150 objectReference: {fileID: 0} + - target: {fileID: 293934904814280933, guid: b996060e27da25c498842defc1996d84, + type: 3} + propertyPath: preferredStartScrollName + value: OppositeLen + objectReference: {fileID: 0} - target: {fileID: 293934904949885392, guid: b996060e27da25c498842defc1996d84, type: 3} propertyPath: m_AnchoredPosition.y diff --git a/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs b/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs index 5ec730c4..a3c549b5 100644 --- a/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs +++ b/Assets/Scripts/InteractionEngine/ImageHintAnimation.cs @@ -5,7 +5,7 @@ public class ImageHintAnimation : MonoBehaviour { public Image imageToChange; - private Color imageToChangeDefaultColor; + public Color imageToChangeDefaultColor { get; set; } private Color animationStartColor; private Color animationEndColor; @@ -42,13 +42,19 @@ public void AnimationTrigger() } } + public void ResetAnimation() + { + if (imageToChange != null) + { + Reset(); + } + } + private void Animate() { if (timer >= animateDuration) { - animating = false; - timer = 0; - imageToChange.color = imageToChangeDefaultColor; + Reset(); } else { @@ -57,6 +63,13 @@ private void Animate() } + private void Reset() + { + animating = false; + timer = 0; + imageToChange.color = imageToChangeDefaultColor; + } + private void updateAnimationParameters() { animationStartColor = globalSettings.hintAnimationStartColor; animationEndColor = globalSettings.hintAnimationEndColor; diff --git a/Assets/Scripts/InventoryStuff/DisplayScrolls.cs b/Assets/Scripts/InventoryStuff/DisplayScrolls.cs index 32227f0a..e5823c58 100644 --- a/Assets/Scripts/InventoryStuff/DisplayScrolls.cs +++ b/Assets/Scripts/InventoryStuff/DisplayScrolls.cs @@ -7,6 +7,8 @@ public class DisplayScrolls : MonoBehaviour { + public string preferredStartScrollName; + public List<Scroll> scrolls; public GameObject[] ScrollButtons; public GameObject ScrollPrefab; @@ -98,6 +100,11 @@ void BuildScrolls(string jsonString) obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = this.scrolls[i].label; ScrollButtons[i] = obj; } - this.DetailScreen.GetComponent<ScrollDetails>().setScroll(this.scrolls[0]); + + Scroll preferredStartScroll = this.scrolls.Find(x => x.label.Equals(preferredStartScrollName)); + if(preferredStartScroll != null) + this.DetailScreen.GetComponent<ScrollDetails>().setScroll(preferredStartScroll); + else + this.DetailScreen.GetComponent<ScrollDetails>().setScroll(this.scrolls[0]); } } diff --git a/Assets/Scripts/InventoryStuff/DropHandling.cs b/Assets/Scripts/InventoryStuff/DropHandling.cs index 4674a0b9..39c2e70b 100644 --- a/Assets/Scripts/InventoryStuff/DropHandling.cs +++ b/Assets/Scripts/InventoryStuff/DropHandling.cs @@ -16,6 +16,10 @@ public void OnDrop(PointerEventData eventData){ Destroy(current); current = Instantiate(eventData.pointerDrag,Vector3.zero, Quaternion.identity); + //Set imageToChangeDefaultColor of current: Fix so that current won't take the color + //the dragged item was having during animation + current.GetComponent<ImageHintAnimation>().imageToChangeDefaultColor = eventData.pointerDrag.GetComponent<ImageHintAnimation>().imageToChangeDefaultColor; + current.GetComponent<ImageHintAnimation>().ResetAnimation(); current.transform.SetParent(gameObject.transform, false); -- GitLab