mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-25 23:17:58 +01:00
59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using Fie.Utility;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class FieOnetimeLight : MonoBehaviour
|
|
{
|
|
public float startIntensity = 1f;
|
|
|
|
public float endIntensity;
|
|
|
|
public float startRange = 5f;
|
|
|
|
public float endRange = 10f;
|
|
|
|
public float duration = 0.5f;
|
|
|
|
public bool isEnd;
|
|
|
|
private Coroutine calcLightCoroutine;
|
|
|
|
[SerializeField]
|
|
private Light _light;
|
|
|
|
private Tweener<TweenTypesOutSine> _intensityTweener = new Tweener<TweenTypesOutSine>();
|
|
|
|
private Tweener<TweenTypesOutSine> _rangeTweener = new Tweener<TweenTypesOutSine>();
|
|
|
|
public void OnEnable()
|
|
{
|
|
_intensityTweener.InitTweener(duration, startIntensity, endIntensity);
|
|
_rangeTweener.InitTweener(duration, startRange, endRange);
|
|
calcLightCoroutine = StartCoroutine(calcLight());
|
|
isEnd = false;
|
|
}
|
|
|
|
private IEnumerator calcLight()
|
|
{
|
|
if (_intensityTweener.IsEnd() && _rangeTweener.IsEnd())
|
|
{
|
|
yield return (object)null;
|
|
/*Error: Unable to find new state assignment for yield return*/;
|
|
}
|
|
_light.intensity = _intensityTweener.UpdateParameterFloat(Time.deltaTime);
|
|
_light.range = _rangeTweener.UpdateParameterFloat(Time.deltaTime);
|
|
yield return (object)null;
|
|
/*Error: Unable to find new state assignment for yield return*/;
|
|
}
|
|
|
|
public void Kill()
|
|
{
|
|
if (calcLightCoroutine != null)
|
|
{
|
|
StopCoroutine(calcLightCoroutine);
|
|
}
|
|
_light.intensity = 0f;
|
|
_light.range = 0f;
|
|
isEnd = true;
|
|
}
|
|
}
|