summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/TimelineEventProxy.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-03-10 14:07:40 +0800
committerchai <chaifix@163.com>2022-03-10 14:07:40 +0800
commit22891bf59032ba88262824255a706d652031384b (patch)
tree7595439ba9966c9402d37e37cee5e8cf098757d5 /Assets/Scripts/Unit/TimelineEventProxy.cs
parent8b04ea73e540067f83870b61d89db4868fea5e8a (diff)
* move folder
Diffstat (limited to 'Assets/Scripts/Unit/TimelineEventProxy.cs')
-rw-r--r--Assets/Scripts/Unit/TimelineEventProxy.cs175
1 files changed, 0 insertions, 175 deletions
diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs
deleted file mode 100644
index 437b5b2d..00000000
--- a/Assets/Scripts/Unit/TimelineEventProxy.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Collections.Generic;
-using UnityEngine;
-
-// 执行帧事件
-[DisallowMultipleComponent]
-public partial class TimelineEventProxy
-{
-
-#if UNITY_EDITOR // ActionTool里
- private static GameObject m_Root_Particles;
- public static GameObject Root_Particles
- {
- get
- {
- if (m_Root_Particles == null)
- {
- m_Root_Particles = GameObject.Find("Root_Particles");
- if(m_Root_Particles == null)
- m_Root_Particles = new GameObject("Root_Particles");
- }
- return m_Root_Particles;
- }
- }
- private static GameObject m_Root_Projectiles;
- public static GameObject Root_Projectiles
- {
- get
- {
- m_Root_Projectiles = GameObject.Find("Root_Projectiles");
- if (m_Root_Projectiles == null)
- m_Root_Projectiles = new GameObject("Root_Projectiles");
- return m_Root_Projectiles;
- }
- }
-
- public bool isInEditMode;
-
- public delegate void RegisterProjectileHandle(Projectile projectile);
- public RegisterProjectileHandle registerProjectile;
-
- public delegate void RegisterParticleSystemHandle(FxClear vfx);
- public RegisterParticleSystemHandle registerParticleSystem;
-#endif
-
- // 不要序列化枚举值,因为可能会随时更改
- public enum EEventType
- {
- EventGame_TimeScale, // 缩放时间
-
- EventMesh_ImageEffect_MotionBlur, // 运动模糊
- EventMesh_ImageEffect_Glitch, // glitch
-
- EventMesh_LensEffect_Bloom, // bloom
- EventMesh_LensEffect_MotionBlur, // motionBlur
- EventMesh_LensEffect_Dash, // dash
-
- EventMesh_PostEffect_Curly, //
-
- EventMesh_AfterImage, // 角色残像
- EventMesh_AfterImageStop, // 角色残像停止事件
- EventMesh_FadeIn, // 角色透明度
- EventMesh_FadeOut, // 角色透明度
- EventMesh_Gloss, // 角色泛光
- EventMesh_VisibilityInMainCamera, // 是否在主相机渲染
-
- EventUnit_SetPosition, // 设置位置
- EventUnit_BulletTime, // 子弹时间
-
- EventCamera_Zoom, // 相机聚焦
- EventCamera_Shake, // 相机晃动
- EventCamera_Blur, // 相机模糊
- EventCamera_WhiteOut, // 相机白屏
-
- EventEnv_Dark,
- EventEnv_Exposure,
-
- EventUI_Drift, //
- EventUI_Blur, //
-
- EventProjectile, // 发射体
- EventEffect, // 特效
- EventSound, // 音效
- }
-
- public const int FPS = 30; // timeline 每秒采样30次
-
- private int m_PrevFrame = -1;
-
- private Transform m_Root;
-
- private Transform m_UnitModel; // 模型的Unit prefab,默认是m_Root的第一个子节点
-
- public UnitController owner { get; private set; }
-
- private UnitAnimation m_UnitAnimation { get { return owner.unitAnimation; } }
-
- private AnimationData m_PrevAnimationData;
-
- public TimelineEventProxy( UnitController owner)
- {
- this.owner = owner;
- m_Root = owner.transform;
- m_PrevAnimationData = null;
- m_UnitModel = m_Root.GetChild(0);
- }
-
- public TimelineEventProxy(Transform root)
- {
- m_Root = root;
- m_PrevAnimationData = null;
- m_UnitModel = m_Root.GetChild(0);
- }
-
- public static Type GetTypeByName(string name)
- {
- Type type = Type.GetType(name);
- return type;
- }
-
- public void ResetPrevAnimationData()
- {
- m_PrevAnimationData = null;
- }
-
- public void ExecuteAnimationEvents(AnimationData animData, float animFrame)
- {
- if (animData == null)
- return;
-
- int frame = (int)animFrame;
- if (m_PrevAnimationData != animData)
- {
- m_PrevFrame = frame;
- m_PrevAnimationData = animData;
- }
- if (frame != m_PrevFrame)
- {
- for (int i = m_PrevFrame + 1; i <= frame; i++)
- {
- List<int> framesHasEvent = animData.GetAnimationEventFrameIndices();
- if (framesHasEvent.Contains(i))
- {
- List<AnimationEventBase> events = animData.GetAnimationEventsAtFrame(i);
- ExecuteEvents(events);
- ListPool<AnimationEventBase>.Release(events);
- }
- ListPool<int>.Release(framesHasEvent);
- }
- }
- m_PrevFrame = frame;
- }
-
- void ExecuteEvents(List<AnimationEventBase> events)
- {
- if (events == null || events.Count == 0)
- return;
- foreach (var e in events)
- {
- string name = e.type.ToString();
- MethodInfo method = GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(AnimationEventBase) }, null);
- if (method != null)
- {
- object[] param = new object[] { e };
- method.Invoke(this, param);
-
- if(owner != null)
- owner.onTimelineEvent(e);
- }
- }
- }
-
-} \ No newline at end of file