add some extra assets FX and SFX
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
public class EarthShield : Shield
|
||||
{
|
||||
[SerializeField] List<Rigidbody> _ShardRigidbodies;
|
||||
[SerializeField] float _AnimSpeed;
|
||||
[SerializeField] AnimationCurve _AnimCurve;
|
||||
[SerializeField] ParticleSystem _SpawnExplosionEffectPrefab;
|
||||
[SerializeField] Transform _RotationObjectOuter;
|
||||
[SerializeField] Transform _RotationObjectInner;
|
||||
[SerializeField] float _RotationSpeedOuter;
|
||||
[SerializeField] float _RotationSpeedInner;
|
||||
[SerializeField] Vector2 _ShardRadiusSpawn;
|
||||
[SerializeField] ParticleSystem _HitEffectPrefab;
|
||||
[SerializeField] float _ShardScale;
|
||||
private List<MeshCollider> _meshColliders;
|
||||
private List<Vector3> _sourcePositions;
|
||||
private List<Quaternion> _sourceRotations;
|
||||
IEnumerator Coroutine_Animate()
|
||||
{
|
||||
StartCoroutine(Coroutine_Rotate());
|
||||
if (_sourcePositions == null)
|
||||
{
|
||||
_sourcePositions = new List<Vector3>();
|
||||
_sourceRotations = new List<Quaternion>();
|
||||
foreach (var i in _ShardRigidbodies)
|
||||
{
|
||||
_sourcePositions.Add(i.transform.localPosition);
|
||||
_sourceRotations.Add(i.transform.localRotation);
|
||||
}
|
||||
}
|
||||
if (_meshColliders == null)
|
||||
{
|
||||
_meshColliders=new List<MeshCollider>();
|
||||
foreach (var i in _ShardRigidbodies)
|
||||
{
|
||||
if(i.TryGetComponent<MeshCollider>(out MeshCollider collider))
|
||||
{
|
||||
_meshColliders.Add(collider);
|
||||
collider.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach(var i in _meshColliders)
|
||||
{
|
||||
i.enabled = false;
|
||||
}
|
||||
List<Vector3> shardPosition = new List<Vector3>();
|
||||
List<Quaternion> shardRotation = new List<Quaternion>();
|
||||
for (int i = 0; i < _ShardRigidbodies.Count; i++)
|
||||
{
|
||||
_ShardRigidbodies[i].gameObject.SetActive(true);
|
||||
_ShardRigidbodies[i].isKinematic = true;
|
||||
_ShardRigidbodies[i].transform.localScale= Vector3.one* _ShardScale;
|
||||
Vector3 dir = _ShardRigidbodies[i].transform.localPosition;//(_ShardRigidbodies[i].transform.position - transform.position);
|
||||
dir.y = 0;
|
||||
float distance = Random.Range(_ShardRadiusSpawn.x, _ShardRadiusSpawn.y);
|
||||
Quaternion rotation = Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360));
|
||||
Vector3 pos = transform.position + dir.normalized * distance;
|
||||
Ray ray = new Ray(transform.position, Vector3.down);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 10))
|
||||
{
|
||||
pos.y = hit.point.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.y = transform.position.y - 1;
|
||||
}
|
||||
shardPosition.Add(pos);
|
||||
shardRotation.Add(rotation);
|
||||
|
||||
ParticleSystem effect = Instantiate(_SpawnExplosionEffectPrefab, pos, Quaternion.identity);
|
||||
effect.Play();
|
||||
}
|
||||
float lerp = 0;
|
||||
while (lerp < 1)
|
||||
{
|
||||
for (int i = 0; i < _ShardRigidbodies.Count; i++)
|
||||
{
|
||||
_ShardRigidbodies[i].transform.localPosition = Vector3.Lerp(transform.InverseTransformPoint(shardPosition[i]),
|
||||
_sourcePositions[i], _AnimCurve.Evaluate(lerp));
|
||||
_ShardRigidbodies[i].transform.localRotation = Quaternion.Lerp(shardRotation[i], _sourceRotations[i], _AnimCurve.Evaluate(lerp));
|
||||
}
|
||||
lerp += Time.deltaTime * _AnimSpeed;
|
||||
yield return null;
|
||||
}
|
||||
for (int i = 0; i < _ShardRigidbodies.Count; i++)
|
||||
{
|
||||
_ShardRigidbodies[i].transform.localPosition = _sourcePositions[i];
|
||||
_ShardRigidbodies[i].transform.localRotation = _sourceRotations[i];
|
||||
}
|
||||
}
|
||||
IEnumerator Coroutine_Rotate()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
_RotationObjectInner.Rotate(0, _RotationSpeedInner * Time.deltaTime, 0);
|
||||
_RotationObjectOuter.Rotate(0, _RotationSpeedOuter * Time.deltaTime, 0);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
IEnumerator Coroutine_StopAnimation()
|
||||
{
|
||||
foreach (var i in _ShardRigidbodies)
|
||||
{
|
||||
i.isKinematic = false;
|
||||
}
|
||||
foreach(var i in _meshColliders)
|
||||
{
|
||||
i.enabled = true;
|
||||
}
|
||||
float lerp = 0;
|
||||
Vector3 startScale = Vector3.one* _ShardScale;
|
||||
Vector3 endScale = Vector3.zero;
|
||||
while (lerp < 1)
|
||||
{
|
||||
for (int i = 0; i < _ShardRigidbodies.Count; i++)
|
||||
{
|
||||
_ShardRigidbodies[i].transform.localScale = Vector3.Lerp(startScale, endScale,lerp);
|
||||
}
|
||||
lerp +=Time.deltaTime * _AnimSpeed;
|
||||
yield return null;
|
||||
}
|
||||
for(int i = 0; i < _ShardRigidbodies.Count; i++)
|
||||
{
|
||||
_ShardRigidbodies[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PlayImplementation()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(Coroutine_Animate());
|
||||
}
|
||||
|
||||
protected override void StopImplemenation()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(Coroutine_StopAnimation());
|
||||
}
|
||||
|
||||
protected override void HitImplementation(Vector3 point, Vector3 normal)
|
||||
{
|
||||
ParticleSystem effect = Instantiate(_HitEffectPrefab, point, Quaternion.identity);
|
||||
effect.transform.forward = normal;
|
||||
effect.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2308ce2b8d650e947a4e5a2282671f81
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 297318
|
||||
packageName: Elemental Spells Full Pack VFX
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/PixPlays/Components/Scripts/VfxSystem/Shields/EarthShield.cs
|
||||
uploadId: 840846
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
public class ParticleSystemShield : Shield
|
||||
{
|
||||
[SerializeField] ParticleSystem _ShieldEffect;
|
||||
[SerializeField] ParticleSystem _HitEffectPrefab;
|
||||
protected override void HitImplementation(Vector3 point, Vector3 normal)
|
||||
{
|
||||
ParticleSystem effect = Instantiate(_HitEffectPrefab, point, Quaternion.identity);
|
||||
effect.transform.forward = normal;
|
||||
effect.Play();
|
||||
}
|
||||
|
||||
protected override void PlayImplementation()
|
||||
{
|
||||
_ShieldEffect.Play();
|
||||
}
|
||||
|
||||
protected override void StopImplemenation()
|
||||
{
|
||||
_ShieldEffect.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba0ceba87b484834fbd93d5eb6bd97f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 297318
|
||||
packageName: Elemental Spells Full Pack VFX
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/PixPlays/Components/Scripts/VfxSystem/Shields/ParticleSystemShield.cs
|
||||
uploadId: 840846
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
public abstract class Shield : BaseVfx, IHittable
|
||||
{
|
||||
[SerializeField] float _RadiusFactor;
|
||||
public override void Play(VfxData data)
|
||||
{
|
||||
base.Play(data);
|
||||
transform.position = data.Source;
|
||||
transform.localScale = Vector3.one * _RadiusFactor * _data.Radius;
|
||||
gameObject.SetActive(true);
|
||||
PlayImplementation();
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
base.Stop();
|
||||
StopImplemenation();
|
||||
}
|
||||
|
||||
protected abstract void PlayImplementation();
|
||||
protected abstract void StopImplemenation();
|
||||
protected abstract void HitImplementation(Vector3 point, Vector3 normal);
|
||||
|
||||
public void OnHit(Vector3 hitPoint, Vector3 normal)
|
||||
{
|
||||
HitImplementation(hitPoint, normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f5e5e7844aa51d49b287c6aeeba72a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 297318
|
||||
packageName: Elemental Spells Full Pack VFX
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/PixPlays/Components/Scripts/VfxSystem/Shields/Shield.cs
|
||||
uploadId: 840846
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
public class WaterShield : Shield
|
||||
{
|
||||
[SerializeField] ParticleSystem _HitEffectPrefab;
|
||||
[SerializeField] Animation _Anim;
|
||||
[SerializeField] AnimationClip _SpawnAnimation;
|
||||
[SerializeField] AnimationClip _DespawnAnimation;
|
||||
[SerializeField] ParticleSystem _WaterAdditionalParticles;
|
||||
protected override void HitImplementation(Vector3 point, Vector3 normal)
|
||||
{
|
||||
ParticleSystem effect = Instantiate(_HitEffectPrefab, point, Quaternion.identity);
|
||||
effect.transform.forward = normal;
|
||||
effect.Play();
|
||||
}
|
||||
|
||||
protected override void PlayImplementation()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
gameObject.SetActive(true);
|
||||
_WaterAdditionalParticles.Play();
|
||||
_Anim.clip = _SpawnAnimation;
|
||||
_Anim.Play();
|
||||
}
|
||||
|
||||
protected override void StopImplemenation()
|
||||
{
|
||||
_WaterAdditionalParticles.Stop();
|
||||
_Anim.clip = _DespawnAnimation;
|
||||
_Anim.Play();
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cce16e37289a5c848b032b5d23f27bc6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 297318
|
||||
packageName: Elemental Spells Full Pack VFX
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/PixPlays/Components/Scripts/VfxSystem/Shields/WaterShield.cs
|
||||
uploadId: 840846
|
||||
Reference in New Issue
Block a user