public void AddProject(KSProject project, string positioning) { MasterSettings ms = MasterSettings.me; ParticleSystem.Particle temp = new ParticleSystem.Particle(); int arraySize = particleSystem.GetParticles(particles); temp.size = ms.WindowSize; temp.color = KSJSON.me.parentCatColors[project.parentCat]; temp.startLifetime = int.MaxValue; temp.lifetime = int.MaxValue; switch(positioning.ToLower()) { case "scatter": temp.position = ScatterPosition(project); break; case "bar": default: temp.position = BarPosition(arraySize); break; } Array.Resize<ParticleSystem.Particle>(ref particles, arraySize + 1); particles[arraySize] = temp; particleSystem.SetParticles(particles, arraySize + 1); }
public void AddProject(KSProject project, string positioning) { MasterSettings ms = MasterSettings.me; ParticleSystem.Particle temp = new ParticleSystem.Particle(); int arraySize = particleSystem.GetParticles(particles); temp.size = ms.WindowSize; temp.color = KSJSON.me.parentCatColors[project.parentCat]; temp.startLifetime = int.MaxValue; temp.lifetime = int.MaxValue; switch (positioning.ToLower()) { case "scatter": temp.position = ScatterPosition(project); break; case "bar": default: temp.position = BarPosition(arraySize); break; } Array.Resize <ParticleSystem.Particle>(ref particles, arraySize + 1); particles[arraySize] = temp; particleSystem.SetParticles(particles, arraySize + 1); }
KSProject parseProjectLine(string line) { /**** Meta: Raised - float Goal - float backers - int comments - int parentCat - string lat - float lon - float *****/ KSProject proj = new KSProject(); string[] vals = line.Split(','); proj.raised = float.Parse(vals[1]); proj.goal = float.Parse(vals[0]); proj.backers = int.Parse(vals[2]); proj.comments = int.Parse(vals[3]); proj.parentCat = vals[4].Trim('"'); proj.lat = float.Parse(vals[5]); proj.lon = float.Parse(vals[6]); return proj; }
KSProject parseProjectLine(string line) { /**** * Meta: * Raised - float * Goal - float * backers - int * comments - int * parentCat - string * lat - float * lon - float *****/ KSProject proj = new KSProject(); string[] vals = line.Split(','); proj.raised = float.Parse(vals[1]); proj.goal = float.Parse(vals[0]); proj.backers = int.Parse(vals[2]); proj.comments = int.Parse(vals[3]); proj.parentCat = vals[4].Trim('"'); proj.lat = float.Parse(vals[5]); proj.lon = float.Parse(vals[6]); return(proj); }
Vector3 placeParticle(KSProject proj, KSMetric xMetric, KSMetric yMetric) { if (GraphAxis.me.yAxisVisible) { return(new Vector3(metricToValue(proj, xMetric), metricToValue(proj, yMetric))); } else { return(new Vector3(metricToValue(proj, xMetric), 0)); } }
Vector3 ScatterPosition(KSProject project) { float raisedMax = 10000f; float goalMax = 10000f; float backersMax = 1000f; float graphSize = 10f; float x = project.raised / raisedMax * graphSize; float y = project.backers / backersMax * graphSize; float z = project.goal / goalMax * graphSize; return(new Vector3(x, y, z)); }
public void OldAddProject(KSProject project) { MasterSettings ms = MasterSettings.me; GameObject temp = (GameObject)Instantiate(WinFab); temp.GetComponent<Window>().Project = project; temp.transform.parent = transform; temp.transform.localScale = Vector3.one * ms.WindowSize; temp.transform.localPosition = new Vector3(0,0,(float)windows.Count * (ms.WindowSize + ms.WindowSpacing)); mat.color = KSJSON.me.parentCatColors[project.parentCat]; temp.renderer.material = mat; windows.Add(temp); if(windows.Count % 1000 == 0 && false) { StaticBatch(); } }
public void OldAddProject(KSProject project) { MasterSettings ms = MasterSettings.me; GameObject temp = (GameObject)Instantiate(WinFab); temp.GetComponent <Window>().Project = project; temp.transform.parent = transform; temp.transform.localScale = Vector3.one * ms.WindowSize; temp.transform.localPosition = new Vector3(0, 0, (float)windows.Count * (ms.WindowSize + ms.WindowSpacing)); mat.color = KSJSON.me.parentCatColors[project.parentCat]; temp.renderer.material = mat; windows.Add(temp); if (windows.Count % 1000 == 0 && false) { StaticBatch(); } }
IEnumerator BuildProjects() { MasterSettings ms = MasterSettings.me; Debug.Log(projectQueue.Count); while (projectQueue.Count > 0) { timer += Time.deltaTime; //buildrate = 3f/(float)projectQueue.Count; while (timer > 0) { if (projectQueue.Count < 1) { break; } KSProject proj = (KSProject)projectQueue.Dequeue(); //Debug.Log(proj.ToString()); ParticleSystem.Particle temp = new ParticleSystem.Particle(); temp.size = ms.WindowSize; temp.color = KSJSON.me.parentCatColors[proj.parentCat]; temp.startLifetime = int.MaxValue; temp.lifetime = int.MaxValue; temp.position = placeParticle( proj, KSMetric.List[GA.xLabel], KSMetric.List[GA.yLabel] ); pps.projects.Add(proj); pps.particles.Add(temp); timer -= buildrate; GA.ProjectCount++; } pps.ToParticleSystem(particleSystem); yield return(null); } makeTris(); //Debug.Log("Finished Queue"); }
public void setProjects(KSProject[] projects) { ///Debug.Log(projects[0].name); ks_projects = projects; for(int i = 0; i < go_polyps.Length; i++) Destroy(go_polyps[i]); go_polyps = new GameObject[projects.Length]; makeNodes(); makeSpine(); makeSkin(); placePolyps(); foreach(MeshRenderer mr in GetComponentsInChildren<MeshRenderer>()) mr.material.color = Color.gray; }
IEnumerator streamCSVtoProjects(GameObject caller, string[] lines) { int i = 0; int chunk = 1000; KSProject[] projects = new KSProject[chunk]; KSProjectResponse response = new KSProjectResponse(); response.meta = new KSMeta(); while(i < lines.Length) { for(int j = 0; j < chunk && i < lines.Length; j++) { projects[j] = parseProjectLine(lines[i]); i++; } response.objects = projects; caller.GetComponent<City>().ProcessResponse(response); yield return null; } }
IEnumerator streamCSVtoProjects(GameObject caller, string[] lines) { int i = 0; int chunk = 1000; KSProject[] projects = new KSProject[chunk]; KSProjectResponse response = new KSProjectResponse(); response.meta = new KSMeta(); while (i < lines.Length) { for (int j = 0; j < chunk && i < lines.Length; j++) { projects[j] = parseProjectLine(lines[i]); i++; } response.objects = projects; caller.GetComponent <City>().ProcessResponse(response); yield return(null); } }
IEnumerator OldBuildProjects() { while (projectQueue.Count > 0) { timer += Time.deltaTime; //buildrate = 3f/(float)projectQueue.Count; while (timer > 0) { if (projectQueue.Count < 1) { break; } KSProject proj = (KSProject)projectQueue.Dequeue(); //Debug.Log(proj.ToString()); if (!buildings.ContainsKey(proj.parentCat)) { Vector3 loc = new Vector3(buildings.Count * 1.5f, 0, 0); loc = Vector3.zero; GameObject temp = (GameObject)Instantiate(BuildingFab); temp.transform.parent = transform; temp.transform.localPosition = loc; buildings.Add(proj.parentCat, temp); } //buildings[proj.parentCat].GetComponent<Building>().AddProject(proj); buildings[proj.parentCat].GetComponent <Building>().AddProject(proj, "scatter"); timer -= buildrate; } yield return(null); } //foreach(var building in buildings) //building.Value.GetComponent<Building>().StaticBatch(); //Debug.Log("Finished Queue"); }
public void AddProject(KSProject project) { AddProject(project, "Bar"); }
public void setProject(KSProject project) { this.project = project; //StartCoroutine(wiggle()); }
float zValue(KSProject proj, KSMetric zMetric) { return metricToValue(proj, zMetric); }
Vector3 placeParticle(KSProject proj, KSMetric xMetric, KSMetric yMetric) { if(GraphAxis.me.yAxisVisible) return new Vector3(metricToValue(proj, xMetric), metricToValue(proj, yMetric)); else return new Vector3(metricToValue(proj, xMetric), 0); }
float metricToValue(KSProject proj, KSMetric metric, string type) { string label = metric.Name; GeoBounds gb = GeoBounds.List[GA.Geographic]; if(label == "Latitude") return (proj.GetMetric("Lat") - gb.Bottom) * 10 / gb.Scale; if(label == "Longitude") return (proj.GetMetric("Lon") - gb.Left) * 10 / gb.Scale; float zoom = GA.zoom; float s, logValue; if(type == "linear") return proj.GetMetric(label) / metric.Zoom / zoom; else { //s ^ 10 = modifier * zoom * 10 //s ^ x = value s = Mathf.Log(metric.Zoom * zoom, 10); logValue = proj.GetMetric(label) > 0 ? Mathf.Log(proj.GetMetric(label), s) : 0; //Debug.Log(s + " ^ " + logValue + " = " + proj.GetMetric(label)); return logValue; } return 0; /* switch(label.ToLower()) //switch(label) { case "raised": if(type == "linear") return proj.raised / Modifiers["Raised"] / zoom; else { // s ^ 10 = modifier * zoom * 10 // s ^ x = value s = Mathf.Log(Modifiers["Raised"] * zoom, 10); logValue = proj.raised > 0 ? Mathf.Log(proj.raised, s) : 0; //Debug.Log(s + " ^ " + logValue + " = " + proj.raised); return logValue; } break; case "goal": //return proj.goal / Modifiers["Goal"] / zoom; val = proj.goal / Modifiers["Goal"] / zoom; if(type == "linear") return val; else { s = Mathf.Log(Modifiers["Goal"] * zoom, 10); logValue = proj.goal > 0 ? Mathf.Log(proj.goal, s) : 0; //Debug.Log(proj.raised + " ^ " + s + " = " + logValue); return logValue; } break; case "backers": //return proj.backers / Modifiers["Backers"] / zoom; if(type == "linear") return proj.backers / Modifiers["Backers"] / zoom; else { s = Mathf.Log(Modifiers["Backers"] * zoom, 10); logValue = proj.backers > 0 ? Mathf.Log(proj.backers, s) : 0; return logValue; } break; case "comments": //return proj.comments / Modifiers["Comments"] / zoom; if(type == "linear") return proj.comments / Modifiers["Comments"] / zoom; else { s = Mathf.Log(Modifiers["Comments"] * zoom, 10); logValue = proj.comments > 0 ? Mathf.Log(proj.comments, s) : 0; return logValue; } break; case "dpb": //return proj.backers == 0 ? 0 : proj.raised / proj.backers / Modifiers["DpB"] / zoom; if(type == "linear") return Mathf.Min(proj.backers, proj.raised) == 0 ? 0 : proj.raised / proj.backers / Modifiers["DpB"] / zoom; else { s = Mathf.Log(Modifiers["DpB"] * zoom, 10); logValue = proj.backers > 0 ? Mathf.Log(proj.raised / proj.backers, s) : 0; return logValue; } break; case "% raised": //return proj.raised / proj.goal / Modifiers["% Raised"] / zoom; if(type == "linear") return proj.raised / proj.goal / Modifiers["% Raised"] / zoom; else { s = Mathf.Log(Modifiers["DpB"] * zoom, 10); logValue = proj.raised > 0 ? Mathf.Log((proj.raised / proj.goal) + 1, s) : 0; return logValue; } break; case "latitude": return (proj.lat - gb.Bottom) * 10 / gb.Scale; break; case "longitude": return (proj.lon - gb.Left) * 10 / gb.Scale; break; case "zero": default: return 0; break; }*/ }
float metricToValue(KSProject proj, KSMetric metric) { return metricToValue(proj, metric, "linear"); }
Vector3 ScatterPosition(KSProject project) { float raisedMax = 10000f; float goalMax = 10000f; float backersMax = 1000f; float graphSize = 10f; float x = project.raised / raisedMax * graphSize; float y = project.backers / backersMax * graphSize; float z = project.goal / goalMax * graphSize; return new Vector3(x,y,z); }
float zValue(KSProject proj, KSMetric zMetric) { return(metricToValue(proj, zMetric)); }
float metricToValue(KSProject proj, KSMetric metric, string type) { string label = metric.Name; GeoBounds gb = GeoBounds.List[GA.Geographic]; if (label == "Latitude") { return((proj.GetMetric("Lat") - gb.Bottom) * 10 / gb.Scale); } if (label == "Longitude") { return((proj.GetMetric("Lon") - gb.Left) * 10 / gb.Scale); } float zoom = GA.zoom; float s, logValue; if (type == "linear") { return(proj.GetMetric(label) / metric.Zoom / zoom); } else { //s ^ 10 = modifier * zoom * 10 //s ^ x = value s = Mathf.Log(metric.Zoom * zoom, 10); logValue = proj.GetMetric(label) > 0 ? Mathf.Log(proj.GetMetric(label), s) : 0; //Debug.Log(s + " ^ " + logValue + " = " + proj.GetMetric(label)); return(logValue); } return(0); /* * switch(label.ToLower()) * //switch(label) * { * case "raised": * if(type == "linear") * return proj.raised / Modifiers["Raised"] / zoom; * else * { * // s ^ 10 = modifier * zoom * 10 * // s ^ x = value * s = Mathf.Log(Modifiers["Raised"] * zoom, 10); * logValue = proj.raised > 0 ? Mathf.Log(proj.raised, s) : 0; * * //Debug.Log(s + " ^ " + logValue + " = " + proj.raised); * return logValue; * } * break; * * case "goal": * //return proj.goal / Modifiers["Goal"] / zoom; * val = proj.goal / Modifiers["Goal"] / zoom; * if(type == "linear") * return val; * else * { * s = Mathf.Log(Modifiers["Goal"] * zoom, 10); * logValue = proj.goal > 0 ? Mathf.Log(proj.goal, s) : 0; * * //Debug.Log(proj.raised + " ^ " + s + " = " + logValue); * return logValue; * } * break; * * case "backers": * //return proj.backers / Modifiers["Backers"] / zoom; * if(type == "linear") * return proj.backers / Modifiers["Backers"] / zoom; * else * { * s = Mathf.Log(Modifiers["Backers"] * zoom, 10); * logValue = proj.backers > 0 ? Mathf.Log(proj.backers, s) : 0; * return logValue; * } * break; * case "comments": * //return proj.comments / Modifiers["Comments"] / zoom; * if(type == "linear") * return proj.comments / Modifiers["Comments"] / zoom; * else * { * s = Mathf.Log(Modifiers["Comments"] * zoom, 10); * logValue = proj.comments > 0 ? Mathf.Log(proj.comments, s) : 0; * return logValue; * } * break; * case "dpb": * //return proj.backers == 0 ? 0 : proj.raised / proj.backers / Modifiers["DpB"] / zoom; * if(type == "linear") * return Mathf.Min(proj.backers, proj.raised) == 0 ? 0 : proj.raised / proj.backers / Modifiers["DpB"] / zoom; * else * { * s = Mathf.Log(Modifiers["DpB"] * zoom, 10); * logValue = proj.backers > 0 ? Mathf.Log(proj.raised / proj.backers, s) : 0; * return logValue; * } * break; * case "% raised": * //return proj.raised / proj.goal / Modifiers["% Raised"] / zoom; * if(type == "linear") * return proj.raised / proj.goal / Modifiers["% Raised"] / zoom; * else * { * s = Mathf.Log(Modifiers["DpB"] * zoom, 10); * logValue = proj.raised > 0 ? Mathf.Log((proj.raised / proj.goal) + 1, s) : 0; * return logValue; * } * break; * case "latitude": * return (proj.lat - gb.Bottom) * 10 / gb.Scale; * break; * case "longitude": * return (proj.lon - gb.Left) * 10 / gb.Scale; * break; * case "zero": * default: * return 0; * break; * * }*/ }
float metricToValue(KSProject proj, KSMetric metric) { return(metricToValue(proj, metric, "linear")); }