2025-05-18 01:04:31 +08:00

84 lines
1.6 KiB
C#

// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "Bullet_particle" company="Kimch"></copyright>
// <summary></summary>
// ***********************************************************************
using UnityEngine;
namespace G
{
/// <summary>
///
/// </summary>
public class Bullet_particle : MonoBehaviour
{
public float start_delay;
public float active_delay;
public float disable_delay;
private ParticleSystem _particle;
private float _currentTime;
private Collider _collider;
private bool _colliderExist;
private void Awake()
{
_particle = this.GetComponent<ParticleSystem>();
_collider = this.GetComponent<Collider>();
if (_collider)
{
_colliderExist = true;
}
this.gameObject.SetActive(false);
}
private void OnEnable()
{
_currentTime = 0f;
if (_particle)
_particle.Stop();
if (_colliderExist)
{
_collider.enabled = false;
}
}
private void Update()
{
_currentTime += Time.deltaTime;
if (_currentTime >= disable_delay)
{
this.gameObject.SetActive(false);
}
if (_currentTime >= active_delay)
{
if (_particle)
_particle.Stop();
if (_colliderExist)
{
_collider.enabled = false;
}
}
else if (_currentTime >= start_delay)
{
if (_particle)
_particle.Play();
if (_colliderExist)
{
_collider.enabled = true;
}
}
}
}
}