MoveBullet.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using UnityEngine;
  3. public class MoveBullet : MonoBehaviour
  4. {
  5. private void Start()
  6. {
  7. }
  8. private void Update()
  9. {
  10. if (this.newParticle != null && Time.timeSinceLevelLoad > 3f)
  11. {
  12. this.AddNewParticle();
  13. this.newParticle = null;
  14. }
  15. if (this.local)
  16. {
  17. base.transform.Translate(new Vector3(this.translationSpeedX, this.translationSpeedY, this.translationSpeedZ) * Time.deltaTime);
  18. }
  19. if (!this.local)
  20. {
  21. base.transform.Translate(new Vector3(this.translationSpeedX, this.translationSpeedY, this.translationSpeedZ) * Time.deltaTime, Space.World);
  22. }
  23. }
  24. private void AddNewParticle()
  25. {
  26. UnityEngine.Object.Destroy(base.gameObject.GetComponentInChildren<ParticleSystem>());
  27. UnityEngine.Object.Destroy(UnityEngine.Object.Instantiate<GameObject>(this.newParticle, base.transform.position, base.transform.rotation), this.deadTime);
  28. UnityEngine.Object.Destroy(base.gameObject, this.deadTime);
  29. }
  30. public float translationSpeedX;
  31. public float translationSpeedY = 1f;
  32. public float translationSpeedZ;
  33. public float deadTime = 4f;
  34. private bool local = true;
  35. public GameObject newParticle;
  36. }