// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
//
//
// ***********************************************************************
using UnityEngine;
namespace G
{
[RequireComponent(typeof(SkillBase))]
public class SkillMachineGun : MonoBehaviour
{
public Transform beam1;
public Transform beam2;
private bool _shootOn;
private float _delay;
private Collider _collider;
private Animation _animation;
private void Awake()
{
_collider = this.GetComponent();
_animation = this.GetComponent();
_animation["shoot"].speed = 0.2f;
_animation["create"].speed = 0.5f;
_animation["destroy"].speed = 0.4f;
}
private void Start()
{
}
private void OnEnable()
{
_shootOn = false;
_delay = 0f;
InvokeRepeating(nameof(Shoot), 0.8f, 0.2f);
_animation.Play("create");
//beam1.particleEmitter().emit = false;
//beam2.particleEmitter().emit = false;
_collider.enabled = false;
}
public void Shoot()
{
_collider.enabled = false;
_collider.enabled = true;
}
private void Update()
{
_delay += Time.deltaTime;
if (_delay > 4.5f)
{
this.gameObject.SetActive(false);
transform.position = Vector3.one * 40f;
transform.parent = null;
}
else if (_delay > 4f)
{
//beam1.particleEmitter().emit = false;
//beam2.particleEmitter().emit = false;
_animation.Play("destroy");
CancelInvoke(nameof(Shoot));
_collider.enabled = false;
}
else if (_delay > 0.6f && !_shootOn)
{
_shootOn = true;
//beam1.particleEmitter().emit = true;
//beam2.particleEmitter().emit = true;
_animation.Play("shoot");
}
}
}
}