86 lines
1.7 KiB
C#
86 lines
1.7 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "SplashPetSword" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
/// <summary>
|
|
/// 剑舞
|
|
/// </summary>
|
|
public class SplashPetSword : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public float hitrate = 0.2f;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public float startDelay = 0.1f;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public float finishDelay = 0.1f;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public float duration = 1f;
|
|
|
|
private Collider _collider;
|
|
private float _offset;
|
|
private float _time;
|
|
private float _curDuration;
|
|
|
|
private void Awake()
|
|
{
|
|
_collider = this.GetComponent<Collider>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_offset = 0f;
|
|
_time = startDelay;
|
|
_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);
|
|
}
|
|
}
|
|
}
|
|
}
|