using Core.Utilities;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using TMPro.Examples;
|
using TowerDefense.Effects;
|
using UnityEngine;
|
|
public class EffectMove : MonoBehaviour
|
{
|
protected bool bFired = false;
|
public GameObject particlePrefab;
|
|
protected GameObject m_SpawnedEffect;
|
PoolableEffect mEff;
|
|
// Start is called before the first frame update
|
void Start()
|
{
|
/*
|
mEff = GetComponent<PoolableEffect>();
|
if (mEff != null)
|
{
|
mEff.TurnOnAllSystems();
|
Vector3 tpos = this.transform.position;
|
tpos.z = 0.0f;
|
this.transform.position = tpos;
|
}*/
|
}
|
|
protected void fireObject()
|
{
|
if (particlePrefab == null) return;
|
|
m_SpawnedEffect = Poolable.TryGetPoolable( particlePrefab );
|
m_SpawnedEffect.transform.parent = this.transform;
|
|
Vector3 tpos = this.transform.position;
|
m_SpawnedEffect.transform.position = tpos;
|
m_SpawnedEffect.transform.localScale = new Vector3(3, 3, 3);
|
|
ParticleSystem pars = m_SpawnedEffect.GetComponent<ParticleSystem>();
|
if (pars)
|
{
|
pars.Simulate(0.0f);
|
pars.Play();
|
}
|
|
|
mEff = m_SpawnedEffect.GetComponent<PoolableEffect>();
|
if (mEff != null)
|
{
|
mEff.TurnOnAllSystems();
|
}
|
}
|
|
private object ParticleSystem(GameObject m_SpawnedEffect)
|
{
|
throw new NotImplementedException();
|
}
|
|
// Update is called once per frame
|
void Update()
|
{
|
if( !bFired)
|
{
|
if (Input.GetKeyDown(KeyCode.F))
|
{
|
fireObject();
|
bFired = true;
|
}
|
}
|
else
|
{
|
if (Input.GetKeyDown(KeyCode.E))
|
{
|
if (mEff)
|
{
|
Poolable.TryPool(mEff.gameObject);
|
bFired = false;
|
mEff = null;
|
|
return;
|
}
|
}
|
|
Vector3 tpos = m_SpawnedEffect.transform.position;
|
tpos.z += (Time.deltaTime * 30);
|
m_SpawnedEffect.transform.position = tpos;
|
|
if( tpos.z>= 40 )
|
{
|
Poolable.TryPool( mEff.gameObject );
|
bFired = false;
|
mEff = null;
|
}
|
}
|
}
|
}
|