forked from moto2002/mobahero_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NcCurveAnimation.cs
950 lines (866 loc) · 25.6 KB
/
NcCurveAnimation.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
using System;
using System.Collections.Generic;
using UnityEngine;
public class NcCurveAnimation : NcEffectAniBehaviour
{
private class NcComparerCurve : IComparer<NcCurveAnimation.NcInfoCurve>
{
protected static float m_fEqualRange = 0.03f;
protected static float m_fHDiv = 5f;
public int Compare(NcCurveAnimation.NcInfoCurve a, NcCurveAnimation.NcInfoCurve b)
{
float num = a.m_AniCurve.Evaluate(NcCurveAnimation.NcComparerCurve.m_fEqualRange / NcCurveAnimation.NcComparerCurve.m_fHDiv) - b.m_AniCurve.Evaluate(NcCurveAnimation.NcComparerCurve.m_fEqualRange / NcCurveAnimation.NcComparerCurve.m_fHDiv);
if (Mathf.Abs(num) < NcCurveAnimation.NcComparerCurve.m_fEqualRange)
{
num = b.m_AniCurve.Evaluate(1f - NcCurveAnimation.NcComparerCurve.m_fEqualRange / NcCurveAnimation.NcComparerCurve.m_fHDiv) - a.m_AniCurve.Evaluate(1f - NcCurveAnimation.NcComparerCurve.m_fEqualRange / NcCurveAnimation.NcComparerCurve.m_fHDiv);
if (Mathf.Abs(num) < NcCurveAnimation.NcComparerCurve.m_fEqualRange)
{
return 0;
}
}
return (int)(num * 1000f);
}
public static int GetSortGroup(NcCurveAnimation.NcInfoCurve info)
{
float num = info.m_AniCurve.Evaluate(NcCurveAnimation.NcComparerCurve.m_fEqualRange / NcCurveAnimation.NcComparerCurve.m_fHDiv);
if (num < -NcCurveAnimation.NcComparerCurve.m_fEqualRange)
{
return 1;
}
if (NcCurveAnimation.NcComparerCurve.m_fEqualRange < num)
{
return 3;
}
return 2;
}
}
[Serializable]
public class NcInfoCurve
{
public enum APPLY_TYPE
{
NONE,
POSITION,
ROTATION,
SCALE,
MATERIAL_COLOR,
TEXTUREUV,
MESH_COLOR
}
protected const float m_fOverDraw = 0.2f;
public bool m_bEnabled = true;
public string m_CurveName = string.Empty;
public AnimationCurve m_AniCurve = new AnimationCurve();
public static string[] m_TypeName = new string[]
{
"None",
"Position",
"Rotation",
"Scale",
"MaterialColor",
"TextureUV",
"MeshColor"
};
public NcCurveAnimation.NcInfoCurve.APPLY_TYPE m_ApplyType = NcCurveAnimation.NcInfoCurve.APPLY_TYPE.POSITION;
public bool[] m_bApplyOption = new bool[]
{
default(bool),
default(bool),
default(bool),
true
};
public bool m_bRecursively;
public float m_fValueScale = 1f;
public Vector4 m_FromColor = Color.white;
public Vector4 m_ToColor = Color.white;
public int m_nTag;
public int m_nSortGroup;
public Vector4 m_OriginalValue;
public Vector4 m_BeforeValue;
public Vector4[] m_ChildOriginalColorValues;
public Vector4[] m_ChildBeforeColorValues;
public bool IsEnabled()
{
return this.m_bEnabled;
}
public void SetEnabled(bool bEnable)
{
this.m_bEnabled = bEnable;
}
public string GetCurveName()
{
return this.m_CurveName;
}
public NcCurveAnimation.NcInfoCurve GetClone()
{
NcCurveAnimation.NcInfoCurve ncInfoCurve = new NcCurveAnimation.NcInfoCurve();
ncInfoCurve.m_AniCurve = new AnimationCurve(this.m_AniCurve.keys);
ncInfoCurve.m_AniCurve.postWrapMode = this.m_AniCurve.postWrapMode;
ncInfoCurve.m_AniCurve.preWrapMode = this.m_AniCurve.preWrapMode;
ncInfoCurve.m_bEnabled = this.m_bEnabled;
ncInfoCurve.m_CurveName = this.m_CurveName;
ncInfoCurve.m_ApplyType = this.m_ApplyType;
Array.Copy(this.m_bApplyOption, ncInfoCurve.m_bApplyOption, this.m_bApplyOption.Length);
ncInfoCurve.m_fValueScale = this.m_fValueScale;
ncInfoCurve.m_bRecursively = this.m_bRecursively;
ncInfoCurve.m_FromColor = this.m_FromColor;
ncInfoCurve.m_ToColor = this.m_ToColor;
ncInfoCurve.m_nTag = this.m_nTag;
ncInfoCurve.m_nSortGroup = this.m_nSortGroup;
return ncInfoCurve;
}
public void CopyTo(NcCurveAnimation.NcInfoCurve target)
{
target.m_AniCurve = new AnimationCurve(this.m_AniCurve.keys);
target.m_AniCurve.postWrapMode = this.m_AniCurve.postWrapMode;
target.m_AniCurve.preWrapMode = this.m_AniCurve.preWrapMode;
target.m_bEnabled = this.m_bEnabled;
target.m_ApplyType = this.m_ApplyType;
Array.Copy(this.m_bApplyOption, target.m_bApplyOption, this.m_bApplyOption.Length);
target.m_fValueScale = this.m_fValueScale;
target.m_bRecursively = this.m_bRecursively;
target.m_FromColor = this.m_FromColor;
target.m_ToColor = this.m_ToColor;
target.m_nTag = this.m_nTag;
target.m_nSortGroup = this.m_nSortGroup;
}
public int GetValueCount()
{
switch (this.m_ApplyType)
{
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.POSITION:
return 4;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.ROTATION:
return 4;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE:
return 3;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR:
return 4;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV:
return 2;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MESH_COLOR:
return 4;
}
return 0;
}
public string GetValueName(int nIndex)
{
string[] array;
switch (this.m_ApplyType)
{
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.POSITION:
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.ROTATION:
array = new string[]
{
"X",
"Y",
"Z",
"World"
};
goto IL_136;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE:
array = new string[]
{
"X",
"Y",
"Z",
string.Empty
};
goto IL_136;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR:
array = new string[]
{
"R",
"G",
"B",
"A"
};
goto IL_136;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV:
array = new string[]
{
"X",
"Y",
string.Empty,
string.Empty
};
goto IL_136;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MESH_COLOR:
array = new string[]
{
"R",
"G",
"B",
"A"
};
goto IL_136;
}
array = new string[]
{
string.Empty,
string.Empty,
string.Empty,
string.Empty
};
IL_136:
return array[nIndex];
}
public void SetDefaultValueScale()
{
switch (this.m_ApplyType)
{
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.POSITION:
this.m_fValueScale = 1f;
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.ROTATION:
this.m_fValueScale = 360f;
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE:
this.m_fValueScale = 1f;
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV:
this.m_fValueScale = 10f;
break;
}
}
public Rect GetFixedDrawRange()
{
return new Rect(-0.2f, -1.2f, 1.4f, 2.4f);
}
public Rect GetVariableDrawRange()
{
Rect result = default(Rect);
for (int i = 0; i < this.m_AniCurve.keys.Length; i++)
{
result.yMin = Mathf.Min(result.yMin, this.m_AniCurve[i].value);
result.yMax = Mathf.Max(result.yMax, this.m_AniCurve[i].value);
}
int num = 20;
for (int j = 0; j < num; j++)
{
float b = this.m_AniCurve.Evaluate((float)j / (float)num);
result.yMin = Mathf.Min(result.yMin, b);
result.yMax = Mathf.Max(result.yMax, b);
}
result.xMin = 0f;
result.xMax = 1f;
result.xMin -= result.width * 0.2f;
result.xMax += result.width * 0.2f;
result.yMin -= result.height * 0.2f;
result.yMax += result.height * 0.2f;
return result;
}
public Rect GetEditRange()
{
return new Rect(0f, -1f, 1f, 2f);
}
public void NormalizeCurveTime()
{
int i = 0;
while (i < this.m_AniCurve.keys.Length)
{
Keyframe keyframe = this.m_AniCurve[i];
float a = Mathf.Max(0f, keyframe.time);
float num = Mathf.Min(1f, Mathf.Max(a, keyframe.time));
if (num != keyframe.time)
{
Keyframe key = new Keyframe(num, keyframe.value, keyframe.inTangent, keyframe.outTangent);
this.m_AniCurve.RemoveKey(i);
i = 0;
this.m_AniCurve.AddKey(key);
}
else
{
i++;
}
}
}
}
[SerializeField]
public List<NcCurveAnimation.NcInfoCurve> m_CurveInfoList;
public float m_fDelayTime;
public float m_fDurationTime = 0.6f;
public bool m_bAutoDestruct = true;
protected float m_fStartTime;
public float m_fAddElapsedTime;
protected float m_fElapsedRate;
protected Transform m_Transform;
protected string m_ColorName;
protected Material m_MainMaterial;
protected string[] m_ChildColorNames;
protected Renderer[] m_ChildRenderers;
protected MeshFilter m_MainMeshFilter;
protected MeshFilter[] m_ChildMeshFilters;
protected NcUvAnimation m_NcUvAnimation;
protected NcTransformTool m_NcTansform;
protected bool m_bSavedOriginalValue;
public override int GetAnimationState()
{
if (!base.enabled || !NcEffectBehaviour.IsActive(base.gameObject))
{
return -1;
}
if (0f < this.m_fDurationTime && (this.m_fStartTime == 0f || !base.IsEndAnimation()))
{
return 1;
}
return 0;
}
public void ResetPosition()
{
this.m_NcTansform = new NcTransformTool(base.transform);
}
public override void ResetAnimation()
{
this.m_NcTansform.CopyToLocalTransform(base.transform);
this.m_fStartTime = NcEffectBehaviour.GetEngineTime() - this.m_fAddElapsedTime;
this.m_Transform = null;
this.m_ChildRenderers = null;
this.m_ChildColorNames = null;
base.ResetAnimation();
if (0f < this.m_fDelayTime)
{
this.m_Timer = null;
}
this.InitAnimation();
this.UpdateAnimation(0f);
}
public void AdjustfElapsedTime(float fAddStartTime)
{
this.m_fAddElapsedTime = fAddStartTime;
}
public float GetRepeatedRate()
{
return this.m_fElapsedRate;
}
private void Awake()
{
this.ResetPosition();
}
private void Start()
{
this.m_fStartTime = NcEffectBehaviour.GetEngineTime() - this.m_fAddElapsedTime;
this.InitAnimation();
if (0f < this.m_fDelayTime)
{
if (base.renderer)
{
base.renderer.enabled = false;
}
}
else
{
base.InitAnimationTimer();
this.UpdateAnimation(0f);
}
}
private void LateUpdate()
{
if (this.m_fStartTime == 0f)
{
return;
}
if (!base.IsStartAnimation() && this.m_fDelayTime != 0f)
{
if (NcEffectBehaviour.GetEngineTime() < this.m_fStartTime + this.m_fDelayTime)
{
return;
}
base.InitAnimationTimer();
if (base.renderer)
{
base.renderer.enabled = true;
}
}
float num = this.m_Timer.GetTime() + this.m_fAddElapsedTime;
float fElapsedRate = num;
if (this.m_fDurationTime != 0f)
{
fElapsedRate = num / this.m_fDurationTime;
}
this.UpdateAnimation(fElapsedRate);
}
private void InitAnimation()
{
if (this.m_Transform != null)
{
return;
}
this.m_fElapsedRate = 0f;
this.m_Transform = base.transform;
foreach (NcCurveAnimation.NcInfoCurve current in this.m_CurveInfoList)
{
if (current.m_bEnabled)
{
switch (current.m_ApplyType)
{
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.POSITION:
current.m_OriginalValue = Vector4.zero;
current.m_BeforeValue = current.m_OriginalValue;
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.ROTATION:
current.m_OriginalValue = Vector4.zero;
current.m_BeforeValue = current.m_OriginalValue;
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE:
current.m_OriginalValue = this.m_Transform.localScale;
current.m_BeforeValue = current.m_OriginalValue;
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR:
if (current.m_bRecursively)
{
if (this.m_ChildRenderers == null)
{
this.m_ChildRenderers = base.transform.GetComponentsInChildren<Renderer>(true);
this.m_ChildColorNames = new string[this.m_ChildRenderers.Length];
}
current.m_ChildOriginalColorValues = new Vector4[this.m_ChildRenderers.Length];
current.m_ChildBeforeColorValues = new Vector4[this.m_ChildRenderers.Length];
for (int i = 0; i < this.m_ChildRenderers.Length; i++)
{
Renderer renderer = this.m_ChildRenderers[i];
this.m_ChildColorNames[i] = NcCurveAnimation.Ng_GetMaterialColorName(renderer.sharedMaterial);
if (this.m_ChildColorNames[i] != null)
{
if (!this.m_bSavedOriginalValue)
{
current.m_ChildOriginalColorValues[i] = renderer.material.GetColor(this.m_ChildColorNames[i]);
}
else
{
renderer.material.SetColor(this.m_ChildColorNames[i], current.m_ChildOriginalColorValues[i]);
}
}
current.m_ChildBeforeColorValues[i] = Vector4.zero;
}
}
else if (base.renderer != null)
{
this.m_ColorName = NcCurveAnimation.Ng_GetMaterialColorName(base.renderer.sharedMaterial);
if (this.m_ColorName != null)
{
if (!this.m_bSavedOriginalValue)
{
current.m_OriginalValue = base.renderer.material.GetColor(this.m_ColorName);
}
else
{
base.renderer.material.SetColor(this.m_ColorName, current.m_OriginalValue);
}
}
current.m_BeforeValue = Vector4.zero;
}
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV:
if (this.m_NcUvAnimation == null)
{
this.m_NcUvAnimation = base.GetComponent<NcUvAnimation>();
}
if (this.m_NcUvAnimation != null)
{
if (!this.m_bSavedOriginalValue)
{
current.m_OriginalValue = new Vector4(this.m_NcUvAnimation.m_fScrollSpeedX, this.m_NcUvAnimation.m_fScrollSpeedY, 0f, 0f);
}
else
{
this.m_NcUvAnimation.m_fScrollSpeedX = current.m_OriginalValue.x;
this.m_NcUvAnimation.m_fScrollSpeedY = current.m_OriginalValue.y;
}
}
current.m_BeforeValue = current.m_OriginalValue;
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MESH_COLOR:
{
float t = current.m_AniCurve.Evaluate(0f);
Color tarColor = Color.Lerp(current.m_FromColor, current.m_ToColor, t);
if (current.m_bRecursively)
{
this.m_ChildMeshFilters = base.transform.GetComponentsInChildren<MeshFilter>(true);
if (this.m_ChildMeshFilters != null && this.m_ChildMeshFilters.Length >= 0)
{
for (int j = 0; j < this.m_ChildMeshFilters.Length; j++)
{
this.ChangeMeshColor(this.m_ChildMeshFilters[j], tarColor);
}
}
}
else
{
this.m_MainMeshFilter = base.GetComponent<MeshFilter>();
this.ChangeMeshColor(this.m_MainMeshFilter, tarColor);
}
break;
}
}
}
}
this.m_bSavedOriginalValue = true;
}
private void UpdateAnimation(float fElapsedRate)
{
this.m_fElapsedRate = fElapsedRate;
foreach (NcCurveAnimation.NcInfoCurve current in this.m_CurveInfoList)
{
if (current.m_bEnabled)
{
float num = current.m_AniCurve.Evaluate(this.m_fElapsedRate);
if (current.m_ApplyType != NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR && current.m_ApplyType != NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MESH_COLOR)
{
num *= current.m_fValueScale;
}
switch (current.m_ApplyType)
{
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.POSITION:
if (current.m_bApplyOption[3])
{
this.m_Transform.position += new Vector3(this.GetNextValue(current, 0, num), this.GetNextValue(current, 1, num), this.GetNextValue(current, 2, num));
}
else
{
this.m_Transform.localPosition += new Vector3(this.GetNextValue(current, 0, num), this.GetNextValue(current, 1, num), this.GetNextValue(current, 2, num));
}
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.ROTATION:
if (current.m_bApplyOption[3])
{
this.m_Transform.rotation *= Quaternion.Euler(this.GetNextValue(current, 0, num), this.GetNextValue(current, 1, num), this.GetNextValue(current, 2, num));
}
else
{
this.m_Transform.localRotation *= Quaternion.Euler(this.GetNextValue(current, 0, num), this.GetNextValue(current, 1, num), this.GetNextValue(current, 2, num));
}
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE:
this.m_Transform.localScale += new Vector3(this.GetNextScale(current, 0, num), this.GetNextScale(current, 1, num), this.GetNextScale(current, 2, num));
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR:
if (current.m_bRecursively)
{
if (this.m_ChildColorNames != null && this.m_ChildColorNames.Length >= 0)
{
for (int i = 0; i < this.m_ChildColorNames.Length; i++)
{
if (this.m_ChildColorNames[i] != null && this.m_ChildRenderers[i] != null)
{
this.SetChildMaterialColor(current, num, i);
}
}
}
}
else if (base.renderer != null && this.m_ColorName != null)
{
if (this.m_MainMaterial == null)
{
this.m_MainMaterial = base.renderer.material;
base.AddRuntimeMaterial(this.m_MainMaterial);
}
Color color = current.m_ToColor - current.m_OriginalValue;
Color color2 = this.m_MainMaterial.GetColor(this.m_ColorName);
for (int j = 0; j < 4; j++)
{
int index;
int expr_2CD = index = j;
float num2 = color2[index];
color2[expr_2CD] = num2 + this.GetNextValue(current, j, color[j] * num);
}
this.m_MainMaterial.SetColor(this.m_ColorName, color2);
}
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV:
if (this.m_NcUvAnimation)
{
this.m_NcUvAnimation.m_fScrollSpeedX += this.GetNextValue(current, 0, num);
this.m_NcUvAnimation.m_fScrollSpeedY += this.GetNextValue(current, 1, num);
}
break;
case NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MESH_COLOR:
{
Color tarColor = Color.Lerp(current.m_FromColor, current.m_ToColor, num);
if (current.m_bRecursively)
{
if (this.m_ChildMeshFilters != null && this.m_ChildMeshFilters.Length >= 0)
{
for (int k = 0; k < this.m_ChildMeshFilters.Length; k++)
{
this.ChangeMeshColor(this.m_ChildMeshFilters[k], tarColor);
}
}
}
else
{
this.ChangeMeshColor(this.m_MainMeshFilter, tarColor);
}
break;
}
}
}
}
if (this.m_fDurationTime != 0f && 1f < this.m_fElapsedRate)
{
if (!base.IsEndAnimation())
{
base.OnEndAnimation();
}
if (this.m_bAutoDestruct)
{
if (this.m_bReplayState)
{
NcEffectBehaviour.SetActiveRecursively(base.gameObject, false);
}
else
{
UnityEngine.Object.DestroyObject(base.gameObject);
}
}
}
}
private void ChangeMeshColor(MeshFilter mFilter, Color tarColor)
{
if (mFilter == null || mFilter.mesh == null)
{
Debug.LogWarning("ChangeMeshColor mFilter : " + mFilter);
Debug.LogWarning("ChangeMeshColor mFilter.mesh : " + mFilter.mesh);
return;
}
Color[] array = mFilter.mesh.colors;
if (array.Length == 0)
{
if (mFilter.mesh.vertices.Length == 0)
{
NcSpriteFactory.CreateEmptyMesh(mFilter);
}
array = new Color[mFilter.mesh.vertices.Length];
for (int i = 0; i < array.Length; i++)
{
array[i] = Color.white;
}
}
for (int j = 0; j < array.Length; j++)
{
array[j] = tarColor;
}
mFilter.mesh.colors = array;
}
private void SetChildMaterialColor(NcCurveAnimation.NcInfoCurve curveInfo, float fValue, int arrayIndex)
{
Color color = curveInfo.m_ToColor - curveInfo.m_ChildOriginalColorValues[arrayIndex];
Color color2 = this.m_ChildRenderers[arrayIndex].material.GetColor(this.m_ChildColorNames[arrayIndex]);
for (int i = 0; i < 4; i++)
{
int index;
int expr_49 = index = i;
float num = color2[index];
color2[expr_49] = num + this.GetChildNextColorValue(curveInfo, i, color[i] * fValue, arrayIndex);
}
this.m_ChildRenderers[arrayIndex].material.SetColor(this.m_ChildColorNames[arrayIndex], color2);
}
private float GetChildNextColorValue(NcCurveAnimation.NcInfoCurve curveInfo, int nIndex, float fValue, int arrayIndex)
{
if (curveInfo.m_bApplyOption[nIndex])
{
float result = fValue - curveInfo.m_ChildBeforeColorValues[arrayIndex][nIndex];
curveInfo.m_ChildBeforeColorValues[arrayIndex][nIndex] = fValue;
return result;
}
return 0f;
}
private float GetNextValue(NcCurveAnimation.NcInfoCurve curveInfo, int nIndex, float fValue)
{
if (curveInfo.m_bApplyOption[nIndex])
{
float result = fValue - curveInfo.m_BeforeValue[nIndex];
curveInfo.m_BeforeValue[nIndex] = fValue;
return result;
}
return 0f;
}
private float GetNextScale(NcCurveAnimation.NcInfoCurve curveInfo, int nIndex, float fValue)
{
if (curveInfo.m_bApplyOption[nIndex])
{
float num = curveInfo.m_OriginalValue[nIndex] * (1f + fValue);
float result = num - curveInfo.m_BeforeValue[nIndex];
curveInfo.m_BeforeValue[nIndex] = num;
return result;
}
return 0f;
}
public float GetElapsedRate()
{
return this.m_fElapsedRate;
}
public void CopyTo(NcCurveAnimation target, bool bCurveOnly)
{
target.m_CurveInfoList = new List<NcCurveAnimation.NcInfoCurve>();
foreach (NcCurveAnimation.NcInfoCurve current in this.m_CurveInfoList)
{
target.m_CurveInfoList.Add(current.GetClone());
}
if (!bCurveOnly)
{
target.m_fDelayTime = this.m_fDelayTime;
target.m_fDurationTime = this.m_fDurationTime;
}
}
public void AppendTo(NcCurveAnimation target, bool bCurveOnly)
{
if (target.m_CurveInfoList == null)
{
target.m_CurveInfoList = new List<NcCurveAnimation.NcInfoCurve>();
}
foreach (NcCurveAnimation.NcInfoCurve current in this.m_CurveInfoList)
{
target.m_CurveInfoList.Add(current.GetClone());
}
if (!bCurveOnly)
{
target.m_fDelayTime = this.m_fDelayTime;
target.m_fDurationTime = this.m_fDurationTime;
}
}
public NcCurveAnimation.NcInfoCurve GetCurveInfo(int nIndex)
{
if (this.m_CurveInfoList == null || nIndex < 0 || this.m_CurveInfoList.Count <= nIndex)
{
return null;
}
return this.m_CurveInfoList[nIndex];
}
public NcCurveAnimation.NcInfoCurve GetCurveInfo(string curveName)
{
if (this.m_CurveInfoList == null)
{
return null;
}
foreach (NcCurveAnimation.NcInfoCurve current in this.m_CurveInfoList)
{
if (current.m_CurveName == curveName)
{
return current;
}
}
return null;
}
public NcCurveAnimation.NcInfoCurve SetCurveInfo(int nIndex, NcCurveAnimation.NcInfoCurve newInfo)
{
if (this.m_CurveInfoList == null || nIndex < 0 || this.m_CurveInfoList.Count <= nIndex)
{
return null;
}
NcCurveAnimation.NcInfoCurve result = this.m_CurveInfoList[nIndex];
this.m_CurveInfoList[nIndex] = newInfo;
return result;
}
public int AddCurveInfo()
{
NcCurveAnimation.NcInfoCurve ncInfoCurve = new NcCurveAnimation.NcInfoCurve();
ncInfoCurve.m_AniCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
ncInfoCurve.m_ToColor = Color.white;
ncInfoCurve.m_ToColor.w = 0f;
if (this.m_CurveInfoList == null)
{
this.m_CurveInfoList = new List<NcCurveAnimation.NcInfoCurve>();
}
this.m_CurveInfoList.Add(ncInfoCurve);
return this.m_CurveInfoList.Count - 1;
}
public int AddCurveInfo(NcCurveAnimation.NcInfoCurve addCurveInfo)
{
if (this.m_CurveInfoList == null)
{
this.m_CurveInfoList = new List<NcCurveAnimation.NcInfoCurve>();
}
this.m_CurveInfoList.Add(addCurveInfo.GetClone());
return this.m_CurveInfoList.Count - 1;
}
public void DeleteCurveInfo(int nIndex)
{
if (this.m_CurveInfoList == null || nIndex < 0 || this.m_CurveInfoList.Count <= nIndex)
{
return;
}
this.m_CurveInfoList.Remove(this.m_CurveInfoList[nIndex]);
}
public void ClearAllCurveInfo()
{
if (this.m_CurveInfoList == null)
{
return;
}
this.m_CurveInfoList.Clear();
}
public int GetCurveInfoCount()
{
if (this.m_CurveInfoList == null)
{
return 0;
}
return this.m_CurveInfoList.Count;
}
public void SortCurveInfo()
{
if (this.m_CurveInfoList == null)
{
return;
}
this.m_CurveInfoList.Sort(new NcCurveAnimation.NcComparerCurve());
foreach (NcCurveAnimation.NcInfoCurve current in this.m_CurveInfoList)
{
current.m_nSortGroup = NcCurveAnimation.NcComparerCurve.GetSortGroup(current);
}
}
public bool CheckInvalidOption()
{
bool result = false;
for (int i = 0; i < this.m_CurveInfoList.Count; i++)
{
if (this.CheckInvalidOption(i))
{
result = true;
}
}
return result;
}
public bool CheckInvalidOption(int nSrcIndex)
{
NcCurveAnimation.NcInfoCurve curveInfo = this.GetCurveInfo(nSrcIndex);
return curveInfo != null && (curveInfo.m_ApplyType != NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR && curveInfo.m_ApplyType != NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE && curveInfo.m_ApplyType != NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV) && false;
}
public override void OnUpdateEffectSpeed(float fSpeedRate, bool bRuntime)
{
this.m_fDelayTime /= fSpeedRate;
this.m_fDurationTime /= fSpeedRate;
}
public override void OnSetReplayState()
{
base.OnSetReplayState();
}
public override void OnResetReplayStage(bool bClearOldParticle)
{
base.OnResetReplayStage(bClearOldParticle);
this.ResetAnimation();
}
public static string Ng_GetMaterialColorName(Material mat)
{
string[] array = new string[]
{
"_Color",
"_TintColor",
"_EmisColor"
};
if (mat != null)
{
string[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
string text = array2[i];
if (mat.HasProperty(text))
{
return text;
}
}
}
return null;
}
}