public static void Main() { //Console.WriteLine(obj.readFile()); /* * string liney = "0.933979 0.179802 -0.308796 4128 2.04 188 DIPHDA; DENEB KAITOS"; * string[] wordies = liney.Split(' '); * List<string> listy = Words.getWords(wordies); * string[] finalprops = Words.getProperties(wordies); * * foreach(string name in listy) * { * Console.WriteLine(name); * } */ string path = @"/Users/eliaanagnostou/Documents/cs71/01-constellations/StarMap/Maps/Hydra.txt"; string text = @"0.994772 0.023164 -0.099456 28 4.61 3 0.972490 0.024187 0.231685 87 5.55 4 0.435119 0.012234 0.900290 144 5.57 7 0.998442 0.033711 -0.044468 315 6.43 11 0.998448 0.035746 -0.042707 352 6.18 14 0.873265 0.031968 0.486196 358 2.07 15 ALPHERATZ 0.512379 0.020508 0.858515 432 2.28 21 CAPH; CAS BETA 0.949168 0.037455 0.312534 448 5.57 22 0.882312 0.036017 -0.469285 493 5.42 24 0.697240 0.028641 -0.716265 496 3.88 25 0.980198 0.042952 0.193306 560 5.54 26 0.693047 0.031231 0.720216 571 5.01 27 0.135171 0.005924 -0.990805 636 5.29 30 0.962619 0.047354 -0.266689 693 4.89 33 0.883455 0.044652 -0.466383 720 5.41 34 0.816743 0.041844 -0.575482 739 5.24 35 0.963482 0.055705 0.261913 886 2.83 39 ALGENIB"; List <StarMapReader> starList = StarGroup.stringToList(text); List <StarMapReader> list = Star.GetList(); foreach (StarMapReader star in list) { Console.WriteLine(star.getX); } StarMapReader.RemoveAllStars(); foreach (StarMapReader star in list) { Console.WriteLine(star.getX); } //foreach(StarMapReader star in starList) //{ // Console.Write(star.getNames().Any()); //} //Console.WriteLine(StarMapReader.getCoordsByName("ALPHERATZ", starList).getX()); //Console.WriteLine(StarMapReader.getStarAmount(starList)); //Constellation con = Constellation.fileToList(path); //Console.WriteLine(con.getEndpointAt(3)); }
public override void OnDestroy() { base.OnDestroy(); mStarGroup = null; m_SkillTrans = null; mSkillIcons = null; mObjectCard = null; m_Point = null; ClearModel(); }
public override void InitUIData() { base.InitUIData(); m_HeroTypeImg = selfTransform.FindChild("Panel/LeftObj/HeroInfo/TypeImg").GetComponent <Image>(); m_ApitudeImg = selfTransform.FindChild("Panel/LeftObj/HeroInfo/ApitudeObj/ApitudeType").GetComponent <Image>(); m_StarGroupTrans = selfTransform.FindChild("Panel/LeftObj/HeroInfo/StarGroup"); m_ExpSlider = selfTransform.FindChild("Panel/LeftObj/HeroInfo/Slider").GetComponent <Slider>(); m_HeroModle = selfTransform.FindChild("Panel/LeftObj/heroImg").GetComponent <Image>(); m_SkillTrans = new List <Transform>(); for (int i = 0; i < 6; i++) { Transform trans = selfTransform.FindChild("Panel/RightObj/ItemList/Panel/AttriObj3/Grid/Item" + i); m_SkillTrans.Add(trans); SkillIconItem item = new SkillIconItem(trans); mSkillIcons.Add(item); } mStarGroup = new StarGroup(m_StarGroupTrans); }
StarGroup[] GetConstellations(List <int> HRs, Star[] stars) { //find index of star with corresponding HR number List <int> orderedIndexs = new List <int>(); for (int i = 0; i < HRs.Count; i++) { int index = Array.IndexOf(stars, Array.Find(stars, s => s.HR_Number == HRs[i])); orderedIndexs.Add(index); } Debug.Log("Number of Links: " + orderedIndexs.Count / 2); //group together nodes List <List <int> > constellationGroups = new List <List <int> >(); for (int i = 0; i < orderedIndexs.Count; i += 2) { //find if any of the lists contains as its last element, any of the two points int index = -1; int matchIndex = -1; for (int j = 0; j < constellationGroups.Count; j++) { int lastValue = constellationGroups[j][constellationGroups[j].Count - 1]; if (lastValue == orderedIndexs[i]) { index = j; matchIndex = 0; } if (lastValue == orderedIndexs[i + 1]) { index = j; matchIndex = 1; } } if (index != -1) { if (matchIndex == 0) { constellationGroups[index].Add(orderedIndexs[i]); constellationGroups[index].Add(orderedIndexs[i + 1]); } if (matchIndex == 1) { constellationGroups[index].Add(orderedIndexs[i + 1]); constellationGroups[index].Add(orderedIndexs[i]); } } else //else make a new list { List <int> newList = new List <int>(); newList.Add(orderedIndexs[i]); newList.Add(orderedIndexs[i + 1]); constellationGroups.Add(newList); } } Debug.Log("Number of groups: " + constellationGroups.Count); //convert each list to world space coordinates List <StarGroup> output = new List <StarGroup>(); for (int i = 0; i < constellationGroups.Count; i++) { List <Vector3> group = new List <Vector3>(); for (int j = 0; j < constellationGroups[i].Count; j++) { group.Add(stars[constellationGroups[i][j]].WorldPosition); } StarGroup newStarGroup = new StarGroup(); newStarGroup.starConnections = group.ToArray(); output.Add(newStarGroup); } return(output.ToArray()); }