summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/Components
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Unit/Components')
-rw-r--r--Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs4
-rw-r--r--Assets/Scripts/Unit/Components/UnitLensEffect.cs209
-rw-r--r--Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs13
-rw-r--r--Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs.meta11
-rw-r--r--Assets/Scripts/Unit/Components/UnitState/PCState.cs3
5 files changed, 131 insertions, 109 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs
index ddf2c4cc..1d407fc2 100644
--- a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs
+++ b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs
@@ -229,6 +229,8 @@ public class AnimatorLayerInfo
m_CurrentState = animState;
m_Animator.CrossFade(animState.ToString(), normalizedTransitionDuration, layerIndex, normalizedTimeOffset, normalizedTransitionTime);
m_TimelineEventProxy.ResetPrevAnimationData();
+
+ playbackSpeed = 1;
}
public void OnPlay(string animState, float normalizedTime)
@@ -236,6 +238,8 @@ public class AnimatorLayerInfo
m_CurrentState = animState;
m_Animator.Play(animState, layerIndex, normalizedTime);
m_TimelineEventProxy.ResetPrevAnimationData();
+
+ playbackSpeed = 1;
}
}
diff --git a/Assets/Scripts/Unit/Components/UnitLensEffect.cs b/Assets/Scripts/Unit/Components/UnitLensEffect.cs
index ff5af87d..23539de0 100644
--- a/Assets/Scripts/Unit/Components/UnitLensEffect.cs
+++ b/Assets/Scripts/Unit/Components/UnitLensEffect.cs
@@ -7,87 +7,87 @@ using UnityEngine.Rendering;
// Unit效果之一,镜头效果,通过command buffer实现
-public class UnitLensEffect : UnitComponent
-{
- private List<RendererProxy> renderers;
-
- private static ObjectPool<CommandBuffer> m_CommandBufferPool;
-
- private List<LensEffectBase> m_Effects;
+public partial class UnitLensEffect : UnitComponent
+{
+ private List<RendererProxy> renderers;
+
+ private static ObjectPool<CommandBuffer> m_CommandBufferPool;
+
+ private List<LensEffectBase> m_Effects;
// 每个角色维护单独的command buffers,而不是共享command buffer。有一定开销,但不重要。
private Dictionary<ERenderingEvent, CommandBuffer> m_InUseCommandBuffers;
private Dictionary<ERenderingEvent, CommandBuffer> m_CachedCommandBuffers;
- static UnitLensEffect()
- {
- m_CommandBufferPool = new ObjectPool<CommandBuffer>(null, null);
- }
-
- public override void Initialize()
- {
- base.Initialize();
-
- renderers = new List<RendererProxy>();
- m_Effects = new List<LensEffectBase>();
+ static UnitLensEffect()
+ {
+ m_CommandBufferPool = new ObjectPool<CommandBuffer>(null, null);
+ }
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ renderers = new List<RendererProxy>();
+ m_Effects = new List<LensEffectBase>();
m_InUseCommandBuffers = new Dictionary<ERenderingEvent, CommandBuffer>();
m_CachedCommandBuffers = new Dictionary<ERenderingEvent, CommandBuffer>();
- }
-
- public override void OnUpdate()
- {
- base.OnUpdate();
+ }
- }
-
- public override void OnPostInitialize()
- {
- base.OnPostInitialize();
-
- IBodyRendererAgent body = owner.unitRender.body;
- if (body == null || body.renderers == null)
- return;
- for (int i = 0; i < body.renderers.Length; ++i)
- {
- var renderer = body.renderers[i];
- if (renderer == null)
- continue;
- RendererProxy proxy = renderer.renderer.gameObject.GetOrAddComponent<RendererProxy>();
- proxy.Initialize(renderer);
- proxy.onWillRenderObject = OnWillRenderObj;
- proxy.onRenderObject = OnRenderObj;
- renderers.Add(proxy);
- }
-
- MainCamera.Instance.customRenderingPipeline.onPreCull += OnWillRenderUnit;
- MainCamera.Instance.customRenderingPipeline.onPostRender += OnRenderUnit;
-
- /////
- //m_Effects.Add(new LensEffect_MotionBlur());
- //m_Effects.Add(new LensEffect_BlurRim(Color.blue));
- //m_Effects.Add(new LensEffect_Buzz());
- }
-
- public override void Release()
- {
- MainCamera.Instance.customRenderingPipeline.onPreCull -= OnWillRenderUnit;
- MainCamera.Instance.customRenderingPipeline.onPostRender -= OnRenderUnit;
-
- base.Release();
- }
-
- private void OnWillRenderUnit()
- {
+ public override void OnUpdate()
+ {
+ base.OnUpdate();
+
+ }
+
+ public override void OnPostInitialize()
+ {
+ base.OnPostInitialize();
+
+ IBodyRendererAgent body = owner.unitRender.body;
+ if (body == null || body.renderers == null)
+ return;
+ for (int i = 0; i < body.renderers.Length; ++i)
+ {
+ var renderer = body.renderers[i];
+ if (renderer == null)
+ continue;
+ RendererProxy proxy = renderer.renderer.gameObject.GetOrAddComponent<RendererProxy>();
+ proxy.Initialize(renderer);
+ proxy.onWillRenderObject = OnWillRenderObj;
+ proxy.onRenderObject = OnRenderObj;
+ renderers.Add(proxy);
+ }
+
+ MainCamera.Instance.customRenderingPipeline.onPreCull += OnWillRenderUnit;
+ MainCamera.Instance.customRenderingPipeline.onPostRender += OnRenderUnit;
+
+ /////
+ //m_Effects.Add(new LensEffect_MotionBlur());
+ //m_Effects.Add(new LensEffect_BlurRim(Color.blue));
+ //m_Effects.Add(new LensEffect_Buzz());
+ }
+
+ public override void Release()
+ {
+ MainCamera.Instance.customRenderingPipeline.onPreCull -= OnWillRenderUnit;
+ MainCamera.Instance.customRenderingPipeline.onPostRender -= OnRenderUnit;
+
+ base.Release();
+ }
+
+ private void OnWillRenderUnit()
+ {
if (m_Effects == null || m_Effects.Count == 0)
return;
PrepareCommandBuffers();
- IBodyRendererAgent body = owner.unitRender.body;
- if (body == null || body.renderers == null)
- return;
- if (m_Effects == null || m_Effects.Count == 0)
- return;
+ IBodyRendererAgent body = owner.unitRender.body;
+ if (body == null || body.renderers == null)
+ return;
+ if (m_Effects == null || m_Effects.Count == 0)
+ return;
foreach (var cb in m_InUseCommandBuffers)
{
cb.Value.Clear();
@@ -118,9 +118,9 @@ public class UnitLensEffect : UnitComponent
}
MainCamera.Instance.camera.AddCommandBuffer(ce, cb.Value);
}
- }
-
- private void OnRenderUnit()
+ }
+
+ private void OnRenderUnit()
{
if (m_Effects == null || m_Effects.Count == 0)
return;
@@ -146,17 +146,12 @@ public class UnitLensEffect : UnitComponent
for (int i = 0; i < m_Effects.Count; ++i)
{
LensEffectBase eff = m_Effects[i];
- MethodInfo method = eff.GetType().GetMethod("OnRenderFinish", BindingFlags.Instance | BindingFlags.Public);
- if (method == null)
- continue;
- method.Invoke(eff, new object[] { });
- if(eff.CanDestroy())
- {
+ eff.OnRenderFinish();
+ if (eff.CanDestroy())
temp.Add(eff);
- }
}
- for(int i = 0; i< temp.Count; ++i)
+ for (int i = 0; i < temp.Count; ++i)
{
temp[i].OnDestroy();
m_Effects.Remove(temp[i]);
@@ -169,19 +164,19 @@ public class UnitLensEffect : UnitComponent
CameraEvent ce = cb.Key.ToCameraEvent();
MainCamera.Instance.camera.RemoveCommandBuffer(ce, cb.Value);
}
+ }
+
+ private void OnWillRenderObj(BodyPartRenderer renderer)
+ {
+ }
+
+ private void OnRenderObj(BodyPartRenderer renderer)
+ {
}
- private void OnWillRenderObj(BodyPartRenderer renderer)
- {
- }
-
- private void OnRenderObj(BodyPartRenderer renderer)
- {
- }
-
void PrepareCommandBuffers()
{
- if(m_InUseCommandBuffers.Count != 0)
+ if (m_InUseCommandBuffers.Count != 0)
{
var temp = m_CachedCommandBuffers;
m_CachedCommandBuffers = m_InUseCommandBuffers;
@@ -192,14 +187,14 @@ public class UnitLensEffect : UnitComponent
{
usedEvent |= m_Effects[i].renderingEvents;
}
- foreach(ERenderingEvent evt in Enum.GetValues(typeof(ERenderingEvent)))
+ foreach (ERenderingEvent evt in Enum.GetValues(typeof(ERenderingEvent)))
{
if (evt == ERenderingEvent.None)
continue;
- if(usedEvent.HasFlag(evt))
+ if (usedEvent.HasFlag(evt))
{
CommandBuffer cb;
- if(m_CachedCommandBuffers.TryGetValue(evt, out cb))
+ if (m_CachedCommandBuffers.TryGetValue(evt, out cb))
{
m_CachedCommandBuffers.Remove(evt);
}
@@ -211,29 +206,29 @@ public class UnitLensEffect : UnitComponent
m_InUseCommandBuffers.Add(evt, cb);
}
}
- foreach(var cb in m_CachedCommandBuffers)
+ foreach (var cb in m_CachedCommandBuffers)
{
m_CommandBufferPool.Release(cb.Value);
}
m_CachedCommandBuffers.Clear();
}
- static CommandBuffer ClaimCommandBuffer()
- {
- CommandBuffer cb = m_CommandBufferPool.Get();
- cb.Clear();
- return cb;
- }
-
- static void ReleaseCommandBuffer(ref CommandBuffer cb)
- {
- m_CommandBufferPool.Release(cb);
- cb = null;
- }
+ static CommandBuffer ClaimCommandBuffer()
+ {
+ CommandBuffer cb = m_CommandBufferPool.Get();
+ cb.Clear();
+ return cb;
+ }
+
+ static void ReleaseCommandBuffer(ref CommandBuffer cb)
+ {
+ m_CommandBufferPool.Release(cb);
+ cb = null;
+ }
public void AddEffect(LensEffectBase effect)
{
m_Effects.Add(effect);
- }
-
-}
+ }
+
+} \ No newline at end of file
diff --git a/Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs b/Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs
new file mode 100644
index 00000000..31d3c549
--- /dev/null
+++ b/Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs
@@ -0,0 +1,13 @@
+using UnityEngine;
+using UnityEngine.Rendering;
+
+public partial class UnitLensEffect : UnitComponent
+{
+
+ public void Dash(Color color, float lifeTime, float angle, UnitSnapshotInfo snapshot)
+ {
+ LensEffect_Dash dash = new LensEffect_Dash(color, lifeTime, angle, snapshot);
+ owner.unitLensEffect.AddEffect(dash);
+ }
+
+} \ No newline at end of file
diff --git a/Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs.meta b/Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs.meta
new file mode 100644
index 00000000..78ed27ad
--- /dev/null
+++ b/Assets/Scripts/Unit/Components/UnitLensEffect_Effects.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 16bed6a0d9a62e74987b4e6b5d70403c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs
index 1bdd355f..22855aeb 100644
--- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs
+++ b/Assets/Scripts/Unit/Components/UnitState/PCState.cs
@@ -144,8 +144,7 @@ public partial class PCState : UnitState
UnitSnapshotInfo info = owner.TakeSnapshot();
Vector2 dir = TestErika.Instance.monster.owner.center + new Vector3(offset, -0.5f, 0) - owner.center;
- LensEffect_Dash dash = new LensEffect_Dash(Color.white, 0.1f, Mathf.Atan2(dir.y, dir.x), info);
- owner.unitLensEffect.AddEffect(dash);
+ owner.unitLensEffect.Dash(Color.white, 0.1f, Mathf.Rad2Deg * Mathf.Atan2(dir.y, dir.x), info);
owner.center = TestErika.Instance.monster.owner.center + new Vector3(offset, -0.5f, 0);
TurnAround(!owner.isTowardRight);