public void SelectWord(string word) { if (_lastSelectedWord != word) { if (_annualWords == null) { _annualWords = new AnnualWordList(); _annualWords.Load(); } resetColor(); showConnections(word); // Get an array of years by word uint[] years = _annualWords.GetYearsByTopWord(word); string result = string.Join(",", System.Array.ConvertAll <uint, string> (years, System.Convert.ToString)); Debug.Log("Years for '" + word + "' are " + result); _linkWiresNodes = years; _lastSelectedWord = word; if (clickedWord != null) { // Check attribute of the word clickedWord.GetComponent <TextMeshPro> ().text = word; clickedWord.GetComponent <TextMeshPro> ().faceColor = getColor(word); //new Color32 (255, 0, 0, 255); clickedWord.GetComponent <TextMeshPro> ().fontMaterial.SetColor("_GlowColor", UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f)); //set lineColor lineColor = getColor(word); } } }
void Start() { AnnualWordList annualWords = new AnnualWordList(); annualWords.Load(); Vector3 center = centerPosition; for (int i = 0; i < numObjects; i++, yearStart++) { int a = 360 / numObjects * i; Vector3 pos = RandomCircle(center, radius, a); GameObject yearName = Instantiate(prefab, pos, Quaternion.LookRotation(pos - center)); yearName.transform.parent = this.transform; yearName.GetComponent <TextMeshPro>().text = yearStart.ToString(); yearName.GetComponent <TextMeshPro>().faceColor = new Color32(255, 0, 0, 255); yearName.GetComponent <TextMeshPro>().fontMaterial.SetColor("_GlowColor", UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f)); yearName.gameObject.name = yearStart.ToString(); //yearName.GetComponent<LyricSpawner> ().GenerateWords (yearName.transform); List <TopWord> annualTopWords = annualWords.GetTopWordsByYear((uint)yearStart, LyricSpawner.NUM_WORDS); //Year, top#3 UnityEngine.Debug.Log(yearStart.ToString() + " : " + annualTopWords[0].Word + "and" + annualTopWords[0].Polarity + " and " + annualTopWords[1].Word + " and " + annualTopWords[2].Word); yearName.GetComponent <LyricSpawner>().GenerateWords(yearName.transform, annualTopWords[0].Word, annualTopWords[1].Word, annualTopWords[2].Word); } // now it includes only top three - for debugging only uint[] years = annualWords.GetYearsByTopWord("love"); string result = string.Join(",", System.Array.ConvertAll <uint, string>(years, System.Convert.ToString)); Debug.Log("Years for 'love' are " + result); //Debug.Log("Coming out here!!"); }
// Use this for initialization void Start() { for (int i = 1965; i < 2015; i++) { GameObject year = GameObject.Find(i.ToString()); allYears.Add(year); } AnnualWordList annualWords = new AnnualWordList(); annualWords.Load(); uint[] commanYears; commanYears = annualWords.GetYearsByTopWord("girl"); for (int i = 0; i < commanYears.Length; i++) { Debug.Log(commanYears[i]); } }
void Start() { AnnualWordList annualWords = new AnnualWordList(); annualWords.Load(); Vector3 center = centerPosition; float latitude = (180.0f - angleMargin * 2) / (totalSpawners - 1) * (latitudeIndex - 1) + angleMargin - 90.0f; WireframeNodes.RegisterCenterSphere(centerPosition, radius); //WireframeNodes.NorthPole = new Vector3 (center.x, center.y + 2 * radius, center.z); WireframeNodes.RegisterNorthPole(RandomCircleOnSphere(center, radius, 0f, 90f)); for (int i = 0; i < numObjects; i++, yearStart++) { float longitude = 360.0f / numObjects * i; Vector3 pos = RandomCircleOnSphere(center, radius, longitude, latitude); // Debug.Log (string.Format ("Generating pos {0}, {1} for {2} at year {3}", longitude, latitude, latitudeIndex, yearStart)); GameObject yearName = Instantiate(prefab, pos, Quaternion.LookRotation(pos - center)); yearName.transform.parent = this.transform; // saving the position to Wireframe Nodes Vector3 offsetPos = RandomCircleOnSphere(center, radius, longitude + AngleOffset, latitude); WireframeNodes.RegisterNode((uint)yearStart, offsetPos, longitude + AngleOffset, latitude); yearName.GetComponent <TextMeshPro> ().text = yearStart.ToString(); // yearName.GetComponent<TextMeshPro> ().faceColor = new Color32 (255, 0, 0, 255); yearName.GetComponent <TextMeshPro> ().fontMaterial.SetColor("_GlowColor", UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f)); yearName.gameObject.name = yearStart.ToString(); //yearName.GetComponent<LyricSpawner> ().GenerateWords (yearName.transform); List <TopWord> annualTopWords = annualWords.GetTopWordsByYear((uint)yearStart, LyricSpawner.NUM_WORDS); //Year, top#3 // UnityEngine.Debug.Log(yearStart.ToString() + " : " + annualTopWords[0].Word + "and" + annualTopWords[0].Polarity + " and " + annualTopWords[1].Word + " and " + annualTopWords[2].Word); yearName.GetComponent <LyricSpawner>().GenerateWords(yearName.transform, annualTopWords.ToArray()); } }
// Use this for initialization void Start() { nodeLinkList = new List <int>(); int i = 0; while (i < 100) { float x = UnityEngine.Random.Range(-35, 35); float z = UnityEngine.Random.Range(-35, 35); float y = UnityEngine.Random.Range(5, 15); Collider[] hitColliders = Physics.OverlapSphere(new Vector3(x, y, z), 5); if (hitColliders.Length == 0) { GameObject networkNode = Instantiate(node, new Vector3(x, y, z), Quaternion.identity); networkNode.GetComponent <Renderer>().material.color = UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f); networkNode.GetComponent <PlanetSpawner>().SpawnPlanets(networkNode.transform); Nodes.Add(networkNode); i++; } } link = Nodes[20].GetComponent <LineRenderer>(); link.SetPosition(0, Nodes[20].transform.position); link.SetPosition(1, Nodes[30].transform.position); for (int j = 0; j < 100; j++) { int rand = UnityEngine.Random.Range(0, 99); nodeLinkList.Add(rand); } for (int j = 0; j < 100; j += 2) { link = Nodes[nodeLinkList[j]].GetComponent <LineRenderer>(); link.SetPosition(0, Nodes[nodeLinkList[j]].transform.position); link.SetPosition(1, Nodes[nodeLinkList[j + 1]].transform.position); } //import billboard data //Get all top 3 words in all songs DataSource songList = new DataSource(); songList.Load(); List <SongInfo> allSongs = songList.GetAllSongs(); // example reading data UnityEngine.Debug.Log(allSongs[1].ToString()); //Get annual top 3 words AnnualWordList annualWords = new AnnualWordList(); annualWords.Load(); List <TopWord> annualTopWords = annualWords.GetTopWordsByYear(1983, 3); //Year, top#3 UnityEngine.Debug.Log(annualTopWords[0].Word); //Get top words over the years List <TopWord> topWords = annualWords.GetTopWords(3); String toPrint = String.Format("Word:{0}, Polarity:{1}", topWords [0].Word, topWords [0].Polarity); UnityEngine.Debug.Log(toPrint); // Get an array of years by word uint[] years = annualWords.GetYearsByTopWord("right"); string result = string.Join(",", System.Array.ConvertAll <uint, string>(years, System.Convert.ToString)); Debug.Log("Years for 'right' are " + result); years = annualWords.GetYearsByTopWord("see"); result = string.Join(",", System.Array.ConvertAll <uint, string>(years, System.Convert.ToString)); Debug.Log("Years for 'see' are " + result); }