95 lines
2.8 KiB
C#
95 lines
2.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class ShadowSlayerDrawEffectsController : MonoBehaviour, IWeaponSpecialEffects
|
|
{
|
|
[SerializeField]
|
|
private WeaponCreationEffect weaponCreationEffect;
|
|
|
|
[SerializeField]
|
|
private List<ParticleSystem> particleSystemsLoadedPower = new();
|
|
|
|
[SerializeField]
|
|
private Renderer swordRenderer;
|
|
|
|
private Material weaponMaterial;
|
|
|
|
[SerializeField]
|
|
private Light weaponLight;
|
|
|
|
private void Awake()
|
|
{
|
|
weaponMaterial = swordRenderer.material;
|
|
}
|
|
|
|
public void PlayWeaponDrawEffect()
|
|
{
|
|
if (gameObject.activeInHierarchy)
|
|
{
|
|
StartCoroutine(PlayOnWeaponDrawEndEffectCoroutine());
|
|
}
|
|
}
|
|
|
|
public void PlayWeaponHideEffect()
|
|
{
|
|
if (gameObject.activeInHierarchy)
|
|
{
|
|
StartCoroutine(PlayOnWeaponHideStartEffectCoroutine());
|
|
}
|
|
}
|
|
|
|
private IEnumerator PlayOnWeaponHideStartEffectCoroutine()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
weaponCreationEffect.Uncreate();
|
|
}
|
|
|
|
private IEnumerator PlayOnWeaponDrawEndEffectCoroutine()
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
weaponCreationEffect.Create();
|
|
}
|
|
|
|
public void EnableLoadedPowerEffect()
|
|
{
|
|
// if (!particleSystemsLoadedPower[0].isPlaying)
|
|
//{
|
|
// particleSystemsLoadedPower.ForEach(system => system.Play());
|
|
// Debug.LogError("enable");
|
|
|
|
//make it animated?
|
|
// weaponLight.enabled = true;
|
|
weaponLight.DOIntensity(3, 1);
|
|
weaponMaterial.DOFloat(2.27f, "EffectStrenght", 1);
|
|
weaponMaterial.DOFloat(1f, "USEDISSOLVE", 1);
|
|
// weaponMaterial.SetFloat("EffectStrenght", 0);
|
|
// weaponMaterial.SetFloat("USEDISSOLVE", 1);
|
|
particleSystemsLoadedPower.ForEach(system => system.enableEmission = true);
|
|
// }
|
|
}
|
|
|
|
public void DisableLoadedPowerEffect()
|
|
{
|
|
// if (particleSystemsLoadedPower[0].isPlaying)
|
|
// {
|
|
// Debug.LogError("disable");
|
|
|
|
// particleSystemsLoadedPower.ForEach(system => system.Stop());
|
|
// weaponLight.enabled = false;
|
|
|
|
// weaponMaterial.SetFloat("EffectStrenght", 0);
|
|
// weaponMaterial.SetFloat("USEDISSOLVE", 0);
|
|
|
|
weaponLight.DOIntensity(0, 1);
|
|
weaponMaterial.DOFloat(0, "EffectStrenght", 1);
|
|
weaponMaterial.DOFloat(0, "USEDISSOLVE", 1);
|
|
particleSystemsLoadedPower.ForEach(system => system.enableEmission = false);
|
|
//}
|
|
}
|
|
}
|
|
} |