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.

35 lines
910 B

  1. using System;
  2. using UnityEngine;
  3. namespace UnityStandardAssets.Effects
  4. {
  5. public class Hose : MonoBehaviour
  6. {
  7. public float maxPower = 20;
  8. public float minPower = 5;
  9. public float changeSpeed = 5;
  10. public ParticleSystem[] hoseWaterSystems;
  11. public Renderer systemRenderer;
  12. private float m_Power;
  13. // Update is called once per frame
  14. private void Update()
  15. {
  16. m_Power = Mathf.Lerp(m_Power, Input.GetMouseButton(0) ? maxPower : minPower, Time.deltaTime*changeSpeed);
  17. if (Input.GetKeyDown(KeyCode.Alpha1))
  18. {
  19. systemRenderer.enabled = !systemRenderer.enabled;
  20. }
  21. foreach (var system in hoseWaterSystems)
  22. {
  23. system.startSpeed = m_Power;
  24. system.enableEmission = (m_Power > minPower*1.1f);
  25. }
  26. }
  27. }
  28. }