From 0899e0eb5dc2b6ea2e2a447a866df7e2c84abd73 Mon Sep 17 00:00:00 2001 From: cemt1363 Date: Sat, 6 Jun 2026 16:31:37 +0200 Subject: [PATCH] wind!! --- Game/Assets/Scenes/0_MainScene.unity | 49 +++++++++++++++++++++++++ Game/Assets/Scripts/DropletMovement.cs | 13 ++++++- Game/Assets/Scripts/WindManager.cs | 47 ++++++++++++++++++++++++ Game/Assets/Scripts/WindManager.cs.meta | 2 + 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 Game/Assets/Scripts/WindManager.cs create mode 100644 Game/Assets/Scripts/WindManager.cs.meta diff --git a/Game/Assets/Scenes/0_MainScene.unity b/Game/Assets/Scenes/0_MainScene.unity index f2cbd64..6aab5f6 100644 --- a/Game/Assets/Scenes/0_MainScene.unity +++ b/Game/Assets/Scenes/0_MainScene.unity @@ -3224,6 +3224,54 @@ Transform: m_CorrespondingSourceObject: {fileID: 7329357223832181834, guid: 2104fa77ddd078b48b1f646a4be3ccf8, type: 3} m_PrefabInstance: {fileID: 2034602594} m_PrefabAsset: {fileID: 0} +--- !u!1 &2060894012 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2060894014} + - component: {fileID: 2060894013} + m_Layer: 0 + m_Name: WindManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &2060894013 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2060894012} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 77a372e261eab9a4b9b6cf05e6c6e576, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::WindManager + windStrength: 2 + windDuration: 10 + minTimeBetweenWind: 5 + maxTimeBetweenWind: 20 +--- !u!4 &2060894014 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2060894012} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.7161, y: -1.98892, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &2090136205 stripped Transform: m_CorrespondingSourceObject: {fileID: 33410884287286606, guid: 5e99c7748f96ea543ad4882124711a08, type: 3} @@ -3796,3 +3844,4 @@ SceneRoots: - {fileID: 1681788161} - {fileID: 1445156949} - {fileID: 750131492} + - {fileID: 2060894014} diff --git a/Game/Assets/Scripts/DropletMovement.cs b/Game/Assets/Scripts/DropletMovement.cs index 92488c7..49dd0df 100644 --- a/Game/Assets/Scripts/DropletMovement.cs +++ b/Game/Assets/Scripts/DropletMovement.cs @@ -109,9 +109,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