summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/Components
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-09-29 19:55:57 +0800
committerchai <chaifix@163.com>2021-09-29 19:55:57 +0800
commit61d6e9bf192ffa54abc57bab69b1bd88c3b8d62b (patch)
tree47071b43d583ced63b1b6cc4a9e4c2c6100ffe3f /Assets/Scripts/Unit/Components
parent16e4a47beaf7786b63404d4a8356e45d70a393b5 (diff)
*misc
Diffstat (limited to 'Assets/Scripts/Unit/Components')
-rw-r--r--Assets/Scripts/Unit/Components/UnitLensEffect.cs24
-rw-r--r--Assets/Scripts/Unit/Components/UnitState/PCState.cs7
2 files changed, 25 insertions, 6 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitLensEffect.cs b/Assets/Scripts/Unit/Components/UnitLensEffect.cs
index 5a68faf8..7758c943 100644
--- a/Assets/Scripts/Unit/Components/UnitLensEffect.cs
+++ b/Assets/Scripts/Unit/Components/UnitLensEffect.cs
@@ -77,6 +77,9 @@ public class UnitLensEffect : UnitComponent
private void OnWillRenderUnit()
{
+ if (m_Effects == null || m_Effects.Count == 0)
+ return;
+
PrepareCommandBuffers();
IBodyRendererAgent body = owner.unitRender.body;
@@ -116,8 +119,11 @@ public class UnitLensEffect : UnitComponent
}
}
- private void OnRenderUnit()
- {
+ private void OnRenderUnit()
+ {
+ if (m_Effects == null || m_Effects.Count == 0)
+ return;
+
// 执行每个event的finish
foreach (var cb in m_InUseCommandBuffers)
{
@@ -148,9 +154,6 @@ public class UnitLensEffect : UnitComponent
CameraEvent ce = cb.Key.ToCameraEvent();
MainCamera.Instance.camera.RemoveCommandBuffer(ce, cb.Value);
}
- var temp = m_CachedCommandBuffers;
- m_CachedCommandBuffers = m_InUseCommandBuffers;
- m_InUseCommandBuffers = temp;
}
private void OnWillRenderObj(BodyPartRenderer renderer)
@@ -163,6 +166,12 @@ public class UnitLensEffect : UnitComponent
void PrepareCommandBuffers()
{
+ if(m_InUseCommandBuffers.Count != 0)
+ {
+ var temp = m_CachedCommandBuffers;
+ m_CachedCommandBuffers = m_InUseCommandBuffers;
+ m_InUseCommandBuffers = temp;
+ }
ERenderingEvent usedEvent = ERenderingEvent.None;
for (int i = 0; i < m_Effects.Count; ++i)
{
@@ -207,4 +216,9 @@ public class UnitLensEffect : UnitComponent
cb = null;
}
+ public void AddEffect(LensEffectBase effect)
+ {
+ m_Effects.Add(effect);
+ }
+
}
diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs
index 060d6e91..e545dea0 100644
--- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs
+++ b/Assets/Scripts/Unit/Components/UnitState/PCState.cs
@@ -139,9 +139,14 @@ public partial class PCState : UnitState
bool TryTeleport()
{
if (Input.GetKeyDown("i"))
- //if (InputManager.Instance.TryCommand(0.5f, KeyCode.I))
{
float offset = owner.isTowardRight ? 1.5f : -1.5f;
+
+ 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, 2, Mathf.Atan2(dir.y, dir.x), info);
+ owner.unitLensEffect.AddEffect(dash);
+
owner.center = TestErika.Instance.monster.owner.center + new Vector3(offset, -0.5f, 0);
TurnAround(!owner.isTowardRight);
return true;