Merge branch 'main' of https://github.com/orsolya-st/gamejam_050626
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77a372e261eab9a4b9b6cf05e6c6e576
|
||||
Reference in New Issue
Block a user