public void LoadHighScore() { TargetHighScore.Clear(); string[] HighScoreView = RequestOutput.CurrentValue.Split('|'); for (int i = 0; i < HighScoreView.Length - 1; i++) { CHighScore newscore = new CHighScore(); string[] HighScoreElement = HighScoreView[i].Split(';'); newscore.ID = HighScoreElement[0]; newscore.Name = HighScoreElement[2]; newscore.Score = HighScoreElement[4]; TargetHighScore.Add(newscore); } //--Add List To UI for (int i = 0; i < TargetHighScore.Count; i++) { GameObject tempScoreRow = GameObject.Instantiate(TargetContentRow, TargetContent.transform); tempScoreRow.GetComponent <SessionScoreRow>().CaptionNo.text = (i + 1).ToString(); tempScoreRow.GetComponent <SessionScoreRow>().CaptionID.text = TargetHighScore[i].ID; tempScoreRow.GetComponent <SessionScoreRow>().CaptionName.text = TargetHighScore[i].Name; tempScoreRow.GetComponent <SessionScoreRow>().CaptionScore.text = TargetHighScore[i].Score.ToString(); } }
public void LoadSessionScore() { for (int i = 0; i < SessionList.StringListValue.Count; i++) { float totalScore = 0; string[] tempName = SessionList.StringListValue[i].Split('.'); CHighScore newscore = new CHighScore(); newscore.ID = tempName[0]; int LetterIndex = 65; int MaxLetterIndex = 90; bool loopLetter = true; while (loopLetter && LetterIndex <= MaxLetterIndex) { int NumberIndex = 1; int MaxNumberIndex = 15; bool loopNumber = true; while (loopNumber && NumberIndex <= MaxNumberIndex) { string ScoreFileName = newscore.ID + ".LV" + GetChar(LetterIndex) + ".Play" + SetNumberStringZero(NumberIndex) + ".Score.xml"; string FullPathFile = SessionConfig.GetDataSessionDirectory() + ScoreFileName; if (File.Exists(FullPathFile)) { string tempxml = System.IO.File.ReadAllText(FullPathFile); XmlDocument xmldoc; XmlNodeList xmlnodelist; XmlNode xmlnode; xmldoc = new XmlDocument(); xmldoc.LoadXml(tempxml); xmlnodelist = xmldoc.GetElementsByTagName("SessionValue"); totalScore += float.Parse(xmlnodelist.Item(0).InnerText.Trim()); } NumberIndex++; } LetterIndex++; } newscore.Score = totalScore; if (SessionName.CurrentValue == newscore.ID) { //Debug.Log(newscore.Score); } //-- input to server } }
static int SortByScore(CHighScore p1, CHighScore p2) { return(p2.Score.CompareTo(p1.Score)); }
public void LoadSessionScore() { TargetHighScore.Clear(); for (int i = 0; i < SessionList.StringListValue.Count; i++) { CHighScore newscore = new CHighScore(); float totalScore = 0; string[] tempName = SessionList.StringListValue[i].Split('.'); newscore.Name = tempName[0]; int LetterIndex = 65; int MaxLetterIndex = 90; bool loopLetter = true; while (loopLetter && LetterIndex <= MaxLetterIndex) { int NumberIndex = 1; int MaxNumberIndex = 15; bool loopNumber = true; while (loopNumber && NumberIndex <= MaxNumberIndex) { string ScoreFileName = newscore.Name + ".Level" + GetChar(LetterIndex) + NumberIndex + ".Score.xml"; string FullPathFile = SessionConfig.GetDataSessionDirectory() + ScoreFileName; if (File.Exists(FullPathFile)) { string tempxml = System.IO.File.ReadAllText(FullPathFile); XmlDocument xmldoc; XmlNodeList xmlnodelist; XmlNode xmlnode; xmldoc = new XmlDocument(); xmldoc.LoadXml(tempxml); xmlnodelist = xmldoc.GetElementsByTagName("SessionValue"); totalScore += float.Parse(xmlnodelist.Item(0).InnerText.Trim()); } else { loopNumber = false; } NumberIndex++; } LetterIndex++; } newscore.Score = totalScore; //Add New Score TargetHighScore.Add(newscore); /* * string FullPathFile = SessionConfig.GetSessionDirectory() + SessionList.StringListValue[i]; * if (File.Exists(FullPathFile)) * { * string tempxml = System.IO.File.ReadAllText(FullPathFile); * * XmlDocument xmldoc; * XmlNodeList xmlnodelist; * XmlNode xmlnode; * xmldoc = new XmlDocument(); * xmldoc.LoadXml(tempxml); * * xmlnodelist = xmldoc.GetElementsByTagName("LevelTotal"); * int total = int.Parse(xmlnodelist.Item(0).InnerText.Trim()); * * for (int j = 0; j < total; j++) * { * xmlnodelist = xmldoc.GetElementsByTagName("Score" + (j + 1).ToString()); * tempScore += float.Parse(xmlnodelist.Item(0).InnerText.Trim()); * } * } * * newscore.Score = tempScore; * * //Add New Score * TargetHighScore.Add(newscore); */ } //TargetHighScore.Sort(SortByScore); //--Add List To UI for (int i = 0; i < TargetHighScore.Count; i++) { GameObject tempScoreRow = GameObject.Instantiate(TargetContentRow, TargetContent.transform); tempScoreRow.GetComponent <SessionScoreRow>().CaptionNo.text = (i + 1).ToString(); tempScoreRow.GetComponent <SessionScoreRow>().CaptionName.text = TargetHighScore[i].Name; tempScoreRow.GetComponent <SessionScoreRow>().CaptionScore.text = TargetHighScore[i].Score.ToString(); } }