// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-02 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using UnityEngine; namespace G { public class SkillFincanon : MonoBehaviour { public Transform beam; private float _delay; private CapsuleCollider _beamCollider; private Vector3 _originScale = new Vector3(1f, 1f, 0.1f); private bool _state; private void Awake() { base.GetComponent()["wait"].speed = 1.2f; base.GetComponent()["create"].speed = 0.25f; base.GetComponent()["destroy"].speed = 0.25f; base.GetComponent()["beam"].speed = 0.8f; beam.gameObject.SetActive(false); _beamCollider = (CapsuleCollider)beam.GetComponent(); } private void Start() { beam.GetComponent().mass = base.GetComponent().mass; } private void OnEnable() { transform.localScale = Vector3.one * 1.5f; _state = false; beam.localScale = Vector3.zero; _delay = 0f; _beamCollider.enabled = false; _beamCollider.height = 0f; InvokeRepeating(nameof(Shoot), 0.1f, 0.2f); beam.gameObject.SetActive(true); base.GetComponent().Play("wait"); } public void Shoot() { if (_delay > 0.5f) { _beamCollider.enabled = false; _beamCollider.enabled = true; } } private void Update() { _delay += Time.deltaTime; if (_delay > 3.4f) { base.gameObject.SetActive(false); transform.localScale = Vector3.zero; beam.gameObject.SetActive(false); CancelInvoke(nameof(Shoot)); } else if (_delay > 2.2f) { base.GetComponent().Play("destroy"); if (!_state) { _beamCollider.enabled = false; _state = true; } beam.localScale = Vector3.Lerp(beam.localScale, Vector3.forward, Time.deltaTime * 15f); } else if (_delay > 1f) { beam.localScale = Vector3.Lerp(beam.localScale, Vector3.one, Time.deltaTime * 15f); base.GetComponent().Play("beam"); } else if (_delay > 0.8f) { _beamCollider.height = Mathf.Lerp(_beamCollider.height, 0.7f, Time.deltaTime * 6f); beam.localScale = Vector3.Lerp(beam.localScale, _originScale, Time.deltaTime * 6f); _state = false; } else if (_delay > 0.2f) { if (!_state) { transform.parent = null; _state = true; } base.GetComponent().Play("create"); } } } }