82 lines
1.9 KiB
C#
82 lines
1.9 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "BulletPet4" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using UnityEngine;
|
|
|
|
namespace G
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class BulletPet4 : MonoBehaviour
|
|
{
|
|
private const int MAX_BULLET = 6;
|
|
|
|
private Transform[] _spear = new Transform[MAX_BULLET];
|
|
private ParticleSystem _splashFx;
|
|
private int _curFire;
|
|
private ParticleSystem[] _feathres = new ParticleSystem[MAX_BULLET];
|
|
private void Awake()
|
|
{
|
|
int dx = 1;
|
|
for (int i = 0; i < MAX_BULLET; i++)
|
|
{
|
|
_spear[i] = transform.GetChild(i);
|
|
_spear[i].GetComponent<BulletPet4_m>().Init(this, dx);
|
|
dx *= -1;
|
|
}
|
|
|
|
_splashFx = transform.GetChild(6).GetComponent<ParticleSystem>();
|
|
|
|
|
|
for (int i = 0; i < MAX_BULLET; i++)
|
|
{
|
|
_feathres[i] = transform.GetChild(7).GetChild(i).GetComponent<ParticleSystem>();
|
|
}
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_curFire = 0;
|
|
InvokeRepeating(nameof(FireOn), 0.1f, 0.2f);
|
|
}
|
|
|
|
public void SplashOn(Vector3 _pos)
|
|
{
|
|
_pos.y = 0.05f;
|
|
_splashFx.transform.position = _pos;
|
|
_splashFx.Play();
|
|
_feathres[_curFire].transform.position = _pos;
|
|
_feathres[_curFire].Play();
|
|
}
|
|
|
|
private void FireOn()
|
|
{
|
|
_spear[_curFire].position = transform.position;
|
|
_spear[_curFire].gameObject.SetActive(true);
|
|
_curFire++;
|
|
if (_curFire >= 6)
|
|
{
|
|
CancelInvoke();
|
|
EntityPet.Instance.AttackFinish();
|
|
_curFire = 5;
|
|
Invoke(nameof(CloseThis), 1f);
|
|
}
|
|
}
|
|
|
|
private void CloseThis()
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|