@@ -119,6 +119,8 @@ public void CreateNewPlayer (string username, string avatarPath)
119119
120120 /**
121121 * Play a player event
122+ * - The logic that determines effects.
123+ * - For example, whether a GO with sprite animation or particle effect animation is attached, and what timeline animation (when tally twirls, etc.) is played.
122124 */
123125 public void PlayEvent ( FeedData feed )
124126 {
@@ -139,32 +141,64 @@ public void PlayEvent (FeedData feed)
139141
140142 // BATTLES ARE MORE COMPLEX
141143 if ( feed . eventType == "monster" ) {
142- StartCoroutine ( PlayBattle ( feed ) ) ;
144+ StartCoroutine ( PlayBattleEffects ( feed ) ) ;
143145 } else {
144146
145147
148+
149+
146150 // STREAM (CLICK or LIKE)
147151 if ( feed . eventType == "stream" ) {
148152 AttachDetachAnimation ( rippleAnim , false , 1f , 2.5f ) ;
153+ // play the timeline animation
154+ currentPlayerScript . animControllerScript . animName = "Pop_Shake_md" ;
149155 }
156+
150157 // ATTACK
151158 else if ( feed . eventType == "attack" ) {
152159 AttachDetachAnimation ( attackSpriteAnim , true , 2.3f , - 1 ) ;
160+ // play the timeline animation
161+ currentPlayerScript . animControllerScript . animName = "Swirl_r_sm" ;
153162 }
163+
154164 // BADGE
155165 else if ( feed . eventType == "badge" ) {
156166 // PLACEHOLDER
157167 AttachDetachAnimation ( triangleTrailsAnim , false , 1f , 2.5f ) ;
168+ // play the timeline animation
169+ currentPlayerScript . animControllerScript . animName = "Swirl_r_md" ;
158170 }
171+
159172 // CONSUMABLE
160173 else if ( feed . eventType == "consumable" ) {
161174 // PLACEHOLDER
162175 AttachDetachAnimation ( triangleTrailsAnim , false , 1f , 2.5f ) ;
176+ // play the timeline animation
177+ currentPlayerScript . animControllerScript . animName = "Pop_sm" ;
163178 }
179+
164180 // DISGUISE
165181 else if ( feed . eventType == "disguise" ) {
166182 // PLACEHOLDER
167183 AttachDetachAnimation ( triangleTrailsAnim , false , 1f , 2.5f ) ;
184+ // play the timeline animation
185+ currentPlayerScript . animControllerScript . animName = "Rotate_Pop_sm" ;
186+ }
187+
188+ // TRACKER
189+ else if ( feed . eventType == "tracker" ) {
190+ // PLACEHOLDER
191+ AttachDetachAnimation ( triangleTrailsAnim , false , 1f , 2.5f ) ;
192+ // play the timeline animation
193+ currentPlayerScript . animControllerScript . animName = "Rotate_md" ;
194+ }
195+
196+ // LEADERBOARD - not currently storing / sending with API
197+ else if ( feed . eventType == "leaderboard" ) {
198+ // PLACEHOLDER
199+ AttachDetachAnimation ( triangleTrailsAnim , false , 1f , 2.5f ) ;
200+ // play the timeline animation
201+ currentPlayerScript . animControllerScript . animName = "Pop_Shake_sm" ;
168202 }
169203
170204
@@ -176,8 +210,7 @@ public void PlayEvent (FeedData feed)
176210 // test
177211 //StartCoroutine (PlayBattle (feed));
178212
179- // play the timeline animation (loops, swirls, pops, etc.)
180- currentPlayerScript . animControllerScript . animEvent = feed . eventType ;
213+
181214 }
182215
183216
@@ -237,46 +270,20 @@ void AttachDetachAnimation (GameObject prefab, bool randomPosition, float scaleM
237270 Debug . Log ( "AttachDetachAnimation() prefab.name = " + prefab . name ) ;
238271
239272
240- // ATTACH GAME OBJECT WITH ANIM
241-
242- //// default position
243- //Vector3 instPos = Vector3.zero;
244-
245- //// or, set slightly random position
246- //if (randomPosition) instPos = new Vector3 (Random.Range (-2, 2), Random.Range (-2, 2), 0);
247-
248-
249-
250-
251-
252-
273+ // ATTACH THE GAME OBJECT WITH ANIMATION
253274
254275 // instantiate prefab, parent under the Player obj transform, position is local space
255276 GameObject obj = ( GameObject ) Instantiate ( prefab , currentPlayerScript . effects . transform , false ) ;
256277
257-
258- // MARKED FOR DELETION
259-
260- // disable so particle effect doesn't start yet
261- //obj.SetActive (false);
262- // parent under the player obj
263- //obj.transform.parent = currentPlayerScript.effects.transform;
264-
265-
266-
267278 // set slightly random position
268279 if ( randomPosition ) obj . transform . localPosition = new Vector3 ( Random . Range ( - 2 , 2 ) , Random . Range ( - 2 , 2 ) , 0 ) ;
269280 // or a default position
270281 else obj . transform . localPosition = Vector3 . zero ;
271282
272-
273283 // set scale
274284 obj . transform . localScale = Vector3 . one * scaleMultiplier ;
275285
276- // now that position is set turn it back on
277- //obj.SetActive (true);
278-
279- // set state
286+ // set state - not using this yet, but may need it
280287 currentPlayerScript . effectIsPlaying = true ;
281288
282289
@@ -286,6 +293,7 @@ void AttachDetachAnimation (GameObject prefab, bool randomPosition, float scaleM
286293 if ( destroyDelay < - 0.1f ) {
287294 // let the animation component destroy the gameobject after the last frame
288295 obj . GetComponent < FrameAnimation > ( ) . playOnceAndDestroy = true ;
296+ StartCoroutine ( ResetEffectPlayingState ( 1f ) ) ;
289297 }
290298 // should this function destroy the gameobject with the animation after n seconds?
291299 else if ( destroyDelay > 0.1f ) {
@@ -308,7 +316,7 @@ IEnumerator ResetEffectPlayingState (float wait)
308316
309317
310318
311- IEnumerator PlayBattle ( FeedData feed )
319+ IEnumerator PlayBattleEffects ( FeedData feed )
312320 {
313321 Debug . Log ( "PlayBattle() feed = " + feed . ToString ( ) ) ;
314322
0 commit comments