Skip to content

Commit eb3b9eb

Browse files
committed
Connects trails to TrailingMonstersManager
1 parent 0123569 commit eb3b9eb

File tree

12 files changed

+483
-215
lines changed

12 files changed

+483
-215
lines changed

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

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

Assets/_Project/Scripts/Core/ColorManager.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ protected ColorManager () { }
3030

3131

3232
static string [] colors = {
33-
"5f1475", "5f1475", "f4e713", "8820aa", "42da82", "f413bc", "3f0236", "42da82", "31a8cb", "42da82", "f413bc", "ec391a", "6261a8", "ec391a", "4d7bbd", "4d7bbd", "6261a8", "5f1475", "31a8cb", "ec391a", "6939ac", "6261a8", "6939ac", "48daa3", "ec391a", "5f40bd", "f413bc", "5f40bd", "6939ac", "074381", "5f40bd", "6939ac", "6939ac", "074381", "5f40bd", "de2319", "058eb8", "5f1475", "6939ac", "5f1475", "074381", "de2319", "463260", "ae1ff1", "ae1ff1", "ae1ff1", "69004b", "5300e3", "129740", "f413bc", "ae1ff1", "de2319", "418fb0", "418fb0", "5f1475", "074381", "ae1ff1", "463260", "a43a9f", "0356d8", "ae1ff1", "f3af1f", "5f1475", "a6134c", "02b65c", "ef4138", "de2dca", "63fbf0", "63fbf0", "63fbf0", "5300e3", "5f1475", "8336bd", "3957c9", "3957c9", "a6134c", "a6134c", "a6134c", "a6134c", "a6134c", "ce218d", "074381", "5f1475", "ef4138", "ef4138", "ef4138", "90c053", "ef4138", "5fadd1", "f41182", "5f1475", "ef4138", "5f1475", "42da82", "5300e3", "5300e3", "5300e3", "5bd6fa", "1f4fbc", "5300e3", "60139b", "f413bc", "5f1475"
33+
"5f1475", "5f1475", "f4e713", "8820aa", "42da82", "f413bc", "3f0236", "42da82", "31a8cb", "42da82", "f413bc", "ec391a", "6261a8", "ec391a", "4d7bbd", "4d7bbd", "6261a8", "5f1475",
34+
"31a8cb", "ec391a", "6939ac", "6261a8", "6939ac", "48daa3", "ec391a", "5f40bd", "f413bc", "5f40bd", "6939ac", "074381", "5f40bd", "6939ac", "6939ac", "074381", "5f40bd", "de2319",
35+
"058eb8", "5f1475", "6939ac", "5f1475", "074381", "de2319", "463260", "ae1ff1", "ae1ff1", "ae1ff1", "69004b", "5300e3", "129740", "f413bc", "ae1ff1", "de2319", "418fb0", "418fb0",
36+
"5f1475", "074381", "ae1ff1", "463260", "a43a9f", "0356d8", "ae1ff1", "f3af1f", "5f1475", "a6134c", "02b65c", "ef4138", "de2dca", "63fbf0", "63fbf0", "63fbf0", "5300e3", "5f1475",
37+
"8336bd", "3957c9", "3957c9", "a6134c", "a6134c", "a6134c", "a6134c", "a6134c", "ce218d", "074381", "5f1475", "ef4138", "ef4138", "ef4138", "90c053", "ef4138", "5fadd1", "f41182",
38+
"5f1475", "ef4138", "5f1475", "42da82", "5300e3", "5300e3", "5300e3", "5bd6fa", "1f4fbc", "5300e3", "60139b", "f413bc", "5f1475"
3439
};
3540

3641

3742

43+
3844
// dictionary of all marketing colors, with mids as keys
3945
public static Dictionary<int, MarketingColor> MarketingColorDict = new Dictionary<int, MarketingColor> () {
4046

@@ -71,6 +77,16 @@ protected ColorManager () { }
7177
{ 110, new MarketingColor{ category = "Energy", colorStr = "fd27b0"} }
7278
};
7379

