14 return UnityEngine.Object.Instantiate<
Effect>(original);
18 public static Effect Get(
string id)
20 return Effect.manager.effects.Get(
id);
24 public static T Get<T>(
string id) where T :
Effect
26 return Effect.manager.effects.Get(
id) as T;
40 public void Play(
float delay,
Point from,
float fixY = 0f,
Point to =
null, Sprite sprite =
null)
42 Point _from = from.Copy();
43 Point _to = ((to !=
null) ? to.Copy() :
null) ??
null;
44 TweenUtil.Tween(delay, delegate()
46 this.Play(_from, fixY, _to, sprite);
51 public unsafe
Effect Play(
Point from,
float fixY = 0f,
Point to =
null, Sprite sprite =
null)
53 return this._Play(from, *from.Position(), fixY, to, sprite);
57 public unsafe
Effect _Play(
Point from, Vector3 fromV,
float fixY = 0f,
Point to =
null, Sprite sprite =
null)
59 if (!
EMono.core.IsGameStarted)
66 this.sr.sprite = sprite;
70 float num = 0.07f * (float)from.cell.light +
EMono.core.screen.tileMap._baseBrightness;
71 num += ((from.cell.HasRoof || from.cell.isShadowed) ? -0.2f : 0f);
74 this.sr.material.SetVector(
"_Color",
new Vector4(num, num, num, 1f));
81 fromV += this.randomRange.Random();
84 this.destPos = (to ?? from);
85 base.transform.position = fromV;
88 this.sr.flipX = (
EMono.rnd(2) == 0);
92 float num2 = Mathf.Min(this.speed * (
float)from.Distance(to),
this.duration);
93 this.destV = *to.Position() + this.posFix + this.randomRange.Random();
96 base.transform.rotation = from.GetRotation(to);
98 this.moveTween = base.transform.DOMove(this.destV, num2,
false).SetEase(Ease.Linear).SetDelay(this.startDelay);
107 public Effect Play(Vector3 v)
109 if (!
EMono.core.IsGameStarted)
115 base.transform.position = this.fromV + this.posFix;
123 protected void Activate()
125 if (this.sprites.Length != 0 &&
this.type !=
Effect.Type.Firework)
127 this.sr.enabled =
false;
130 this.killTimer = TweenUtil.Tween(this.startDelay + this.duration + 0.01f + (
float)this.sprites.Length * 0.01f,
null,
new Action(this.Kill));
134 public Effect Flip(
bool x =
false,
bool y =
false)
138 this.sr.flipX = (this.sr.flipX ? (!x) : x);
139 this.sr.flipY = (this.sr.flipY ? (!y) : y);
145 public Effect SetStartDelay(
float a)
152 public virtual void OnPlay()
157 public virtual void OnUpdate()
159 if (!base.gameObject.activeSelf)
161 base.gameObject.SetActive(
true);
163 this.timer += (this.randomSpeed ? UnityEngine.Random.Range(Time.deltaTime, Time.deltaTime * 1.5f) : Time.deltaTime);
164 if (this.startDelay != 0f)
166 if (this.timer < this.startDelay)
170 this.timer = (this.startDelay = 0f);
172 if (this.sprites.Length != 0 &&
this.type !=
Effect.Type.Firework &&
this.timer >
this.duration / (
float)
this.sprites.Length)
176 if (this.spriteIndex >= this.sprites.Length)
181 this.sr.enabled =
true;
182 this.sr.sprite = this.sprites[this.spriteIndex];
189 TweenUtil.KillTween(ref this.killTimer,
false);
190 TweenUtil.KillTween(ref this.moveTween,
false);
192 Effect.manager.Remove(
this);
193 if (this.pool &&
Effect.manager.effects.usePool)
195 PoolManager.DespawnOrDestroy(base.transform);
200 UnityEngine.Object.Destroy(base.gameObject);
205 public void OnDisable()
207 if (base.transform.parent && !
this.test)
214 public void OnDestroy()
216 if (this.materialsToDestroy !=
null)
218 foreach (Material obj
in this.materialsToDestroy)
220 UnityEngine.Object.Destroy(obj);
226 public Effect Emit(
int num)
228 ParticleSystem[] array = this.systems;
229 for (
int i = 0; i < array.Length; i++)
237 public Effect SetParticleColor(Color c)
239 ParticleSystem[] array = this.systems;
240 for (
int i = 0; i < array.Length; i++)
242 array[i].main.startColor = c;
248 public Effect SetParticleColor(Color color,
bool changeMaterial =
false,
string idCol =
"_Color")
252 this.materialsToDestroy =
new List<Material>();
254 foreach (ParticleSystem particleSystem
in this.systems)
258 Material material = particleSystem.GetComponent<ParticleSystemRenderer>().material;
259 this.materialsToDestroy.Add(material);
260 material.SetColor(idCol, color);
264 particleSystem.main.startColor = color;
271 public Effect SetScale(
float a)
273 base.transform.localScale *= a;
278 public Effect.Type type;
281 public float duration = 1f;
287 public float startDelay;
290 public bool lookAtTarget;
299 public SpriteRenderer sr;
302 public ParticleSystem[] systems;
305 public Vector3[] dirs;
311 public Vector3 posFix;
314 public Vector3 randomRange;
317 public Tween moveTween;
320 public Sprite[] sprites;
323 public bool randomFlip;
326 public bool randomSpeed;
332 public bool setColor =
true;
335 public Action onComplete;
339 public int spriteIndex;
347 public Vector3 fromV;
351 public Vector3 destV;
359 public Transform poolParent;
363 public List<Material> materialsToDestroy;
367 public Point destPos;
370 protected bool killed;
374 public Tween killTimer;