Skip to content

Commit 5a2857c

Browse files
committed
Connect all incoming tagMatches to monsters and trails
1 parent eb3b9eb commit 5a2857c

File tree

13 files changed

+251
-79
lines changed

13 files changed

+251
-79
lines changed

Assets/_Project/Scenes/tally-viz-master.unity

Lines changed: 21 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/_Project/Scripts/Core/DebugManager.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected DebugManager () { }
2020

2121
public TMP_Text debugText;
2222
public ScrollRect debugScrollRect;
23-
23+
public bool DEBUG;
2424

2525

2626

@@ -34,6 +34,9 @@ protected DebugManager () { }
3434

3535
private void Awake ()
3636
{
37+
DEBUG = false;
38+
39+
3740
AddSymbols ();
3841
// clear display
3942
ClearDisplay ();
@@ -129,6 +132,8 @@ public static string GetSymbol (string name)
129132
/// <param name="list"></param>
130133
public void PrintList (string str, List<int> list)
131134
{
135+
if (!DEBUG) return;
136+
132137
int i = 0;
133138
str += " [" + list.Count + "]: ";
134139
foreach (var item in list) {
@@ -139,8 +144,11 @@ public void PrintList (string str, List<int> list)
139144
}
140145

141146

147+
142148
public void PrintDict (string str, Dictionary<int, TrailingMonster> dict)
143149
{
150+
if (!DEBUG) return;
151+
144152
int i = 0;
145153
str += " [" + dict.Count + "]: ";
146154
foreach (KeyValuePair<int, TrailingMonster> t in dict) {

Assets/_Project/Scripts/Effects/Trail.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void UpdatePositions ()
9797
//trailWidth = siblingCount * .1f;
9898

9999
// set width based on the range + extra to cover the background
100-
trailWidth = trailsRange + widthExtra;
100+
trailWidth = Mathf.Min (trailsRange + widthExtra, 1.4f);
101101

102102
// set start and end width
103103
trailRenderer.startWidth = trailWidth; // 5 = 0.45f

Assets/_Project/Scripts/Effects/TrailManager.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections;
1+
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Linq;
45
using UnityEngine;
@@ -30,7 +31,7 @@ IEnumerator AddTestTrails (float wait)
3031
yield return new WaitForSeconds (wait);
3132

3233
// random num
33-
numberTrails = (int)Random.Range (minTrailCount, maxTrailCount);
34+
numberTrails = (int)UnityEngine.Random.Range (minTrailCount, maxTrailCount);
3435
// add trail
3536
for (int i = 0; i < numberTrails; i++) {
3637
AddTrail (i);
@@ -47,7 +48,10 @@ IEnumerator AddTestTrails (float wait)
4748
public void AddTrail (int _mid = -1)
4849
{
4950
// if at max trails
50-
if (trails.Count >= 8) return;
51+
if (trails.Count >= 8) {
52+
Debug.LogWarning ("trails.Count >= " + trails.Count);
53+
return;
54+
}
5155

5256
if (_mid < 1) {
5357
// get a random mid from those in the game
@@ -60,7 +64,7 @@ public void AddTrail (int _mid = -1)
6064
// if already exists then exit
6165
var exists = trails.Find (item => item.name.Equals (name));
6266
if (exists != null) {
63-
//Debug.Log ("TRAIL ALREADY EXISTS IN LIST");
67+
Debug.LogWarning ("TRAIL ALREADY EXISTS IN LIST");
6468
return;
6569
}
6670

@@ -88,6 +92,7 @@ public void RemoveTrail (int _mid = -1)
8892
break;
8993
}
9094
}
95+
//Debug.Log ("RemoveTrail(" + _mid + ") trails.Count = " + trails.Count + ", " + String.Join ("; ", trails));
9196
}
9297

9398
public void RemoveAllTrails ()

Assets/_Project/Scripts/Players/Monster.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void Init (int _mid)
4848
// random
4949
void SetSpriteInParticleSystem (int _mid = -1, int _gameMidsIndex = -1)
5050
{
51-
Debug.Log ("SetSpriteInParticleSystem() mid =" + mid + ", gameMidsIndex = " + gameMidsIndex);
51+
//Debug.Log ("SetSpriteInParticleSystem() mid =" + mid + ", gameMidsIndex = " + gameMidsIndex);
5252

5353
// choose random
5454
if (_mid < 1) {

Assets/_Project/Scripts/Players/MonsterIndex.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ private void Awake ()
5454
*/
5555
public int GetGameMidIndex (int _mid)
5656
{
57-
Debug.Log ("GetMonsterSpriteIndex() [1] _mid = " + _mid);
57+
//Debug.Log ("GetMonsterSpriteIndex() [1] _mid = " + _mid);
5858
int midSpriteIndex = -1;
5959
if (gameMids.Contains (_mid))
6060
midSpriteIndex = Array.IndexOf (gameMids, _mid);
61-
Debug.Log ("GetMonsterSpriteIndex() [2] midSpriteIndex = " + midSpriteIndex);
61+
//Debug.Log ("GetMonsterSpriteIndex() [2] midSpriteIndex = " + midSpriteIndex);
6262
return midSpriteIndex;
6363
}
6464

Assets/_Project/Scripts/Players/MonsterManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections;
1+
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using UnityEngine;
45

@@ -78,6 +79,7 @@ public void RemoveMonster (int _mid = -1)
7879
break;
7980
}
8081
}
82+
//Debug.Log ("RemoveMonster(" + _mid + ") monsters.Count = " + monsters.Count + ", " + String.Join ("; ", monsters));
8183
}
8284

8385
// test
@@ -94,11 +96,9 @@ public void RemoveAllMonsters ()
9496

9597
public void UpdateMonsterPositions ()
9698
{
97-
98-
99-
Debug.Log ("spawnPoints.Length = " + spawnPoints.Length);
100-
Debug.Log ("monsters.Count = " + monsters.Count);
101-
Debug.Log ("newTrailMids.Count = " + newTrailMids.Count);
99+
//Debug.Log ("spawnPoints.Length = " + spawnPoints.Length);
100+
//Debug.Log ("monsters.Count = " + monsters.Count);
101+
//Debug.Log ("newTrailMids.Count = " + newTrailMids.Count);
102102

103103
//for (int i = 0; i < monsters.Count; i++) {
104104
// // get mid of monster at i of monsters

Assets/_Project/Scripts/Players/Player.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ private void Awake ()
3636

3737
public void Init (FeedData _feedData)
3838
{
39-
//Debug.Log ("Player.Init() _username = " + _username);
40-
Debug.Log ("Player.Init() _feedData.tagMatches = " + _feedData.tagMatches);
39+
//Debug.Log ("Player.Init() _feedData.tagMatches = " + _feedData.tagMatches);
4140

4241
// test
4342
//SaveTagMatchesFromStream (_feedData.tagMatches);
@@ -46,6 +45,8 @@ public void Init (FeedData _feedData)
4645
username = _feedData.username;
4746
avatarPath = _feedData.avatarPath;
4847
lastActive = DateTime.Now;
48+
49+
Debug.Log ("Player.Init() username = " + username);
4950
}
5051

5152
/**
@@ -63,8 +64,11 @@ IEnumerator StartChecks ()
6364
/**
6465
* Parse the tagMatches (monsters) string from the stream and update trails and monster sprites
6566
*/
66-
public void SaveTagMatchesFromStream (string tagMatchesStr)
67+
public IEnumerator SaveTagMatchesFromStream (float wait, string tagMatchesStr)
6768
{
69+
// wait a second
70+
yield return new WaitForSeconds (wait);
71+
6872
// clear list
6973
tagMatchesMids.Clear ();
7074

@@ -104,7 +108,7 @@ public void SaveTagMatchesFromStream (string tagMatchesStr)
104108
}
105109
}
106110
// test
107-
DebugManager.Instance.PrintList ("\n\ntagMatchesMids " + username + " ", tagMatchesMids);
111+
DebugManager.Instance.PrintList ("tagMatchesMids " + username + " ", tagMatchesMids);
108112
// update trailing monsters, with random set to false
109113
StartCoroutine (trailingMonstersManager.UpdateTrailingMonsters (1f, false));
110114
}

Assets/_Project/Scripts/Players/PlayerManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public bool CreateNewPlayer (FeedData feedData)
270270
// store FeedData for zoom
271271
currentPlayerScript.feedData = feedData;
272272
// add the current monsters / trails for the player
273-
currentPlayerScript.SaveTagMatchesFromStream (feedData.tagMatches);
273+
StartCoroutine (currentPlayerScript.SaveTagMatchesFromStream (2.0f, feedData.tagMatches));
274274
}
275275
return true;
276276
}
@@ -299,7 +299,7 @@ public void PlayEvent (FeedData feedData)
299299
currentPlayerScript.feedData = feedData;
300300

301301
// update trailing monsters and trails
302-
currentPlayerScript.SaveTagMatchesFromStream (feedData.tagMatches);
302+
StartCoroutine (currentPlayerScript.SaveTagMatchesFromStream (.1f, feedData.tagMatches));
303303

304304
// show event in public var
305305
currentEventType = feedData.eventType;

0 commit comments

Comments
 (0)