85 lines
2.0 KiB
C#
85 lines
2.0 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "SkillMachineGun" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
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<Collider>();
|
|
_animation = this.GetComponent<Animation>();
|
|
_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");
|
|
}
|
|
}
|
|
}
|
|
}
|