147 lines
3.3 KiB
C#
147 lines
3.3 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "SkillDragonHead" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[RequireComponent(typeof(SkillBase))]
|
|
public class SkillDragonHead : MonoBehaviour
|
|
{
|
|
public Transform pt_body;
|
|
|
|
public ParticleSystem waterPrs;
|
|
|
|
public Transform zwater;
|
|
|
|
public Transform endFx;
|
|
|
|
public AudioClip snd_water;
|
|
|
|
public AudioClip snd_bite;
|
|
|
|
|
|
private SphereCollider _collider;
|
|
private Animation _animation;
|
|
private float _activeDelay;
|
|
private int _impact;
|
|
private float _moveSpeed;
|
|
private SkillBase _skillBase;
|
|
private bool _lock;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
_skillBase = this.GetComponent<SkillBase>();
|
|
|
|
_collider = this.GetComponent<SphereCollider>();
|
|
_animation = this.GetComponent<Animation>();
|
|
_animation["bite_ready"].speed = 0.2f;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_collider.enabled = false;
|
|
_lock = true;
|
|
var em = waterPrs.emission;
|
|
em.enabled = true;
|
|
_animation.Play("bite_ready");
|
|
var animState = _animation.PlayQueued("bite");
|
|
animState.speed = 0.15f;
|
|
animState = _animation.PlayQueued("bite_i");
|
|
animState.speed = 0.25f;
|
|
|
|
_moveSpeed = 0.8f;
|
|
_impact = 0;
|
|
pt_body.gameObject.SetActive(true);
|
|
zwater.localScale = Vector3.one;// * 0.32f;
|
|
|
|
endFx.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (_animation.IsPlaying("bite_i"))
|
|
{
|
|
if (_impact != 2)
|
|
{
|
|
_skillBase.damage *= 4;
|
|
|
|
_collider.center = Vector3.forward * 0.1f;
|
|
_collider.enabled = true;
|
|
_impact = 2;
|
|
_activeDelay = 0f;
|
|
endFx.gameObject.SetActive(true);
|
|
_skillBase.PlaySound(snd_bite);
|
|
}
|
|
else
|
|
{
|
|
_activeDelay += Time.deltaTime;
|
|
if (_activeDelay > 3f)
|
|
{
|
|
_collider.enabled = false;
|
|
this.gameObject.SetActive(false);
|
|
this.transform.position = Vector3.one * 16f;
|
|
|
|
pt_body.gameObject.SetActive(false);
|
|
_activeDelay = 0f;
|
|
}
|
|
else if (_activeDelay > 2f)
|
|
{
|
|
zwater.localScale -= Vector3.right * (Time.deltaTime * 0.3f);
|
|
}
|
|
else if (_activeDelay > 1.2f && _lock)
|
|
{
|
|
_lock = !_lock;
|
|
var em = waterPrs.emission;
|
|
em.enabled = false;
|
|
}
|
|
else if (_activeDelay > 0.5f)
|
|
{
|
|
_collider.enabled = false;
|
|
}
|
|
}
|
|
this.transform.Translate(Vector3.forward * (Time.deltaTime * 0.1f));
|
|
}
|
|
else if (_animation.IsPlaying("bite"))
|
|
{
|
|
if (_impact != 1)
|
|
{
|
|
_skillBase.PlaySound(snd_water);
|
|
|
|
_activeDelay = 0f;
|
|
_collider.center = Vector3.zero;
|
|
_collider.enabled = true;
|
|
_impact = 1;
|
|
}
|
|
else
|
|
{
|
|
_activeDelay += Time.deltaTime;
|
|
if (_activeDelay > 0.5f)
|
|
{
|
|
_collider.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
else if (_animation.IsPlaying("bite_ready"))
|
|
{
|
|
this.transform.Translate(Vector3.forward * (Time.deltaTime * _moveSpeed));
|
|
}
|
|
}
|
|
}
|
|
} |