You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1013 B
38 lines
1013 B
3 years ago
|
using System;
|
||
|
using UnityEngine;
|
||
|
|
||
|
|
||
|
namespace UnityStandardAssets.Effects
|
||
|
{
|
||
|
public class Hose : MonoBehaviour
|
||
|
{
|
||
|
public float maxPower = 20;
|
||
|
public float minPower = 5;
|
||
|
public float changeSpeed = 5;
|
||
|
public ParticleSystem[] hoseWaterSystems;
|
||
|
public Renderer systemRenderer;
|
||
|
|
||
|
private float m_Power;
|
||
|
|
||
|
|
||
|
// Update is called once per frame
|
||
|
private void Update()
|
||
|
{
|
||
|
m_Power = Mathf.Lerp(m_Power, Input.GetMouseButton(0) ? maxPower : minPower, Time.deltaTime*changeSpeed);
|
||
|
|
||
|
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||
|
{
|
||
|
systemRenderer.enabled = !systemRenderer.enabled;
|
||
|
}
|
||
|
|
||
|
foreach (var system in hoseWaterSystems)
|
||
|
{
|
||
|
ParticleSystem.MainModule mainModule = system.main;
|
||
|
mainModule.startSpeed = m_Power;
|
||
|
var emission = system.emission;
|
||
|
emission.enabled = (m_Power > minPower*1.1f);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|