XftEventComponent.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System;
  2. using UnityEngine;
  3. namespace Xft
  4. {
  5. public class XftEventComponent : MonoBehaviour
  6. {
  7. public float ElapsedTime
  8. {
  9. get
  10. {
  11. return this.m_elapsedTime;
  12. }
  13. }
  14. public void Initialize(XffectComponent owner)
  15. {
  16. this.Owner = owner;
  17. switch (this.Type)
  18. {
  19. case XEventType.CameraShake:
  20. this.m_eventHandler = new CameraShakeEvent(this);
  21. break;
  22. case XEventType.Sound:
  23. this.m_eventHandler = new SoundEvent(this);
  24. break;
  25. case XEventType.Light:
  26. this.m_eventHandler = new LightEvent(this);
  27. break;
  28. case XEventType.CameraEffect:
  29. if (this.CameraEffectType == CameraEffectEvent.EType.ColorInverse)
  30. {
  31. this.m_eventHandler = new ColorInverseEvent(this);
  32. }
  33. else if (this.CameraEffectType == CameraEffectEvent.EType.Glow)
  34. {
  35. this.m_eventHandler = new GlowEvent(this);
  36. }
  37. else if (this.CameraEffectType == CameraEffectEvent.EType.GlowPerObj)
  38. {
  39. this.m_eventHandler = new GlowPerObjEvent(this);
  40. }
  41. else if (this.CameraEffectType == CameraEffectEvent.EType.RadialBlur)
  42. {
  43. this.m_eventHandler = new RadialBlurEvent(this);
  44. }
  45. else if (this.CameraEffectType == CameraEffectEvent.EType.RadialBlurMask)
  46. {
  47. this.m_eventHandler = new RadialBlurTexAddEvent(this);
  48. }
  49. else if (this.CameraEffectType == CameraEffectEvent.EType.Glitch)
  50. {
  51. this.m_eventHandler = new GlitchEvent(this);
  52. }
  53. break;
  54. case XEventType.TimeScale:
  55. this.m_eventHandler = new TimeScaleEvent(this);
  56. break;
  57. default:
  58. UnityEngine.Debug.LogWarning("invalid event type!");
  59. break;
  60. }
  61. this.m_eventHandler.Initialize();
  62. this.m_elapsedTime = 0f;
  63. this.m_finished = false;
  64. }
  65. public void ResetCustom()
  66. {
  67. this.m_elapsedTime = 0f;
  68. if (this.m_eventHandler != null)
  69. {
  70. this.m_eventHandler.Reset();
  71. }
  72. this.m_finished = false;
  73. }
  74. public void UpdateCustom(float deltaTime)
  75. {
  76. if (this.m_finished)
  77. {
  78. return;
  79. }
  80. if (this.m_eventHandler != null)
  81. {
  82. this.m_elapsedTime += deltaTime;
  83. if (!this.m_eventHandler.CanUpdate && this.m_elapsedTime >= this.StartTime && this.StartTime >= 0f)
  84. {
  85. this.m_eventHandler.OnBegin();
  86. }
  87. if (this.m_eventHandler.CanUpdate)
  88. {
  89. this.m_eventHandler.Update(deltaTime);
  90. }
  91. if (this.m_eventHandler.CanUpdate && this.m_elapsedTime > this.StartTime + this.EndTime && this.EndTime > 0f)
  92. {
  93. this.ResetCustom();
  94. this.m_finished = true;
  95. }
  96. }
  97. }
  98. public XftEventType EventType;
  99. public XEventType Type;
  100. public float StartTime;
  101. public float EndTime = -1f;
  102. public CameraEffectEvent.EType CameraEffectType = CameraEffectEvent.EType.Glow;
  103. public int CameraEffectPriority;
  104. public Shader RadialBlurShader;
  105. public Transform RadialBlurObj;
  106. public float RBSampleDist = 0.3f;
  107. public MAGTYPE RBStrengthType;
  108. public float RBSampleStrength = 1f;
  109. public AnimationCurve RBSampleStrengthCurve = new AnimationCurve(new Keyframe[]
  110. {
  111. new Keyframe(0f, 0f),
  112. new Keyframe(1f, 1f)
  113. });
  114. public XCurveParam RBSampleStrengthCurveX;
  115. public Shader RadialBlurTexAddShader;
  116. public Texture2D RadialBlurMask;
  117. public float RBMaskSampleDist = 3f;
  118. public MAGTYPE RBMaskStrengthType;
  119. public float RBMaskSampleStrength = 5f;
  120. public AnimationCurve RBMaskSampleStrengthCurve = new AnimationCurve(new Keyframe[]
  121. {
  122. new Keyframe(0f, 0f),
  123. new Keyframe(1f, 1f)
  124. });
  125. public XCurveParam RBMaskSampleStrengthCurveX;
  126. public Shader GlowCompositeShader;
  127. public Shader GlowBlurShader;
  128. public Shader GlowDownSampleShader;
  129. public float GlowIntensity = 1.5f;
  130. public int GlowBlurIterations = 3;
  131. public float GlowBlurSpread = 0.7f;
  132. public Color GlowColorStart = new Color(0f, 0.02745098f, 0.819607854f, 0.4392157f);
  133. public Color GlowColorEnd = new Color(0.298039228f, 0.5882353f, 1f, 1f);
  134. public COLOR_GRADUAL_TYPE GlowColorGradualType;
  135. public float GlowColorGradualTime = 2f;
  136. public AnimationCurve ColorCurve = new AnimationCurve(new Keyframe[]
  137. {
  138. new Keyframe(0f, 0f),
  139. new Keyframe(1f, 1f)
  140. });
  141. public Shader GlowPerObjReplacementShader;
  142. public Shader GlowPerObjBlendShader;
  143. public Shader ColorInverseShader;
  144. public AnimationCurve CIStrengthCurve = new AnimationCurve(new Keyframe[]
  145. {
  146. new Keyframe(0f, 0f),
  147. new Keyframe(1f, 1f)
  148. });
  149. public Shader GlitchShader;
  150. public Texture2D GlitchMask;
  151. public float MinAmp;
  152. public float MaxAmp = 0.05f;
  153. public float MinRand = 0.05f;
  154. public float MaxRand = 0.85f;
  155. public int WaveLen = 10;
  156. public AudioClip Clip;
  157. public float Volume = 1f;
  158. public float Pitch = 1f;
  159. public bool IsSoundLoop;
  160. public Vector3 PositionForce = new Vector3(0f, 4f, 0f);
  161. public Vector3 RotationForce = Vector3.zero;
  162. public float PositionStifness = 0.3f;
  163. public float PositionDamping = 0.1f;
  164. public float RotationStiffness = 0.1f;
  165. public float RotationDamping = 0.25f;
  166. public XCameraShakeType CameraShakeType;
  167. public float ShakeCurveTime = 1f;
  168. public AnimationCurve PositionCurve = new AnimationCurve(new Keyframe[]
  169. {
  170. new Keyframe(0f, 0.5f),
  171. new Keyframe(0.33f, 1f),
  172. new Keyframe(0.66f, 0f),
  173. new Keyframe(1f, 0.5f)
  174. });
  175. public AnimationCurve RotationCurve = new AnimationCurve(new Keyframe[]
  176. {
  177. new Keyframe(0f, 0.5f),
  178. new Keyframe(0.33f, 1f),
  179. new Keyframe(0.66f, 0f),
  180. new Keyframe(1f, 0.5f)
  181. });
  182. public bool UseEarthQuake;
  183. public float EarthQuakeMagnitude = 2f;
  184. public MAGTYPE EarthQuakeMagTye;
  185. public AnimationCurve EarthQuakeMagCurve = new AnimationCurve(new Keyframe[]
  186. {
  187. new Keyframe(0f, 0f),
  188. new Keyframe(1f, 1f)
  189. });
  190. public XCurveParam EarthQuakeMagCurveX;
  191. public float EarthQuakeTime = 2f;
  192. public float EarthQuakeCameraRollFactor = 0.1f;
  193. public Light LightComp;
  194. public float LightIntensity = 1f;
  195. public MAGTYPE LightIntensityType;
  196. public AnimationCurve LightIntensityCurve = new AnimationCurve(new Keyframe[]
  197. {
  198. new Keyframe(0f, 0f),
  199. new Keyframe(1f, 1f)
  200. });
  201. public XCurveParam LightIntensityCurveX;
  202. public float LightRange = 10f;
  203. public MAGTYPE LightRangeType;
  204. public AnimationCurve LightRangeCurve = new AnimationCurve(new Keyframe[]
  205. {
  206. new Keyframe(0f, 0f),
  207. new Keyframe(1f, 20f)
  208. });
  209. public XCurveParam LightRangeCurveX;
  210. public float TimeScale = 1f;
  211. public float TimeScaleDuration = 1f;
  212. public XffectComponent Owner;
  213. protected XftEvent m_eventHandler;
  214. protected float m_elapsedTime;
  215. protected bool m_finished;
  216. }
  217. }