91 lines
2.1 KiB
C#
91 lines
2.1 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "SkillMirage" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
/// <summary>
|
|
/// 幻影
|
|
/// </summary>
|
|
[RequireComponent(typeof(SkillBase))]
|
|
public class SkillMirage : MonoBehaviour
|
|
{
|
|
private float _delayFinish;
|
|
|
|
private Vector3 _bounceScale = new Vector3(1f, 1f, 2f);
|
|
|
|
private Vector3 _startScale = new Vector3(1f, 1f, 0.5f);
|
|
|
|
private Vector3 _position;
|
|
|
|
private float _dropDown;
|
|
|
|
private bool _bounce;
|
|
|
|
private bool _move;
|
|
|
|
private Vector3 _direction;
|
|
|
|
private void OnEnable()
|
|
{
|
|
transform.localScale = _startScale;
|
|
_dropDown = 0.2f;
|
|
_move = false;
|
|
_bounce = false;
|
|
_delayFinish = 0f;
|
|
_position = transform.position;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (_move)
|
|
{
|
|
_position += _direction * Time.deltaTime * 1.5f;
|
|
if (!_bounce)
|
|
{
|
|
_dropDown -= Time.deltaTime * 3f;
|
|
_direction = transform.forward + Vector3.up * _dropDown;
|
|
transform.rotation = Quaternion.LookRotation(_direction);
|
|
}
|
|
else
|
|
{
|
|
transform.localScale = Vector3.Lerp(transform.localScale, _bounceScale, Time.deltaTime * 3f);
|
|
}
|
|
if (_position.y < 0f)
|
|
{
|
|
_position.y = 0f;
|
|
_dropDown = 0.4f;
|
|
_bounce = true;
|
|
_direction.y = 0f;
|
|
_direction = (_direction + Vector3.up * 0.3f) * 2f;
|
|
transform.rotation = Quaternion.LookRotation(_direction);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
transform.localScale = Vector3.Lerp(transform.localScale, _bounceScale, Time.deltaTime * 5f);
|
|
}
|
|
transform.position = _position;
|
|
_delayFinish += Time.deltaTime;
|
|
if (_delayFinish > 1f)
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
_delayFinish = 0f;
|
|
}
|
|
else if (_delayFinish > 0.1f)
|
|
{
|
|
_move = true;
|
|
}
|
|
}
|
|
}
|
|
}
|