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]); } }
// 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); }