@@ -21,9 +21,9 @@ public override string ToString()
21
21
}
22
22
}
23
23
24
- private readonly float totalAnimationTime = 2f ;
24
+ private float speed = 120f ;
25
25
private float currentRotation ;
26
- private float startTime ;
26
+ private float lastTime ;
27
27
private bool started ;
28
28
private float centerX ;
29
29
private float centerY ;
@@ -54,7 +54,6 @@ public void Start(float currentTime)
54
54
if ( started )
55
55
return ;
56
56
started = true ;
57
- startTime = currentTime ;
58
57
}
59
58
60
59
public void Stop ( )
@@ -64,9 +63,10 @@ public void Stop()
64
63
65
64
public float Rotate ( float currentTime )
66
65
{
67
- var elapsed = Mathf . Repeat ( currentTime - startTime , totalAnimationTime ) ;
68
- currentRotation = Linear ( elapsed , 360f , totalAnimationTime ) ;
66
+ var deltaTime = currentTime - lastTime ;
67
+ currentRotation += deltaTime * speed * ( ( Mathf . Sin ( currentTime * 1.2f ) ) + 2 ) ;
69
68
currentRotation = Mathf . Repeat ( currentRotation , 360f ) ;
69
+ lastTime = currentTime ;
70
70
return currentRotation ;
71
71
}
72
72
@@ -141,67 +141,5 @@ private void PopRotation()
141
141
var rot = rotations . Pop ( ) ;
142
142
GUIUtility . RotateAroundPivot ( - rot . rotation , rot . center ) ;
143
143
}
144
-
145
- private float ExpoEase ( float currentTime , float end , float duration )
146
- {
147
- //Debug.LogFormat("ExpoEase: {0} {1}", currentTime, duration);
148
- currentTime /= duration / 2 ;
149
- if ( currentTime < 1 ) return duration / 2 * Mathf . Pow ( 2 , 10 * ( currentTime - 1 ) ) ;
150
- currentTime -- ;
151
- return end / 2 * ( - Mathf . Pow ( 2 , - 10 * currentTime ) + 2 ) ;
152
- }
153
- private float SinEase ( float currentTime , float end , float duration )
154
- {
155
- return - end / 2 * ( Mathf . Cos ( Mathf . PI * currentTime / duration ) - 1 ) ;
156
- }
157
-
158
- private float SinEaseIn ( float t , float c , float d )
159
- {
160
- //Debug.LogFormat("SinEaseIn: {0} {1}", t, d);
161
-
162
- return - c * Mathf . Cos ( t / d * ( Mathf . PI / 2 ) ) + c ;
163
- }
164
- private float SinEaseOut ( float t , float c , float d )
165
- {
166
- //Debug.LogFormat("SinEaseOut: {0} {1}", t, d);
167
- return c * Mathf . Sin ( t / d * ( Mathf . PI / 2 ) ) ;
168
- }
169
-
170
- private float Linear ( float t , float c , float d )
171
- {
172
- //Debug.LogFormat("Linear: {0} {1}", t, d);
173
- return c * t / d ;
174
- }
175
-
176
- private float CubicIn ( float t , float c , float d )
177
- {
178
- //Debug.LogFormat("CubicIn: {0} {1}", t, d);
179
- t /= d ;
180
- return c * t * t * t ;
181
- }
182
-
183
- private float CubicOut ( float t , float c , float d )
184
- {
185
- //Debug.LogFormat("CubicOut: {0} {1}", t, d);
186
- t /= d ;
187
- t -- ;
188
- return c * ( t * t * t + 1 ) ;
189
- }
190
-
191
- private float CubicInOut ( float t , float c , float d )
192
- {
193
- t /= d / 2 ;
194
- if ( t < 1 ) return c / 2 * t * t * t ;
195
- t -= 2 ;
196
- return c / 2 * ( t * t * t + 2 ) ;
197
- }
198
-
199
- private float QuintInOut ( float t , float c , float d )
200
- {
201
- t /= d / 2 ;
202
- if ( t < 1 ) return c / 2 * t * t * t * t * t ;
203
- t -= 2 ;
204
- return c / 2 * ( t * t * t * t * t + 2 ) ;
205
- }
206
144
}
207
145
}
0 commit comments