summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/Components/UnitImageEffect.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-09-17 20:09:19 +0800
committerchai <chaifix@163.com>2021-09-17 20:09:19 +0800
commit234c25bc8761a4d41bc5b4aa362449cf3e806e13 (patch)
tree69cc0b7002ac8018af1806de366526dfc089d49e /Assets/Scripts/Unit/Components/UnitImageEffect.cs
parentea4624fbef6e9d8f58da12be363807eb19a37b53 (diff)
*unit image effect
Diffstat (limited to 'Assets/Scripts/Unit/Components/UnitImageEffect.cs')
-rw-r--r--Assets/Scripts/Unit/Components/UnitImageEffect.cs36
1 files changed, 24 insertions, 12 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitImageEffect.cs b/Assets/Scripts/Unit/Components/UnitImageEffect.cs
index a2689ca1..8af48a3e 100644
--- a/Assets/Scripts/Unit/Components/UnitImageEffect.cs
+++ b/Assets/Scripts/Unit/Components/UnitImageEffect.cs
@@ -17,14 +17,17 @@ public class UnitImageEffectHolder
}
}
-public delegate void UnitImageEffectStepCallback(float normalizedTime);
-
public class UnitImageEffectHandle
{
- public float lifeTime;
+ public delegate void UnitImageEffectStepCallback(float normalizedTime);
+ public delegate void UnitImageEffectEndCallback();
+
+ public float lifeTime;
public float curTime;
public UnitImageEffectHolder holder;
+
public UnitImageEffectStepCallback stepFunc;
+ public UnitImageEffectEndCallback onStop;
}
//Unit后处理效果
@@ -49,6 +52,7 @@ public class UnitImageEffect : UnitComponent
if(handle.curTime > handle.lifeTime)
{
temp.Add(handle);
+ handle.onStop?.Invoke();
continue;
}
handle.stepFunc?.Invoke(handle.curTime / handle.lifeTime);
@@ -123,7 +127,6 @@ public class UnitImageEffect : UnitComponent
holder = null;
}
- #region effects
public void ShowMotionBlur(float lifeTime, float angle, float distance)
{
@@ -155,9 +158,11 @@ public class UnitImageEffect : UnitComponent
effects.Add(handle);
}
- public void ShowGlitch(float lifeTime)
+ public void ShowGlitch(float lifeTime, bool hideUnitInMainCamera = true)
{
- UnitImageEffectHandle handle = m_HandlePool.Get();
+ PCController pc = UnitManager.Instance.pc as PCController;
+
+ UnitImageEffectHandle handle = m_HandlePool.Get();
handle.lifeTime = lifeTime;
handle.curTime = 0;
@@ -171,18 +176,25 @@ public class UnitImageEffect : UnitComponent
handle.holder.renderer.GetPropertyBlock(block);
handle.holder.renderer.SetPropertyBlock(block);
- handle.stepFunc = (float normalTime) =>
- {
+ handle.stepFunc = (float normalTime) => {
+ UnitCamera.Instance.Render();
+
handle.holder.gameObject.transform.position = UnitManager.Instance.pc.center;
handle.holder.renderer.GetPropertyBlock(block);
handle.holder.renderer.SetPropertyBlock(block);
};
- effects.Add(handle);
- }
+ if (hideUnitInMainCamera)
+ {
+ pc.unitRender.SetVisibilityInAllCameras(false);
+ }
-
- #endregion
+ handle.onStop = () => {
+ pc.unitRender.SetVisibilityInAllCameras(true);
+ };
+
+ effects.Add(handle);
+ }
} \ No newline at end of file