80+
// dictionary of all "first party tracker" colors, with mids as keys
81+
public static Dictionary<int, MarketingColor> FirstPartyMarketingColorDict = new Dictionary<int, MarketingColor> () {
82+
83+
{ 995, new MarketingColor{ category = "First party", colorStr = "78068C"} },
84+
{ 996, new MarketingColor{ category = "First party", colorStr = "77289E"} },
85+
{ 997, new MarketingColor{ category = "First party", colorStr = "915EBD"} },
86+
{ 998, new MarketingColor{ category = "First party", colorStr = "5D5179"} },
87+
{ 999, new MarketingColor{ category = "First party", colorStr = "571F4E"} }
88+
};
89+
7490

7591

7692
private void Awake ()

Assets/_Project/Scripts/Core/DebugManager.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,61 @@ public static string GetSymbol (string name)
121121
}
122122

123123

124+
125+
/// <summary>
126+
/// Print a list of integers
127+
/// </summary>
128+
/// <param name="str"></param>
129+
/// <param name="list"></param>
130+
public void PrintList (string str, List<int> list)
131+
{
132+
int i = 0;
133+
str += " [" + list.Count + "]: ";
134+
foreach (var item in list) {
135+
if (++i > 1) str += ", ";
136+
str += item.ToString ();
137+
}
138+
Debug.Log (str);
139+
}
140+
141+
142+
public void PrintDict (string str, Dictionary<int, TrailingMonster> dict)
143+
{
144+
int i = 0;
145+
str += " [" + dict.Count + "]: ";
146+
foreach (KeyValuePair<int, TrailingMonster> t in dict) {
147+
if (++i > 1) str += ", ";
148+
str += dict [t.Key].mid + "-" + dict [t.Key].passes;
149+
}
150+
Debug.Log (str);
151+
}
152+
153+
154+
155+
/// <summary>
156+
/// Return list of random integers
157+
/// </summary>
158+
/// <param name="lengthMin">Minimum list length</param>
159+
/// <param name="lengthMax">Maximum list length</param>
160+
/// <param name="rangeMin">Minimum range for each index</param>
161+
/// <param name="rangeMax">Maximum range for each index</param>
162+
/// <returns></returns>
163+
public List<int> GetListOfRandomInts (int lengthMin, int lengthMax, int rangeMin, int rangeMax)
164+
{
165+
// create list
166+
List<int> newList = new List<int> ();
167+
// use random number for length
168+
int numberToAdd = (int)Random.Range (lengthMin, lengthMax);
169+
// loop and add ints
170+
for (int i = 0; i < numberToAdd; i++) {
171+
// random int
172+
//newList [i] = (int)Random.Range (rangeMin, rangeMax);
173+
// random mid
174+
newList.Add (MonsterIndex.Instance.GetRandomMid (rangeMin, rangeMax));
175+
}
176+
return newList;
177+
}
178+
179+
180+
124181
}

Assets/_Project/Scripts/Data/DataManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ public void HandleJsonResponse (string text)
427427
string _createdAtStr = item.GetValue ("createdAt").ToString ();
428428
string _monsters = item.GetValue ("monsters").ToString ();
429429
string _trackers = item.GetValue ("trackers").ToString ();
430+
string _tagMatches = item.GetValue ("tagMatches").ToString ();
430431

431432
// parse string to ISO 8601 format
432433
DateTime _createdAt = DateTime.Parse (_createdAtStr, null, System.Globalization.DateTimeStyles.RoundtripKind);
@@ -525,6 +526,7 @@ public void HandleJsonResponse (string text)
525526
output.createdAt = _createdAt;
526527
output.monsters = _monsters;
527528
output.trackers = _trackers;
529+
output.tagMatches = _tagMatches;
528530

529531

530532

