diff --git a/Game/Assets/Scripts/DropletMovement.cs b/Game/Assets/Scripts/DropletMovement.cs index 5b7c04e..14a201d 100644 --- a/Game/Assets/Scripts/DropletMovement.cs +++ b/Game/Assets/Scripts/DropletMovement.cs @@ -87,9 +87,18 @@ public class DropletMovement : MonoBehaviour if (isDashing || isDropping) { return; - } + } // was here before - rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y); + float windForce = 0f; + + if (WindManager.Instance != null) + { + windForce = WindManager.Instance.CurrentWindForce; + } + + rb.linearVelocity = new Vector2(movement.x * moveSpeed + windForce, rb.linearVelocity.y); + + //used to be rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y); } private void OnTriggerEnter2D(Collider2D other) diff --git a/Game/Assets/Scripts/WindManager.cs b/Game/Assets/Scripts/WindManager.cs new file mode 100644 index 0000000..89f95ce --- /dev/null +++ b/Game/Assets/Scripts/WindManager.cs @@ -0,0 +1,47 @@ +using UnityEngine; +using System.Collections; + +public class WindManager : MonoBehaviour +{ + public static WindManager Instance; + + public float windStrength = 5f; + public float windDuration = 10f; + + public float minTimeBetweenWind = 5f; + public float maxTimeBetweenWind = 20f; + + public float CurrentWindForce { get; private set; } + + void Awake() + { + Instance = this; + } + + void Start() + { + StartCoroutine(WindRoutine()); + } + + IEnumerator WindRoutine() + { + while (true) + { + float waitTime = Random.Range( + minTimeBetweenWind, + maxTimeBetweenWind + ); + + yield return new WaitForSeconds(waitTime); + + CurrentWindForce = + Random.value < 0.5f + ? -windStrength + : windStrength; + + yield return new WaitForSeconds(windDuration); + + CurrentWindForce = 0f; + } + } +} \ No newline at end of file diff --git a/Game/Assets/Scripts/WindManager.cs.meta b/Game/Assets/Scripts/WindManager.cs.meta new file mode 100644 index 0000000..35c073c --- /dev/null +++ b/Game/Assets/Scripts/WindManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 77a372e261eab9a4b9b6cf05e6c6e576 \ No newline at end of file