-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathLeanTween.cs
2721 lines (2502 loc) · 81.3 KB
/
LeanTween.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections;
using UnityEngine;
public class LeanTween : MonoBehaviour
{
public static bool throwErrors = true;
private static LTDescr[] tweens;
private static int tweenMaxSearch = 0;
private static int maxTweens = 400;
private static int frameRendered = -1;
private static GameObject _tweenEmpty;
private static float dtEstimated;
private static float previousRealTime;
private static float dt;
private static float dtActual;
private static LTDescr tween;
private static int i;
private static int j;
private static AnimationCurve punch = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(0.112586f, 0.9976035f), new Keyframe(0.3120486f, -0.1720615f), new Keyframe(0.4316337f, 0.07030682f), new Keyframe(0.5524869f, -0.03141804f), new Keyframe(0.6549395f, 0.003909959f), new Keyframe(0.770987f, -0.009817753f), new Keyframe(0.8838775f, 0.001939224f), new Keyframe(1f, 0f));
private static AnimationCurve shake = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(0.25f, 1f), new Keyframe(0.75f, -1f), new Keyframe(1f, 0f));
private static Transform trans;
private static float timeTotal;
private static TweenAction tweenAction;
private static float ratioPassed;
private static float from;
private static float to;
private static float val;
private static Vector3 newVect;
private static bool isTweenFinished;
private static GameObject target;
private static GameObject customTarget;
public static int startSearch = 0;
public static LTDescr descr;
private static Action<LTEvent>[] eventListeners;
private static GameObject[] goListeners;
private static int eventsMaxSearch = 0;
public static int EVENTS_MAX = 10;
public static int LISTENERS_MAX = 10;
public static GameObject tweenEmpty
{
get
{
init(maxTweens);
return _tweenEmpty;
}
}
public static void init()
{
init(maxTweens);
}
public static void init(int maxSimultaneousTweens)
{
if (tweens == null)
{
maxTweens = maxSimultaneousTweens;
tweens = new LTDescr[maxTweens];
_tweenEmpty = new GameObject();
_tweenEmpty.name = "~LeanTween";
_tweenEmpty.AddComponent(typeof(LeanTween));
_tweenEmpty.isStatic = true;
_tweenEmpty.hideFlags = HideFlags.HideAndDontSave;
UnityEngine.Object.DontDestroyOnLoad(_tweenEmpty);
for (int i = 0; i < maxTweens; i++)
{
tweens[i] = new LTDescr();
}
}
}
public static void reset()
{
tweens = null;
}
public void Update()
{
update();
}
public void OnLevelWasLoaded(int lvl)
{
LTGUI.reset();
}
public static void update()
{
if (frameRendered != Time.frameCount)
{
init();
dtEstimated = Time.realtimeSinceStartup - previousRealTime;
if (dtEstimated > 0.2f)
{
dtEstimated = 0.2f;
}
previousRealTime = Time.realtimeSinceStartup;
dtActual = Time.deltaTime * Time.timeScale;
for (int i = 0; i < tweenMaxSearch && i < maxTweens; i++)
{
if (tweens[i].toggle)
{
tween = tweens[i];
trans = tween.trans;
timeTotal = tween.time;
tweenAction = tween.type;
dt = dtActual;
if (tween.useEstimatedTime)
{
dt = dtEstimated;
timeTotal = tween.time;
}
else if (tween.useFrames)
{
dt = 1f;
}
else if (tween.direction == 0f)
{
dt = 0f;
}
if (trans == null)
{
removeTween(i);
}
else
{
isTweenFinished = false;
if (tween.delay <= 0f)
{
if (tween.passed + dt > timeTotal && tween.direction > 0f)
{
isTweenFinished = true;
tween.passed = tween.time;
}
else if (tween.direction < 0f && tween.passed - dt < 0f)
{
isTweenFinished = true;
tween.passed = Mathf.Epsilon;
}
}
if (!tween.hasInitiliazed && (((double)tween.passed == 0.0 && (double)tween.delay == 0.0) || (double)tween.passed > 0.0))
{
tween.hasInitiliazed = true;
if (!tween.useEstimatedTime)
{
tween.time *= Time.timeScale;
}
switch (tweenAction)
{
case TweenAction.MOVE:
tween.from = trans.position;
break;
case TweenAction.MOVE_X:
{
ref Vector3 reference7 = ref tween.from;
Vector3 position2 = trans.position;
reference7.x = position2.x;
break;
}
case TweenAction.MOVE_Y:
{
ref Vector3 reference8 = ref tween.from;
Vector3 position3 = trans.position;
reference8.x = position3.y;
break;
}
case TweenAction.MOVE_Z:
{
ref Vector3 reference = ref tween.from;
Vector3 position = trans.position;
reference.x = position.z;
break;
}
case TweenAction.MOVE_LOCAL_X:
{
ref Vector3 reference2 = ref tweens[i].from;
Vector3 localPosition = trans.localPosition;
reference2.x = localPosition.x;
break;
}
case TweenAction.MOVE_LOCAL_Y:
{
ref Vector3 reference13 = ref tweens[i].from;
Vector3 localPosition3 = trans.localPosition;
reference13.x = localPosition3.y;
break;
}
case TweenAction.MOVE_LOCAL_Z:
{
ref Vector3 reference12 = ref tweens[i].from;
Vector3 localPosition2 = trans.localPosition;
reference12.x = localPosition2.z;
break;
}
case TweenAction.SCALE_X:
{
ref Vector3 reference11 = ref tween.from;
Vector3 localScale3 = trans.localScale;
reference11.x = localScale3.x;
break;
}
case TweenAction.SCALE_Y:
{
ref Vector3 reference10 = ref tween.from;
Vector3 localScale2 = trans.localScale;
reference10.x = localScale2.y;
break;
}
case TweenAction.SCALE_Z:
{
ref Vector3 reference9 = ref tween.from;
Vector3 localScale = trans.localScale;
reference9.x = localScale.z;
break;
}
case TweenAction.ALPHA:
{
SpriteRenderer component = trans.gameObject.GetComponent<SpriteRenderer>();
ref Vector3 reference6 = ref tween.from;
float a;
if (component != null)
{
Color color = component.color;
a = color.a;
}
else
{
Color color2 = trans.gameObject.GetComponent<Renderer>().material.color;
a = color2.a;
}
reference6.x = a;
break;
}
case TweenAction.MOVE_LOCAL:
tween.from = trans.localPosition;
break;
case TweenAction.MOVE_CURVED:
case TweenAction.MOVE_CURVED_LOCAL:
case TweenAction.MOVE_SPLINE:
case TweenAction.MOVE_SPLINE_LOCAL:
tween.from.x = 0f;
break;
case TweenAction.ROTATE:
tween.from = trans.eulerAngles;
tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z));
break;
case TweenAction.ROTATE_X:
{
ref Vector3 reference5 = ref tween.from;
Vector3 eulerAngles3 = trans.eulerAngles;
reference5.x = eulerAngles3.x;
tween.to.x = closestRot(tween.from.x, tween.to.x);
break;
}
case TweenAction.ROTATE_Y:
{
ref Vector3 reference4 = ref tween.from;
Vector3 eulerAngles2 = trans.eulerAngles;
reference4.x = eulerAngles2.y;
tween.to.x = closestRot(tween.from.x, tween.to.x);
break;
}
case TweenAction.ROTATE_Z:
{
ref Vector3 reference3 = ref tween.from;
Vector3 eulerAngles = trans.eulerAngles;
reference3.x = eulerAngles.z;
tween.to.x = closestRot(tween.from.x, tween.to.x);
break;
}
case TweenAction.ROTATE_AROUND:
tween.lastVal = 0f;
tween.origRotation = trans.eulerAngles;
break;
case TweenAction.ROTATE_LOCAL:
tween.from = trans.localEulerAngles;
tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z));
break;
case TweenAction.SCALE:
tween.from = trans.localScale;
break;
case TweenAction.GUI_MOVE:
tween.from = new Vector3(tween.ltRect.rect.x, tween.ltRect.rect.y, 0f);
break;
case TweenAction.GUI_MOVE_MARGIN:
tween.from = new Vector2(tween.ltRect.margin.x, tween.ltRect.margin.y);
break;
case TweenAction.GUI_SCALE:
tween.from = new Vector3(tween.ltRect.rect.width, tween.ltRect.rect.height, 0f);
break;
case TweenAction.GUI_ALPHA:
tween.from.x = tween.ltRect.alpha;
break;
case TweenAction.GUI_ROTATE:
if (!tween.ltRect.rotateEnabled)
{
tween.ltRect.rotateEnabled = true;
tween.ltRect.resetForRotation();
}
tween.from.x = tween.ltRect.rotation;
break;
case TweenAction.ALPHA_VERTEX:
tween.from.x = (float)(int)trans.GetComponent<MeshFilter>().mesh.colors32[0].a;
break;
}
tween.diff = tween.to - tween.from;
}
if (tween.delay <= 0f)
{
if (timeTotal <= 0f)
{
ratioPassed = 0f;
}
else
{
ratioPassed = tween.passed / timeTotal;
}
if (ratioPassed > 1f)
{
ratioPassed = 1f;
}
else if (ratioPassed < 0f)
{
ratioPassed = 0f;
}
if (tweenAction >= TweenAction.MOVE_X && tweenAction <= TweenAction.CALLBACK)
{
if (tween.animationCurve == null)
{
switch (tween.tweenType)
{
case LeanTweenType.linear:
val = tween.from.x + tween.diff.x * ratioPassed;
break;
case LeanTweenType.easeOutQuad:
val = easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed);
break;
case LeanTweenType.easeInQuad:
val = easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed);
break;
case LeanTweenType.easeInOutQuad:
val = easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed);
break;
case LeanTweenType.easeInCubic:
val = easeInCubic(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutCubic:
val = easeOutCubic(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutCubic:
val = easeInOutCubic(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInQuart:
val = easeInQuart(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutQuart:
val = easeOutQuart(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutQuart:
val = easeInOutQuart(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInQuint:
val = easeInQuint(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutQuint:
val = easeOutQuint(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutQuint:
val = easeInOutQuint(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInSine:
val = easeInSine(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutSine:
val = easeOutSine(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutSine:
val = easeInOutSine(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInExpo:
val = easeInExpo(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutExpo:
val = easeOutExpo(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutExpo:
val = easeInOutExpo(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInCirc:
val = easeInCirc(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutCirc:
val = easeOutCirc(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutCirc:
val = easeInOutCirc(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInBounce:
val = easeInBounce(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutBounce:
val = easeOutBounce(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutBounce:
val = easeInOutBounce(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInBack:
val = easeInBack(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutBack:
val = easeOutBack(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutBack:
val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInElastic:
val = easeInElastic(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeOutElastic:
val = easeOutElastic(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeInOutElastic:
val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed);
break;
case LeanTweenType.easeShake:
case LeanTweenType.punch:
if (tween.tweenType == LeanTweenType.punch)
{
tween.animationCurve = punch;
}
else if (tween.tweenType == LeanTweenType.easeShake)
{
tween.animationCurve = shake;
}
tween.to.x = tween.from.x + tween.to.x;
tween.diff.x = tween.to.x - tween.from.x;
val = tweenOnCurve(tween, ratioPassed);
break;
case LeanTweenType.easeSpring:
val = spring(tween.from.x, tween.to.x, ratioPassed);
break;
default:
val = tween.from.x + tween.diff.x * ratioPassed;
break;
}
}
else
{
val = tweenOnCurve(tween, ratioPassed);
}
if (tweenAction == TweenAction.MOVE_X)
{
Transform transform = trans;
float x = val;
Vector3 position4 = trans.position;
float y = position4.y;
Vector3 position5 = trans.position;
transform.position = new Vector3(x, y, position5.z);
}
else if (tweenAction == TweenAction.MOVE_Y)
{
Transform transform2 = trans;
Vector3 position6 = trans.position;
float x2 = position6.x;
float y2 = val;
Vector3 position7 = trans.position;
transform2.position = new Vector3(x2, y2, position7.z);
}
else if (tweenAction == TweenAction.MOVE_Z)
{
Transform transform3 = trans;
Vector3 position8 = trans.position;
float x3 = position8.x;
Vector3 position9 = trans.position;
transform3.position = new Vector3(x3, position9.y, val);
}
if (tweenAction == TweenAction.MOVE_LOCAL_X)
{
Transform transform4 = trans;
float x4 = val;
Vector3 localPosition4 = trans.localPosition;
float y3 = localPosition4.y;
Vector3 localPosition5 = trans.localPosition;
transform4.localPosition = new Vector3(x4, y3, localPosition5.z);
}
else if (tweenAction == TweenAction.MOVE_LOCAL_Y)
{
Transform transform5 = trans;
Vector3 localPosition6 = trans.localPosition;
float x5 = localPosition6.x;
float y4 = val;
Vector3 localPosition7 = trans.localPosition;
transform5.localPosition = new Vector3(x5, y4, localPosition7.z);
}
else if (tweenAction == TweenAction.MOVE_LOCAL_Z)
{
Transform transform6 = trans;
Vector3 localPosition8 = trans.localPosition;
float x6 = localPosition8.x;
Vector3 localPosition9 = trans.localPosition;
transform6.localPosition = new Vector3(x6, localPosition9.y, val);
}
else if (tweenAction == TweenAction.MOVE_CURVED)
{
if (tween.path.orientToPath)
{
tween.path.place(trans, val);
}
else
{
trans.position = tween.path.point(val);
}
}
else if (tweenAction == TweenAction.MOVE_CURVED_LOCAL)
{
if (tween.path.orientToPath)
{
tween.path.placeLocal(trans, val);
}
else
{
trans.localPosition = tween.path.point(val);
}
}
else if (tweenAction == TweenAction.MOVE_SPLINE)
{
if (tween.spline.orientToPath)
{
tween.spline.place(trans, val);
}
else
{
trans.position = tween.spline.point(val);
}
}
else if (tweenAction == TweenAction.MOVE_SPLINE_LOCAL)
{
if (tween.spline.orientToPath)
{
tween.spline.placeLocal(trans, val);
}
else
{
trans.localPosition = tween.spline.point(val);
}
}
else if (tweenAction == TweenAction.SCALE_X)
{
Transform transform7 = trans;
float x7 = val;
Vector3 localScale4 = trans.localScale;
float y5 = localScale4.y;
Vector3 localScale5 = trans.localScale;
transform7.localScale = new Vector3(x7, y5, localScale5.z);
}
else if (tweenAction == TweenAction.SCALE_Y)
{
Transform transform8 = trans;
Vector3 localScale6 = trans.localScale;
float x8 = localScale6.x;
float y6 = val;
Vector3 localScale7 = trans.localScale;
transform8.localScale = new Vector3(x8, y6, localScale7.z);
}
else if (tweenAction == TweenAction.SCALE_Z)
{
Transform transform9 = trans;
Vector3 localScale8 = trans.localScale;
float x9 = localScale8.x;
Vector3 localScale9 = trans.localScale;
transform9.localScale = new Vector3(x9, localScale9.y, val);
}
else if (tweenAction == TweenAction.ROTATE_X)
{
Transform transform10 = trans;
float x10 = val;
Vector3 eulerAngles4 = trans.eulerAngles;
float y7 = eulerAngles4.y;
Vector3 eulerAngles5 = trans.eulerAngles;
transform10.eulerAngles = new Vector3(x10, y7, eulerAngles5.z);
}
else if (tweenAction == TweenAction.ROTATE_Y)
{
Transform transform11 = trans;
Vector3 eulerAngles6 = trans.eulerAngles;
float x11 = eulerAngles6.x;
float y8 = val;
Vector3 eulerAngles7 = trans.eulerAngles;
transform11.eulerAngles = new Vector3(x11, y8, eulerAngles7.z);
}
else if (tweenAction == TweenAction.ROTATE_Z)
{
Transform transform12 = trans;
Vector3 eulerAngles8 = trans.eulerAngles;
float x12 = eulerAngles8.x;
Vector3 eulerAngles9 = trans.eulerAngles;
transform12.eulerAngles = new Vector3(x12, eulerAngles9.y, val);
}
else if (tweenAction == TweenAction.ROTATE_AROUND)
{
float angle = val - tween.lastVal;
if (isTweenFinished)
{
trans.eulerAngles = tween.origRotation;
trans.RotateAround(trans.TransformPoint(tween.point), tween.axis, tween.to.x);
}
else
{
trans.RotateAround(trans.TransformPoint(tween.point), tween.axis, angle);
tween.lastVal = val;
}
}
else if (tweenAction == TweenAction.ALPHA)
{
SpriteRenderer component2 = trans.gameObject.GetComponent<SpriteRenderer>();
if (component2 != null)
{
SpriteRenderer spriteRenderer = component2;
Color color3 = component2.color;
float r = color3.r;
Color color4 = component2.color;
float g = color4.g;
Color color5 = component2.color;
spriteRenderer.color = new Color(r, g, color5.b, val);
}
else
{
Material[] materials = trans.gameObject.GetComponent<Renderer>().materials;
foreach (Material material in materials)
{
Material material2 = material;
Color color6 = material.color;
float r2 = color6.r;
Color color7 = material.color;
float g2 = color7.g;
Color color8 = material.color;
material2.color = new Color(r2, g2, color8.b, val);
}
}
}
else if (tweenAction == TweenAction.ALPHA_VERTEX)
{
Mesh mesh = trans.GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
Color32[] array = new Color32[vertices.Length];
Color32 color9 = mesh.colors32[0];
color9 = new Color((float)(int)color9.r, (float)(int)color9.g, (float)(int)color9.b, val);
for (int k = 0; k < vertices.Length; k++)
{
array[k] = color9;
}
mesh.colors32 = array;
}
}
else if (tweenAction >= TweenAction.MOVE)
{
if (tween.animationCurve != null)
{
newVect = tweenOnCurveVector(tween, ratioPassed);
}
else if (tween.tweenType == LeanTweenType.linear)
{
newVect = new Vector3(tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
}
else if (tween.tweenType >= LeanTweenType.linear)
{
switch (tween.tweenType)
{
case LeanTweenType.easeOutQuad:
newVect = new Vector3(easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed));
break;
case LeanTweenType.easeInQuad:
newVect = new Vector3(easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInQuadOpt(tween.from.z, tween.diff.z, ratioPassed));
break;
case LeanTweenType.easeInOutQuad:
newVect = new Vector3(easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed));
break;
case LeanTweenType.easeInCubic:
newVect = new Vector3(easeInCubic(tween.from.x, tween.to.x, ratioPassed), easeInCubic(tween.from.y, tween.to.y, ratioPassed), easeInCubic(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutCubic:
newVect = new Vector3(easeOutCubic(tween.from.x, tween.to.x, ratioPassed), easeOutCubic(tween.from.y, tween.to.y, ratioPassed), easeOutCubic(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutCubic:
newVect = new Vector3(easeInOutCubic(tween.from.x, tween.to.x, ratioPassed), easeInOutCubic(tween.from.y, tween.to.y, ratioPassed), easeInOutCubic(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInQuart:
newVect = new Vector3(easeInQuart(tween.from.x, tween.to.x, ratioPassed), easeInQuart(tween.from.y, tween.to.y, ratioPassed), easeInQuart(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutQuart:
newVect = new Vector3(easeOutQuart(tween.from.x, tween.to.x, ratioPassed), easeOutQuart(tween.from.y, tween.to.y, ratioPassed), easeOutQuart(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutQuart:
newVect = new Vector3(easeInOutQuart(tween.from.x, tween.to.x, ratioPassed), easeInOutQuart(tween.from.y, tween.to.y, ratioPassed), easeInOutQuart(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInQuint:
newVect = new Vector3(easeInQuint(tween.from.x, tween.to.x, ratioPassed), easeInQuint(tween.from.y, tween.to.y, ratioPassed), easeInQuint(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutQuint:
newVect = new Vector3(easeOutQuint(tween.from.x, tween.to.x, ratioPassed), easeOutQuint(tween.from.y, tween.to.y, ratioPassed), easeOutQuint(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutQuint:
newVect = new Vector3(easeInOutQuint(tween.from.x, tween.to.x, ratioPassed), easeInOutQuint(tween.from.y, tween.to.y, ratioPassed), easeInOutQuint(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInSine:
newVect = new Vector3(easeInSine(tween.from.x, tween.to.x, ratioPassed), easeInSine(tween.from.y, tween.to.y, ratioPassed), easeInSine(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutSine:
newVect = new Vector3(easeOutSine(tween.from.x, tween.to.x, ratioPassed), easeOutSine(tween.from.y, tween.to.y, ratioPassed), easeOutSine(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutSine:
newVect = new Vector3(easeInOutSine(tween.from.x, tween.to.x, ratioPassed), easeInOutSine(tween.from.y, tween.to.y, ratioPassed), easeInOutSine(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInExpo:
newVect = new Vector3(easeInExpo(tween.from.x, tween.to.x, ratioPassed), easeInExpo(tween.from.y, tween.to.y, ratioPassed), easeInExpo(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutExpo:
newVect = new Vector3(easeOutExpo(tween.from.x, tween.to.x, ratioPassed), easeOutExpo(tween.from.y, tween.to.y, ratioPassed), easeOutExpo(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutExpo:
newVect = new Vector3(easeInOutExpo(tween.from.x, tween.to.x, ratioPassed), easeInOutExpo(tween.from.y, tween.to.y, ratioPassed), easeInOutExpo(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInCirc:
newVect = new Vector3(easeInCirc(tween.from.x, tween.to.x, ratioPassed), easeInCirc(tween.from.y, tween.to.y, ratioPassed), easeInCirc(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutCirc:
newVect = new Vector3(easeOutCirc(tween.from.x, tween.to.x, ratioPassed), easeOutCirc(tween.from.y, tween.to.y, ratioPassed), easeOutCirc(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutCirc:
newVect = new Vector3(easeInOutCirc(tween.from.x, tween.to.x, ratioPassed), easeInOutCirc(tween.from.y, tween.to.y, ratioPassed), easeInOutCirc(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInBounce:
newVect = new Vector3(easeInBounce(tween.from.x, tween.to.x, ratioPassed), easeInBounce(tween.from.y, tween.to.y, ratioPassed), easeInBounce(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutBounce:
newVect = new Vector3(easeOutBounce(tween.from.x, tween.to.x, ratioPassed), easeOutBounce(tween.from.y, tween.to.y, ratioPassed), easeOutBounce(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutBounce:
newVect = new Vector3(easeInOutBounce(tween.from.x, tween.to.x, ratioPassed), easeInOutBounce(tween.from.y, tween.to.y, ratioPassed), easeInOutBounce(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInBack:
newVect = new Vector3(easeInBack(tween.from.x, tween.to.x, ratioPassed), easeInBack(tween.from.y, tween.to.y, ratioPassed), easeInBack(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutBack:
newVect = new Vector3(easeOutBack(tween.from.x, tween.to.x, ratioPassed), easeOutBack(tween.from.y, tween.to.y, ratioPassed), easeOutBack(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutBack:
newVect = new Vector3(easeInOutBack(tween.from.x, tween.to.x, ratioPassed), easeInOutBack(tween.from.y, tween.to.y, ratioPassed), easeInOutBack(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInElastic:
newVect = new Vector3(easeInElastic(tween.from.x, tween.to.x, ratioPassed), easeInElastic(tween.from.y, tween.to.y, ratioPassed), easeInElastic(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeOutElastic:
newVect = new Vector3(easeOutElastic(tween.from.x, tween.to.x, ratioPassed), easeOutElastic(tween.from.y, tween.to.y, ratioPassed), easeOutElastic(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeInOutElastic:
newVect = new Vector3(easeInOutElastic(tween.from.x, tween.to.x, ratioPassed), easeInOutElastic(tween.from.y, tween.to.y, ratioPassed), easeInOutElastic(tween.from.z, tween.to.z, ratioPassed));
break;
case LeanTweenType.easeShake:
case LeanTweenType.punch:
if (tween.tweenType == LeanTweenType.punch)
{
tween.animationCurve = punch;
}
else if (tween.tweenType == LeanTweenType.easeShake)
{
tween.animationCurve = shake;
}
tween.to = tween.from + tween.to;
tween.diff = tween.to - tween.from;
if (tweenAction == TweenAction.ROTATE || tweenAction == TweenAction.ROTATE_LOCAL)
{
tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z));
}
newVect = tweenOnCurveVector(tween, ratioPassed);
break;
case LeanTweenType.easeSpring:
newVect = new Vector3(spring(tween.from.x, tween.to.x, ratioPassed), spring(tween.from.y, tween.to.y, ratioPassed), spring(tween.from.z, tween.to.z, ratioPassed));
break;
}
}
else
{
newVect = new Vector3(tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
}
if (tweenAction == TweenAction.MOVE)
{
trans.position = newVect;
}
else if (tweenAction == TweenAction.MOVE_LOCAL)
{
trans.localPosition = newVect;
}
else if (tweenAction == TweenAction.ROTATE)
{
trans.eulerAngles = newVect;
}
else if (tweenAction == TweenAction.ROTATE_LOCAL)
{
trans.localEulerAngles = newVect;
}
else if (tweenAction == TweenAction.SCALE)
{
trans.localScale = newVect;
}
else if (tweenAction == TweenAction.GUI_MOVE)
{
tween.ltRect.rect = new Rect(newVect.x, newVect.y, tween.ltRect.rect.width, tween.ltRect.rect.height);
}
else if (tweenAction == TweenAction.GUI_MOVE_MARGIN)
{
tween.ltRect.margin = new Vector2(newVect.x, newVect.y);
}
else if (tweenAction == TweenAction.GUI_SCALE)
{
tween.ltRect.rect = new Rect(tween.ltRect.rect.x, tween.ltRect.rect.y, newVect.x, newVect.y);
}
else if (tweenAction == TweenAction.GUI_ALPHA)
{
tween.ltRect.alpha = newVect.x;
}
else if (tweenAction == TweenAction.GUI_ROTATE)
{
tween.ltRect.rotation = newVect.x;
}
}
if (tween.onUpdateFloat != null)
{
tween.onUpdateFloat(val);
}
else if (tween.onUpdateFloatObject != null)
{
tween.onUpdateFloatObject(val, tween.onUpdateParam);
}
else if (tween.onUpdateVector3Object != null)
{
tween.onUpdateVector3Object(newVect, tween.onUpdateParam);
}
else if (tween.onUpdateVector3 != null)
{
tween.onUpdateVector3(newVect);
}
else if (tween.optional != null)
{
object obj = tween.optional["onUpdate"];
if (obj != null)
{
Hashtable arg = (Hashtable)tween.optional["onUpdateParam"];
if (tweenAction == TweenAction.VALUE3)
{
if (obj.GetType() == typeof(string))
{
string methodName = obj as string;
customTarget = ((tween.optional["onUpdateTarget"] == null) ? trans.gameObject : (tween.optional["onUpdateTarget"] as GameObject));
customTarget.BroadcastMessage(methodName, newVect);
}
else if (obj.GetType() == typeof(Action<Vector3, Hashtable>))
{
Action<Vector3, Hashtable> action = (Action<Vector3, Hashtable>)obj;
action(newVect, arg);
}
else
{
Action<Vector3> action2 = (Action<Vector3>)obj;
action2(newVect);
}
}
else if (obj.GetType() == typeof(string))
{
string methodName2 = obj as string;
if (tween.optional["onUpdateTarget"] != null)
{
customTarget = (tween.optional["onUpdateTarget"] as GameObject);
customTarget.BroadcastMessage(methodName2, val);
}
else
{
trans.gameObject.BroadcastMessage(methodName2, val);
}
}
else if (obj.GetType() == typeof(Action<float, Hashtable>))
{
Action<float, Hashtable> action3 = (Action<float, Hashtable>)obj;
action3(val, arg);
}
else if (obj.GetType() == typeof(Action<Vector3>))
{
Action<Vector3> action4 = (Action<Vector3>)obj;
action4(newVect);
}
else
{
Action<float> action5 = (Action<float>)obj;
action5(val);
}
}
}
}
if (isTweenFinished)
{
if (tweenAction == TweenAction.GUI_ROTATE)
{
tween.ltRect.rotateFinished = true;
}
if (tween.loopType == LeanTweenType.once || tween.loopCount == 1)
{
if (tweenAction == TweenAction.DELAYED_SOUND)
{
AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
}
if (tween.onComplete != null)
{
removeTween(i);
tween.onComplete();
}
else if (tween.onCompleteObject != null)
{
removeTween(i);
tween.onCompleteObject(tween.onCompleteParam);
}
else if (tween.optional != null)
{
Action action6 = null;
Action<object> action7 = null;
string text = string.Empty;
object obj2 = null;
if (tween.optional != null && (bool)tween.trans && tween.optional["onComplete"] != null)
{
obj2 = tween.optional["onCompleteParam"];
if (tween.optional["onComplete"].GetType() == typeof(string))
{
text = (tween.optional["onComplete"] as string);
}
else if (obj2 != null)
{
action7 = (Action<object>)tween.optional["onComplete"];
}
else
{
action6 = (Action)tween.optional["onComplete"];
if (action6 == null)
{
Debug.LogWarning("callback was not converted");
}
}
}
removeTween(i);
if (action7 != null)
{
action7(obj2);
}
else if (action6 != null)
{
action6();
}
else if (text != string.Empty)
{
if (tween.optional["onCompleteTarget"] != null)
{
customTarget = (tween.optional["onCompleteTarget"] as GameObject);
if (obj2 != null)
{
customTarget.BroadcastMessage(text, obj2);
}
else
{