98 lines
2.3 KiB
C#
98 lines
2.3 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-11-03
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "SkillWheelwind" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
public class SkillWheelwind : MonoBehaviour
|
|
{
|
|
public Transform tornado;
|
|
|
|
private int _index;
|
|
private int _lastIndex = -1;
|
|
|
|
private float _startTime;
|
|
private float _finishTime = 1.6f;
|
|
|
|
private Collider _collider;
|
|
|
|
private int _tornadoRatio;
|
|
private int _tornadoAmount;
|
|
|
|
public void SetTornado(int ratio, int amount)
|
|
{
|
|
_tornadoRatio = ratio;
|
|
_tornadoAmount = amount;
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
_collider = this.GetComponent<Collider>();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
this.transform.localScale = Vector3.one * 0.3f;
|
|
_collider.isTrigger = true;
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
Vector3 localScale = transform.localScale;
|
|
if (localScale.x > 1f)
|
|
{
|
|
}
|
|
|
|
if (localScale.x < 1.8f)
|
|
{
|
|
localScale += Vector3.one * (4f * Time.deltaTime);
|
|
this.transform.localScale = localScale;
|
|
}
|
|
else
|
|
{
|
|
this.transform.localScale = Vector3.one * 1.8f;
|
|
}
|
|
|
|
if (_startTime > _finishTime)
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
this.transform.localScale = Vector3.one * 0.3f;
|
|
_startTime = 0f;
|
|
}
|
|
_startTime += Time.deltaTime;
|
|
_index = (int)(_startTime * 16f);
|
|
_index %= 4;
|
|
|
|
if (_index != _lastIndex)
|
|
{
|
|
if (_tornadoRatio > 0 && _index == 1 && _tornadoRatio > GlobalUtils.RndHundred)
|
|
{
|
|
Vector3 dir = Random.insideUnitCircle;
|
|
dir.z = dir.y;
|
|
dir.y = 0;
|
|
dir.Normalize();
|
|
dir *= 0.05f;
|
|
var pos = this.transform.TransformPoint(dir);
|
|
pos.y = 0f;
|
|
var rot = Quaternion.LookRotation(dir);
|
|
var skill_tornado = Object.Instantiate(tornado, pos, rot);
|
|
//skill_tornado.localScale = Vector3.one * 0.3f;
|
|
skill_tornado.GetComponent<Rigidbody>().mass = this.GetComponent<Rigidbody>().mass * 0.6f;
|
|
}
|
|
|
|
_collider.enabled = _index == 0;// (_index == 0 || _index == 3);
|
|
_lastIndex = _index;
|
|
}
|
|
}
|
|
}
|
|
}
|