2025-05-18 01:04:31 +08:00

85 lines
1.9 KiB
C#

// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "Sword_Extreme" company="Kimch"></copyright>
// <summary></summary>
// ***********************************************************************
using UnityEngine;
namespace G
{
public class Sword_Extreme : MonoBehaviour
{
private float _delay;
private bool _efOn;
private Transform _cha1;
private Collider _collider;
private Vector3 _startPos;
private void Awake()
{
_cha1 = GameObject.FindWithTag("Player").transform;
_collider = this.GetComponent<Collider>();
}
private void OnEnable()
{
_delay = 1.5f;
_efOn = false;
this.gameObject.layer = GameLayer.StunAttack;
_collider.enabled = true;
_startPos = transform.position;
}
public void SetPower(int _amount)
{
this.GetComponent<Rigidbody>().mass = _amount * 0.4f;
}
private void ColliderOn()
{
_collider.enabled = false;
_collider.enabled = true;
}
private void Update()
{
_delay -= Time.deltaTime;
if (_delay < -1.5f)
{
this.GetComponent<ParticleSystem>().Clear();
this.gameObject.SetActive(false);
}
else if (_delay < -1f)
{
CancelInvoke();
}
else if (_delay < 0f)
{
transform.position = Vector3.Lerp(transform.position, _cha1.position + Vector3.up * 0.2f, Time.deltaTime * 3.5f);
if (!_efOn)
{
transform.position = _startPos;
this.gameObject.layer = GameLayer.RiseupAttack;
InvokeRepeating(nameof(ColliderOn), 0.01f, 0.1f);
_efOn = true;
this.GetComponent<ParticleSystem>().Play();
}
}
else
{
transform.position = _cha1.position;
}
}
}
}