123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using UnityEngine;
- using System.Collections;
- public class SimpleShootingScript : MonoBehaviour
- {
- public int m_ShootSpeed = 15;
- private float mLightOffTime;
- public ParticleSystem[] m_VelocityShootParticles;
- public ParticleSystem[] m_OtherParticles;
- public Light m_ShootLight;
- private bool ShootOn;
- public GameObject ShootFX;
- public Transform m_ShootSound;
- void Start()
- {
- foreach (ParticleSystem i in m_VelocityShootParticles)
- {
- i.GetComponent<ParticleSystem>().emissionRate = m_ShootSpeed;
- }
- }
- void Update()
- {
- if (Input.GetButton("Fire1"))
- {
- //ShootFX.SetActive(true);
- ShootNow();
- foreach (ParticleSystem i in m_VelocityShootParticles)
- {
- i.GetComponent<ParticleSystem>().enableEmission = true;
- }
- foreach (ParticleSystem i in m_OtherParticles)
- {
- i.GetComponent<ParticleSystem>().enableEmission = true;
- }
- }
- else
- {
- //ShootFX.SetActive(false);
- foreach (ParticleSystem i in m_VelocityShootParticles)
- {
- i.GetComponent<ParticleSystem>().enableEmission = false;
- }
- foreach (ParticleSystem i in m_OtherParticles)
- {
- i.GetComponent<ParticleSystem>().enableEmission = false;
- }
- }
- }
- public void ShootNow()
- {
- if (mLightOffTime < Time.time)
- {
- Instantiate(m_ShootSound, ShootFX.transform.position,ShootFX.transform.rotation);
- m_ShootLight.enabled = !m_ShootLight.enabled;
- mLightOffTime = Time.time + 1.0f/ (m_ShootSpeed * 2);
- }
- }
- }
|