Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/WaterDropsRainMy.cs
2026-02-21 16:45:37 +08:00

71 lines
1.5 KiB
C#

using System.Collections.Generic;
using BitStrap;
using UltimateWater;
using UltimateWater.Utils;
using UnityEngine;
public class WaterDropsRainMy : MonoBehaviour
{
[Range(0f, 1f)]
public float Intensity = 0.1f;
[MinMaxRange(0f, 2f)]
public MinMaxRange Size = new MinMaxRange
{
MinValue = 0.3f,
MaxValue = 0.5f
};
[MinMaxRange(0f, 8f)]
public MinMaxRange Life = new MinMaxRange
{
MinValue = 0.5f,
MaxValue = 2f
};
public float Force = 5f;
public List<WaterRaindropsIME> _Simulations = new List<WaterRaindropsIME>();
private void Update()
{
if (Time.deltaTime != 0f && Random.Range(0f, 1f) < Intensity)
{
SpawnRandom(1);
}
}
[Button]
public void SpawnRandom()
{
SpawnRandom(1);
}
[Button]
public void SpawnRandomMany()
{
SpawnRandom(20);
}
public void SpawnRandom(int amount)
{
if (_Simulations.Count == 0 || !_Simulations[0].enabled)
{
return;
}
WaterRaindropsIME waterRaindropsIME = _Simulations[0];
for (int i = 0; i < amount; i++)
{
Vector3 velocity = -Vector3.up * Force;
float num = Size.Random();
Vector2 vector = new Vector2(Random.Range(0f, 1f), Random.Range(0f, 1f));
waterRaindropsIME.Spawn(velocity, num, Life.Random(), vector.x, vector.y);
for (int j = 0; j < Random.Range(0, 20); j++)
{
Vector2 vector2 = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * 0.05f;
waterRaindropsIME.Spawn(Vector3.zero, num * 0.2f, 0.5f + Random.Range(0f, 0.4f), vector.x + vector2.x, vector.y + vector2.y);
}
}
}
}