// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-02 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using UnityEngine; namespace G { /// /// 剑舞 /// [RequireComponent(typeof(SkillBase))] public class SkillSwordDance : MonoBehaviour { /// /// /// public float hitrate = 0.2f; /// /// /// public float startDelay = 0.1f; /// /// /// public float finishDelay = 0.1f; /// /// /// public float duration = 0.9f; private Collider _collider; private float _offset; private float _time; private float _curDuration; private float _curHitrate; private void Awake() { _collider = this.GetComponent(); } private void OnEnable() { _offset = 0f; _time = startDelay; var sp1 = GetComponent().special1; if (sp1 > 0) { _curHitrate = 0.9f / (5f + sp1); _curDuration = duration + sp1 * 0.2f; } else { _curDuration = duration; } } private void DanceHit() { _collider.enabled = false; _collider.enabled = true; } private void FixedUpdate() { _offset += Time.deltaTime; if (_offset < _curDuration) { _time -= Time.deltaTime; if (_time <= 0f) { _time = hitrate; DanceHit(); } } else if (_offset < _curDuration + finishDelay) { _collider.enabled = false; } else { _collider.enabled = false; this.transform.position = Vector3.one * 38f; this.gameObject.SetActive(false); } } } }