Assets/_Project/Scripts/Effects/Trail.cs

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class Trail : MonoBehaviour {
88
public GameObject avatar;
99
public TrailRenderer trailRenderer;
1010
public int mid;
11+
public int passes;
1112
public int siblingCount;
1213
public int trailIndex;
1314

@@ -19,6 +20,8 @@ public class Trail : MonoBehaviour {
1920
public float positionMax = 1.5f;
2021
// Minimum position for overall trail edge
2122
public float positionMin = -1.5f;
23+
// range between the positionMax and positionMin
24+
float positionRange = 1.5f - -1.5f;
2225
// Extra amount added to width to hide background
2326
public float widthExtra = 0.01f;
2427
// length scale
@@ -27,9 +30,21 @@ public class Trail : MonoBehaviour {
2730

2831

2932

33+
private void Awake ()
34+
{
35+
// get renderer
36+
trailRenderer = GetComponent<TrailRenderer> ();
37+
// disable until position is set
38+
trailRenderer.enabled = false;
39+
trailRenderer.emitting = false;
40+
41+
// set trail color
42+
SetColor ();
43+
}
44+
3045
/**
31-
* Set color on start
32-
*/
46+
* Set color on start
47+
*/
3348
public void SetColor ()
3449
{
3550
// get from mid
@@ -45,66 +60,62 @@ public void SetColor ()
4560
}
4661

4762

48-
private void Awake ()
63+
public void UpdatePositions ()
4964
{
50-
// get renderer
51-
trailRenderer = GetComponent<TrailRenderer> ();
52-
// disable until position is set
53-
trailRenderer.enabled = false;
54-
trailRenderer.emitting = false;
55-
}
65+
//Debug.Log ("Trail.UpdatePositions() called");
5666

5767

58-
public void Init ()
59-
{
60-
//Debug.Log ("Init() called on Trail");
68+
// POSITION
6169

62-
// set trail color
63-
SetColor ();
64-
65-
66-
// number of siblings (other trails)
70+
// set siblings count (other trails)
6771
siblingCount = transform.parent.childCount;
68-
// define the width by the number of trails
69-
trailWidth = siblingCount * .1f;
70-
// set the position of this trail by its index in the hierarchy
71-
trailIndex = transform.GetSiblingIndex ();
72-
7372

74-
// range between the positionMax and positionMin
75-
float positionRange = positionMax - positionMin;
73+
// set trail index by its position in the hierarchy
74+
trailIndex = transform.GetSiblingIndex ();
7675

77-
// sets positionsByIndex array by number of trails
76+
// update array length to total number of trails
7877
positionsByIndex = new float [siblingCount];
7978

8079
// calculate range between each trail
8180
float trailsRange = positionRange / (siblingCount);
8281

83-
// place trails so the outer edges are touching positionMin and positionMax
82+
// create positions, placing trails so the outer edges are touching positionMin and positionMax
8483
for (int i = 0; i < siblingCount; i++) {
8584
// starts with positionMin plus an offset that lets the trail edge touch it
86-
positionsByIndex [i] = positionMin + (trailsRange * (i + 0.5f)); // the 0.5 places it in the middle of the range, or something
87-
} // tbh I don't really know, I'm just glad it works
88-
89-
// set the trail width to the range plus a 'lil extra to cover the background
90-
trailWidth = trailsRange + widthExtra;
91-
92-
// how long trail lasts, a.k.a. its length
93-
trailRenderer.time = siblingCount * lengthScale;
85+
// the 0.5 places it in the middle of the range, or something
86+
// tbh I don't really know, I'm just glad it works
87+
positionsByIndex [i] = positionMin + (trailsRange * (i + 0.5f));
88+
}
9489

9590
// set offset based on index
9691
transform.localPosition = new Vector3 (0, positionsByIndex [trailIndex], 0);
9792

98-
// set w & h
93+
94+
// WIDTH
95+
96+
// set width based on the number of trails
97+
//trailWidth = siblingCount * .1f;
98+
99+
// set width based on the range + extra to cover the background
100+
trailWidth = trailsRange + widthExtra;
101+
102+
// set start and end width
99103
trailRenderer.startWidth = trailWidth; // 5 = 0.45f
100104
trailRenderer.endWidth = trailWidth;
101105

102-
// set vertices
106+
107+
// OPTIONS
108+
109+
// set vertices - how smooth the corners are
103110
trailRenderer.numCornerVertices = 10;
104111
trailRenderer.numCapVertices = 5;
105112

113+
// set length - how long trail lasts
114+
trailRenderer.time = siblingCount * lengthScale;
115+
106116
//trailRenderer.sortingOrder = avatar.GetComponent<SpriteRenderer> ().sortingOrder;
107117

118+
// enable and start emitting after all parameters are set
108119
trailRenderer.enabled = true;
109120
trailRenderer.emitting = true;
110121
}

0 commit comments

Comments
 (0)