139 lines
3.1 KiB
C#
139 lines
3.1 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2020-08-28
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "SkillBird" company="Kimch"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
namespace G
|
|||
|
{
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
[RequireComponent(typeof(SkillBird))]
|
|||
|
public class SkillBird : MonoBehaviour
|
|||
|
{
|
|||
|
private Collider _collider;
|
|||
|
private Animation _animation;
|
|||
|
|
|||
|
private Vector3 _targetPos;
|
|||
|
|
|||
|
private float _attackDelay;
|
|||
|
private int _attackCount;
|
|||
|
|
|||
|
private Vector3 _edgePos;
|
|||
|
|
|||
|
private Vector3 _rndPos;
|
|||
|
|
|||
|
private Vector3 _direction;
|
|||
|
|
|||
|
private Transform _cha1;
|
|||
|
|
|||
|
private bool _attack;
|
|||
|
|
|||
|
private bool _flyStart;
|
|||
|
|
|||
|
public Transform pt_leaf;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
_animation = GetComponent<Animation>();
|
|||
|
_animation["appear"].speed = 2.2f;
|
|||
|
_animation["fly_chosun"].speed = 0.2f;
|
|||
|
_collider = GetComponent<Collider>();
|
|||
|
_collider.enabled = false;
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
_cha1 = GameObject.FindWithTag("Player").transform;
|
|||
|
}
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
_animation["appear"].speed = 0f;
|
|||
|
_animation.Play("appear");
|
|||
|
AnimationState animationState = _animation.PlayQueued("fly_chosun");
|
|||
|
animationState.speed = 0.25f;
|
|||
|
_attack = false;
|
|||
|
_collider.enabled = false;
|
|||
|
//pt_leaf.particleEmitter().emit = true;
|
|||
|
_flyStart = false;
|
|||
|
_attackCount = 0;
|
|||
|
_attackDelay = 0f;
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (!_flyStart)
|
|||
|
{
|
|||
|
if (_attackDelay > 0.1f)
|
|||
|
{
|
|||
|
_animation["appear"].speed = 2.2f;
|
|||
|
Time.timeScale = 0.1f;
|
|||
|
_flyStart = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_attackDelay += Time.deltaTime;
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
if (!_attack)
|
|||
|
{
|
|||
|
if (_animation.IsPlaying("fly_chosun"))
|
|||
|
{
|
|||
|
_attack = true;
|
|||
|
_attackDelay = 1.2f;
|
|||
|
_animation["appear"].speed = 0.25f;
|
|||
|
Time.timeScale = 1f;
|
|||
|
this.GetComponent<AudioSource>().Play();
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
if (_attackDelay > 0.5f)
|
|||
|
{
|
|||
|
transform.position += transform.forward * Time.deltaTime * 2.5f;
|
|||
|
_attackDelay -= Time.deltaTime;
|
|||
|
_collider.enabled = true;
|
|||
|
return;
|
|||
|
}
|
|||
|
if (_attackDelay > 0f)
|
|||
|
{
|
|||
|
_attackDelay -= Time.deltaTime;
|
|||
|
transform.position += transform.forward * Time.deltaTime * 4f;
|
|||
|
_collider.enabled = false;
|
|||
|
return;
|
|||
|
}
|
|||
|
_attackDelay = 1.2f;
|
|||
|
_edgePos = Random.onUnitSphere * 1f;
|
|||
|
_edgePos.y = 0f;
|
|||
|
_attackCount++;
|
|||
|
if (_attackCount >= 6)
|
|||
|
{
|
|||
|
transform.position = Vector3.one * 15f;
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
_collider.enabled = false;
|
|||
|
pt_leaf.particleEmitter().emit = false;
|
|||
|
}
|
|||
|
else if (_attack)
|
|||
|
{
|
|||
|
_rndPos = _cha1.position + _edgePos;
|
|||
|
_direction = _cha1.position - _rndPos;
|
|||
|
transform.position = _rndPos;
|
|||
|
this.GetComponent<AudioSource>().Play();
|
|||
|
if (_direction != Vector3.zero)
|
|||
|
{
|
|||
|
transform.rotation = Quaternion.LookRotation(_direction);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|