diff --git a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs index 828ba181..dfd7fb44 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/AIRework/HomeOwnerAI.cs @@ -36,9 +36,10 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework [NonSerialized] public IEnumerable patrolPointPool; + private Transform transform; + public void Reset() { - Transform transform = GetComponent(); StateMachine machine = GetScript(); if (transform && machine) { @@ -68,11 +69,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework AudioHandler.audioClipHandlers["HO_footsteps"] = SHADE.Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps"); patrolPointPool = patrolPointParent.GetComponentsInChildren(); - Transform transform = GetComponent(); - if (transform) - { - startPos = transform.GlobalPosition; - } + transform = GetComponent(); atk = false; @@ -81,6 +78,8 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework protected override void start() { //attackHitbox.SetActive(false); + if (transform) + startPos = transform.GlobalPosition; } diff --git a/Assets/Scripts/UI/SC_SingleScaleBounce.cs b/Assets/Scripts/UI/SC_SingleScaleBounce.cs index d0eb4b66..b0833de6 100644 --- a/Assets/Scripts/UI/SC_SingleScaleBounce.cs +++ b/Assets/Scripts/UI/SC_SingleScaleBounce.cs @@ -7,67 +7,67 @@ using System.Threading.Tasks; namespace SHADE_Scripting.UI { - public class SingleScaleBounce: Script + public class SingleScaleBounce : Script + { + [NonSerialized] + TweenThread thread; + + [NonSerialized] + Vector3 defaultScale; + + public float durationUp = 0.15f; + public float durationDown = 0.3f; + + public float scaleSize = 1.2f; + + [NonSerialized] + private bool scaleUp = false; + + private Transform trans; + + protected override void awake() { - [NonSerialized] - TweenThread thread; - - [NonSerialized] - Vector3 defaultScale; - - public float durationUp = 0.15f; - public float durationDown = 0.3f; - - public float scaleSize = 1.2f; - - [NonSerialized] - private bool scaleUp = false; - - protected override void awake() - { - Transform trans = GetComponent(); - if(trans != null) - { - defaultScale = trans.LocalScale; - } - - } - - protected override void start() - { - thread = TweenManager.CreateTweenThread(0.0f,1.0f,1.0f,EASING_METHOD.EASE_IN_SINE); - } - - - protected override void update() - { - if(scaleUp) - { - if(thread.IsCompleted()) - { - scaleUp = false; - thread.duration = durationDown; - thread.ResetInvert(); - } - } - - Transform trans = GetComponent(); - if(trans != null) - { - trans.LocalScale = defaultScale * thread.GetValue(); - } - - - } - - - public void ScaleBounceOnce() - { - scaleUp = true; - thread.duration = durationUp; - thread.Reset(1.0f, scaleSize); - } - + trans = GetComponent(); + if (trans != null) + { + defaultScale = trans.LocalScale; + } } + + protected override void start() + { + if(thread != null) + thread = TweenManager.CreateTweenThread(0.0f, 1.0f, 1.0f, EASING_METHOD.EASE_IN_SINE); + } + + + protected override void update() + { + if (scaleUp) + { + if (thread != null && thread.IsCompleted()) + { + scaleUp = false; + thread.duration = durationDown; + thread.ResetInvert(); + } + } + + if (trans && thread != null) + trans.LocalScale = defaultScale * thread.GetValue(); + } + + public void ScaleBounceOnce() + { + scaleUp = true; + if (thread != null) + { + thread.duration = durationUp; + thread.Reset(1.0f, scaleSize); + } + } + + + } }