mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-26 23:37:59 +01:00
84 lines
2.2 KiB
C#
84 lines
2.2 KiB
C#
using Fie.Manager;
|
|
using Fie.Object;
|
|
using ParticlePlayground;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Fie.Ponies.RisingSun
|
|
{
|
|
[FiePrefabInfo("Prefabs/RisingSun/Power/RisingSunForceField")]
|
|
public class FieEmitObjectRisingSunForceField : FieEmittableObjectBase
|
|
{
|
|
[SerializeField]
|
|
private float ForceFieldSeedDuration = 4f;
|
|
|
|
[SerializeField]
|
|
private float ForceFieldSeedDestroyDuration = 1f;
|
|
|
|
[SerializeField]
|
|
private float entytyInstantiateDelay = 0.3f;
|
|
|
|
[SerializeField]
|
|
private List<PlaygroundParticlesC> _childParticles = new List<PlaygroundParticlesC>();
|
|
|
|
private float _lifeTimeCount;
|
|
|
|
private bool _isEndUpdate;
|
|
|
|
private IEnumerator EmitSphereCoroutine()
|
|
{
|
|
yield return (object)new WaitForSeconds(entytyInstantiateDelay);
|
|
/*Error: Unable to find new state assignment for yield return*/;
|
|
}
|
|
|
|
public override void awakeEmitObject()
|
|
{
|
|
_childParticles.ForEach(delegate(PlaygroundParticlesC particle)
|
|
{
|
|
particle.Emit(setEmission: true);
|
|
});
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
base.transform.localRotation = Quaternion.identity;
|
|
if (!_isEndUpdate)
|
|
{
|
|
_lifeTimeCount += Time.deltaTime;
|
|
if (_lifeTimeCount >= ForceFieldSeedDuration - ForceFieldSeedDestroyDuration)
|
|
{
|
|
stopParticleEmitting();
|
|
destoryEmitObject(ForceFieldSeedDestroyDuration);
|
|
_isEndUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
if (!_isEndUpdate && !(_lifeTimeCount > ForceFieldSeedDuration - ForceFieldSeedDestroyDuration) && collision.gameObject.tag == "Floor")
|
|
{
|
|
emitForceFieldEntity();
|
|
stopParticleEmitting();
|
|
destoryEmitObject(ForceFieldSeedDestroyDuration);
|
|
_isEndUpdate = true;
|
|
}
|
|
}
|
|
|
|
private void stopParticleEmitting()
|
|
{
|
|
_childParticles.ForEach(delegate(PlaygroundParticlesC particle)
|
|
{
|
|
particle.Emit(setEmission: false);
|
|
});
|
|
}
|
|
|
|
private void emitForceFieldEntity()
|
|
{
|
|
Transform targetTransform = null;
|
|
FieManagerBehaviour<FieEmittableObjectManager>.I.EmitObject<FieEmitObjectRisingSunForceFieldEmitEffect>(base.transform, Vector3.zero, targetTransform, base.ownerCharacter);
|
|
StartCoroutine(EmitSphereCoroutine());
|
|
}
|
|
}
|
|
}
|