@@ -23,6 +23,11 @@ void OnDisable ()
2323 public GameObject playerPrefab ;
2424 public Dictionary < string , GameObject > playerDict ;
2525
26+ // player currently showing an event
27+ GameObject currentPlayer ;
28+ // player animation controller
29+ TallyAnimController playerCharacterAnim ;
30+
2631 // temp sprites for assigning avatars
2732 public Sprite [ ] avatars ;
2833
@@ -33,6 +38,7 @@ private void Awake ()
3338 playerDict = new Dictionary < string , GameObject > ( ) ;
3439 }
3540
41+
3642 /**
3743 * Remove all players from stage, reset dict
3844 */
@@ -97,62 +103,34 @@ public void CreateNewPlayer (string username)
97103
98104 public void PlayEvent ( FeedData feed )
99105 {
106+ //Debug.Log (DebugManager.GetSymbol ("smilingFace") + " PlayerManager.PlayEvent() [1] feed = " + feed.username.ToString ());
100107
101- //SoundManager.Instance.RandomSoundEffectIndex ();
102-
103-
104-
105- //float r = Random.Range (0f, 1f);
106- //if (r < .25f)
107- // AudioManager.Instance.Play ("Attack");
108- //else if (r < .5f)
109- // AudioManager.Instance.Play ("Badge");
110- //else if (r < .75f)
111- // AudioManager.Instance.Play ("Consumable");
112- //else if (r < 1f)
113- // AudioManager.Instance.Play ("Click");
114-
115-
116-
108+ // play matching sound
117109 AudioManager . Instance . Play ( feed . eventType ) ;
118110
111+ // get the player from the dict
112+ playerDict . TryGetValue ( feed . username , out currentPlayer ) ;
113+ if ( ! currentPlayer ) return ;
119114
120- Debug . Log ( DebugManager . GetSymbol ( "smilingFace" ) + " PlayerManager.PlayEvent() feed = " + feed . username . ToString ( ) ) ;
121115
116+ // MARKED FOR DELETION
117+ //// get player obj
118+ //GameObject playerCharacter;
119+ //TallyAnimController playerCharacterAnim;
120+ //// get the first child
121+ //playerCharacter = currentPlayer.transform.GetChild (0).gameObject;
122+ //Debug.Log (DebugManager.GetSymbol ("smilingFace") + " PlayerManager.PlayEvent() [2] - " + playerCharacter.name);
123+ //// get the animation controller
124+ //playerCharacterAnim = playerCharacter.GetComponent<TallyAnimController> ();
122125
123- // get player obj
124- GameObject player ;
125- GameObject playerCharacter ;
126- TallyAnimController playerCharacterAnim ;
127- playerDict . TryGetValue ( feed . username , out player ) ;
128- if ( ! player ) return ;
129126
130- // get the first child
131- playerCharacter = player . transform . GetChild ( 0 ) . gameObject ;
132-
133- Debug . Log ( DebugManager . GetSymbol ( "smilingFace" ) + " PlayerManager.PlayEvent() feed = " + playerCharacter . name ) ;
134127
135128 // get the animation controller
136- playerCharacterAnim = playerCharacter . GetComponent < TallyAnimController > ( ) ;
129+ playerCharacterAnim = currentPlayer . GetComponentInChildren < TallyAnimController > ( ) ;
137130
138131 // play the animation
139132 playerCharacterAnim . animEvent = feed . eventType ;
140133
141-
142- //// get random child
143- //Transform [] children = gameObject.GetComponentsInChildren<Transform> ();
144- //GameObject randomObject = children [Random.Range (0, children.Length)].gameObject;
145-
146- //// pick random anim
147- //int randomEventIndex = (int)Random.Range (1, 5);
148-
149-
150-
151- ////GameObject PlayerCharacter = randomObject.transform.GetChild (0).gameObject;
152- //TallyAnimController anim = randomObject.GetComponent<TallyAnimController> ();
153- //Debug.Log (randomObject.name + " - " + randomEventIndex);
154- //anim.currentAnimation = randomEventIndex;
155-
156134 }
157135
158136
0 commit comments