// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-02 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using UnityEngine; namespace G { /// /// 守护弹道 /// public class BulletPet1 : MonoBehaviour { /// /// /// public float bullet_speed = 2f; /// /// /// public float bullet_delay = 0.5f; private GameObject _particleFx; private float _delay; private void Awake() { this.gameObject.SetActive(false); if (transform.childCount > 0) { _particleFx = transform.GetChild(0).gameObject; } } private void OnEnable() { _delay = bullet_delay; if (_particleFx) { _particleFx.SetActive(false); } } private void Update() { if (_delay > 0f) { _delay -= Time.deltaTime; if (_delay <= 0f) { if (_particleFx) { _particleFx.SetActive(true); } } else return; } this.transform.Translate(new Vector3(0f, 0f, bullet_speed * Time.deltaTime)); Vector3 position = transform.position; if (position.y < 0f) { EntityPet.Instance.AttackFinish(); this.gameObject.SetActive(false); } } } }