public override void StartEditingTeam(int InTeamIndex) { if (Global.AllData == null || CurPool == EPool.None || (int)CurPool >= Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools.Count || InTeamIndex < 0 || InTeamIndex >= Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[(int)CurPool].Teams.Count) { return; } RoutineScoreData SData = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[(int)CurPool].Teams[InTeamIndex].Data.RoutineScores; if (SData != null && SData.DiffResults != null) { CurData = null; base.StartEditingTeam(InTeamIndex); foreach (ExData ed in SData.ExResults) { if (ed.JudgeNameId == GetJudgeNameId()) { CurData = ed; break; } } if (CurData == null) { CurData = new ExData(CurDivision, CurRound, CurPool, InTeamIndex); } } UpdatePoints(); }
public static ExData Load(Stream InStream) { XmlSerializer serializer = new XmlSerializer(typeof(ExData)); ExData LoadedData = serializer.Deserialize(InStream) as ExData; return(LoadedData); }
public override void SendResultsToHeadJudger(int InDiv, int InRound, int InPool, int InTeam) { base.SendResultsToHeadJudger(InDiv, InRound, InPool, InTeam); Debug.Log(" SendResultsToHeadJudger " + InDiv + " " + InRound + " " + InPool + " " + InTeam); RoutineScoreData SData = Global.AllData.AllDivisions[InDiv].Rounds[InRound].Pools[InPool].Teams[InTeam].Data.RoutineScores; CurData.Division = (EDivision)InDiv; CurData.Round = (ERound)InRound; CurData.Pool = (EPool)InPool; CurData.Team = InTeam; CurData.JudgeNameId = GetJudgeNameId(); SData.SetExResults(CurData); if (Networking.IsConnectedToServer) { Debug.Log(" send ex data to server " + CurData.Point1Count); Global.NetObj.ClientSendFinishJudgingEx(CurData.SerializeToString()); } else { CachedData = new ExData(CurData); Networking.bNeedSendCachedResults = true; } }
public string GetExtData(ExtDataType extDataType) { string result = null; if (ExData != null && ExData.ContainsKey((ushort)extDataType)) { result = ExData[(ushort)extDataType]; } return(result); }
// 获取 AI 的答案 private void AIAnswer(BaseEvent varData) { if (varData == null || mAIFinish) { return; } ExData <int> data = varData as ExData <int>; int answer = data.data; mAISelect = mAllAnswer[answer]; // 记录AI的选择 if (mPlayerFinish) // 玩家先答题, 显示右边的圈 { UIHelper.SetActive(mAllAnswer[answer], "Right", true); } mAIFinish = true; if (mRound == 1) { UIHelper.SetActive(mRedSlider, "Score", true); } // 判断正确与否 if (curQuestions[mRound - 1].real == ((char)(65 + answer)).ToString()) { // 正确 判断加多少分 mAIScore += 240 * time / 10f; UIHelper.SetSlider(mRedSlider, mAIScore / MaxScore); if (mPlayerFinish) // 玩家先答题才出答案 { UIHelper.SetColor(mAllAnswer[answer], Color.green); } } else { // 错误不加分 if (mPlayerFinish) // 玩家先答题才出答案 { UIHelper.SetColor(mAllAnswer[answer], Color.red); } else { // 玩家没答题, AI的进度条闪一下 TweenColor tc = mRedSlider.Find("Sprite").GetComponent <TweenColor>(); tc.ResetToBeginning(); tc.PlayForward(); } } UIHelper.SetLabel(mRedSlider, "Score", mAIScore.ToString("0")); // 判断游戏是否结束 OneEnd(); }
public ExData(ExData InData) { JudgeNameId = InData.JudgeNameId; Division = InData.Division; Round = InData.Round; Pool = InData.Pool; Team = InData.Team; Point1Count = InData.Point1Count; Point2Count = InData.Point2Count; Point3Count = InData.Point3Count; Point5Count = InData.Point5Count; }
IEnumerator AI_Reply(float time) { yield return(new WaitForSeconds(time)); // AI 随机答一题 ExData <int> data = new ExData <int>(); data.data = Random.Range(0, 4); data.pEventID = (int)PlayerEvent.AI_Reply; manager.NotifyEvent(data.pEventID, data); }
public void LoadAutosave(string InFilename) { try { FileStream File = new FileStream(InFilename, FileMode.Open); CurData = ExData.Load(File); File.Close(); } catch (System.Exception e) { Debug.Log("Load autosave exception: " + e.Message); } }
public void ReceiveExData(string JudgeGuid, string InData) { ExData NewExData = ExData.Load(Global.GenerateStreamFromString(InData)); if (NewExData != null) { TeamData TData = Global.GetTeamData(NewExData.Division, NewExData.Round, NewExData.Pool, NewExData.Team); if (TData != null) { bool bNewScore = TData.RoutineScores.SetExResults(NewExData); OnRecievedResultsData(bNewScore); } } }
public bool SetExResults(ExData InData) { if (InData.JudgeNameId == -1) { return(false); } ResultsData rd = TournamentData.FindResultsData(InData.Division, InData.Round, InData.Pool); int ResultIndex = -1; for (int i = 0; i < rd.ExJudgeIds.Count; ++i) { if (InData.JudgeNameId == rd.ExJudgeIds[i]) { ResultIndex = i; break; } } bool bNewScore = false; if (ResultIndex >= 0) { for (int DataIndex = 0; DataIndex <= ResultIndex; ++DataIndex) { if (DataIndex >= ExResults.Count) { ExResults.Add(new ExData()); } } if (!ExResults[ResultIndex].IsValid()) { bNewScore = true; } ExResults[ResultIndex] = InData; } return(bNewScore); }
void WriteExXml(XmlWriter writer, List <TeamDataDisplay> TeamList, int JudgeIndex) { if (TeamList.Count > 0 && TeamList[0].Data.RoutineScores.ExResults.Count > JudgeIndex) { writer.WriteStartElement("ns2:Ex" + (JudgeIndex + 1)); for (int TeamIndex = 0; TeamIndex < TeamList.Count; ++TeamIndex) { TeamDataDisplay tdd = TeamList[TeamIndex]; if (JudgeIndex < tdd.Data.RoutineScores.ExResults.Count) { ExData ed = tdd.Data.RoutineScores.ExResults[JudgeIndex]; writer.WriteElementString("ns2:Team" + (TeamIndex + 1) + "Point1", ed.Point1Count.ToString()); writer.WriteElementString("ns2:Team" + (TeamIndex + 1) + "Point2", ed.Point2Count.ToString()); writer.WriteElementString("ns2:Team" + (TeamIndex + 1) + "Point3", ed.Point3Count.ToString()); writer.WriteElementString("ns2:Team" + (TeamIndex + 1) + "Point5", ed.Point5Count.ToString()); } } writer.WriteEndElement(); } }
public async Task <bool> DownloadAdditionalData() { while (isBusyUpdatingMA) { Console.WriteLine("Waiting for sma update to finish before dowanloading additional data..."); } Logger.WriteLog("Additional data is being downloaded "); ExData DataManager = new ExData(Product, UpdateJasonDB); SharedRawExchangeData.AddRange(DataManager.RawExchangeData); Logger.WriteLog("done downloading additional data "); return(true); }
void DrawBackupList() { Rect BackupArea = new Rect(20, 100, Screen.width - 40, Screen.height - 150); GUILayout.BeginArea(BackupArea); GUILayout.BeginVertical(); BackupAreaScrollPos = GUILayout.BeginScrollView(BackupAreaScrollPos); foreach (BackupExData bd in BackupList) { GUILayout.BeginHorizontal(); string BackupStr = GetBackupDisplayString(bd) + " | .1: " + bd.Data.Point1Count + " .2: " + bd.Data.Point2Count + " .3: " + bd.Data.Point3Count + " .5: " + bd.Data.Point5Count; GUIStyle LabelStyle = new GUIStyle("label"); GUIContent BackupContent = new GUIContent(BackupStr); GUILayout.Label(BackupContent, GUILayout.MaxWidth(LabelStyle.CalcSize(BackupContent).x + 20)); if (GUILayout.Button("Load")) { bIsChoosingBackup = false; //bBackupLoaded = true; CurData = bd.Data; //CurBackupData = bd; HeaderDrawer.CanvasGO.SetActive(true); JudgerCanvasUI.SetActive(true); UpdatePoints(); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.EndArea(); }
public override void RecoverAutosave() { base.RecoverAutosave(); BackupList.Clear(); string BackupPath = Application.persistentDataPath + "/Backup"; string[] Files = Directory.GetFiles(BackupPath); foreach (string filename in Files) { if (filename.Contains("ExBackup")) { BackupExData backup = new BackupExData(); try { FileStream BackupFile = new FileStream(filename, FileMode.Open); backup.Data = ExData.Load(BackupFile); backup.Filename = filename; BackupFile.Close(); } catch (System.Exception e) { Debug.Log("Load autosave exception: " + e.Message); } backup.WrittenTime = File.GetLastWriteTime(filename); BackupList.Add(backup); } } BackupList.Sort( delegate(BackupExData b1, BackupExData b2) { if (b1 == b2) { return(0); } else if (b1.WrittenTime < b2.WrittenTime) { return(1); } else { return(-1); } }); // Delete old backup files if (BackupList.Count > Global.MaxBackupFileCount) { for (int FileIndex = Global.MaxBackupFileCount; FileIndex < BackupList.Count; ++FileIndex) { try { File.Delete(BackupList[FileIndex].Filename); } catch (System.Exception e) { Debug.Log("Delete old backup files exception: " + e.Message); } } while (BackupList.Count > Global.MaxBackupFileCount) { BackupList.RemoveAt(Global.MaxBackupFileCount); } } }
void OnGUI() { if (!bIsEditing) { CatCombo.List(new Rect(20, Screen.height * .03f, Screen.width * .18f, Screen.height * .07f), CatComboList[CatCombo.GetSelectedItemIndex()], CatComboList, CatComboStyle); if (CatPickingFrameUpdate != Time.frameCount) { CatPickingFrameUpdate = Time.frameCount; bCatPicking = CatCombo.IsPicking; } } if (bInEditingMode && CatCombo.GetSelectedItemIndex() == 3) { bInEditingMode = false; bIsEditing = false; EditAIData = null; EditExData = null; EditDiffData = null; bEditAddNewData = false; } if (!bIsEditing && GUI.Button(new Rect(Screen.width * .3f, Screen.height * .04f, Screen.width * .25f, Screen.height * .07f), "Export SCHEDULE to Excel")) { ExportScheduleToExcel(); } if (!bIsEditing && GUI.Button(new Rect(Screen.width * .56f, Screen.height * .04f, Screen.width * .23f, Screen.height * .07f), "Export RESULTS to Excel")) { ExportResultsToExcel(); } if (GUI.Button(new Rect(Screen.width * .83f, Screen.height * .04f, Screen.width * .17f - 20, Screen.height * .07f), "Send All Teams to Livestream")) { LiveStream.TeamList teamList = new LiveStream.TeamList(); EDivision division = EDivision.Open; foreach (DivisionData dd in Global.AllData.AllDivisions) { ERound round = ERound.Finals; foreach (RoundData rd in dd.Rounds) { EPool pool = EPool.A; foreach (PoolData pd in rd.Pools) { int teamNumber = 0; foreach (TeamDataDisplay td in pd.Teams) { LiveStream.Team team = new LiveStream.Team( LiveStream.TeamStates.Inited, division.ToString(), round.ToString(), pool.ToString(), teamNumber ); foreach (PlayerData playerData in td.Data.Players) { team.Players.Add(new LiveStream.Player(playerData)); } teamList.Teams.Add(team); ++teamNumber; } ++pool; } ++round; } ++division; } SendRestMessageAsync(teamList); } #region Round Buttons GUIStyle RoundStyle = new GUIStyle("button"); string LongestRoundStr = "Women - Quarterfinals"; Rect RoundRect = new Rect(20, Screen.height * .15f, RoundStyle.CalcSize(new GUIContent(LongestRoundStr)).x + 40, Screen.height * .75f - 20); if (!bIsEditing && !bCatPicking) { GUILayout.BeginArea(RoundRect); RoundsScrollPos = GUILayout.BeginScrollView(RoundsScrollPos, GUILayout.MaxHeight(RoundRect.height / 2f)); GUIStyle RoundButtonStyle = new GUIStyle("button"); RoundButtonStyle.alignment = TextAnchor.MiddleLeft; for (int DivIndex = 0; DivIndex < Global.AllData.AllDivisions.Length; ++DivIndex) { DivisionData DivData = Global.AllData.AllDivisions[DivIndex]; if (DivData.HasAnyPoolData()) { for (int RoundIndex = 0; RoundIndex < DivData.Rounds.Length; ++RoundIndex) { RoundData RData = DivData.Rounds[RoundIndex]; if (RData.HasAnyPoolData()) { GUIContent RoundContent = new GUIContent(((EDivision)DivIndex) + " - " + ((ERound)RoundIndex) + (RData.ContainsJudgeScores() ? " - Results" : "")); Vector2 RoundTextSize = RoundButtonStyle.CalcSize(RoundContent); if (GUILayout.Button(RoundContent, RoundButtonStyle, GUILayout.Width(RoundRect.width * .9f), GUILayout.Height(RoundTextSize.y))) { CurDivIndex = DivIndex; CurRoundIndex = RoundIndex; } } } } } GUILayout.EndScrollView(); GUILayout.EndArea(); } #endregion if (CurDivIndex != -1 && CurRoundIndex != -1) { float StartX = RoundRect.x + RoundRect.width + 20; Rect TeamRect = new Rect(StartX, RoundRect.y, Screen.width - StartX - 20, Screen.height - RoundRect.y - 20); GUILayout.BeginArea(TeamRect); GUILayout.BeginVertical(); TeamsScrollPos = GUILayout.BeginScrollView(TeamsScrollPos); GUILayout.BeginVertical(); GUIStyle labelStyle = new GUIStyle("label"); labelStyle.normal.textColor = Color.black; if (!bIsEditing) { List <PoolData> Pools = Global.AllData.AllDivisions[CurDivIndex].Rounds[CurRoundIndex].Pools; int PoolIndex = 0; foreach (PoolData pd in Pools) { GUILayout.Label("Pool " + pd.PoolName, labelStyle); // This is a hack to get team result order List <RoutineScoreData> sortedScores = new List <RoutineScoreData>(); foreach (TeamDataDisplay tdd in pd.Teams) { if (sortedScores.Count == 0) { sortedScores.Add(tdd.Data.RoutineScores); } else { int insertIndex = 0; foreach (RoutineScoreData score in sortedScores) { if (tdd.Data.RoutineScores.GetTotalPoints() > score.GetTotalPoints()) { sortedScores.Insert(insertIndex, tdd.Data.RoutineScores); break; } ++insertIndex; } if (insertIndex == sortedScores.Count) { sortedScores.Insert(insertIndex, tdd.Data.RoutineScores); } } } int TeamNum = 0; foreach (TeamDataDisplay tdd in pd.Teams) { ++TeamNum; GUILayout.Label(TeamNum + ": " + tdd.Data.PlayerNames + ":", labelStyle); for (int ScoresIndex = 0; ScoresIndex < (CurCat == ECategoryView.Overview ? 1 : 3); ++ScoresIndex) { GUIStyle EditStyle = new GUIStyle("button"); EditStyle.alignment = TextAnchor.MiddleLeft; string ResultsStr = tdd.Data.RoutineScores.GetResultsString(ScoresIndex, CurCat, true, sortedScores); if (ResultsStr.Length > 0) { if (bInEditingMode) { if (GUILayout.Button(" " + ResultsStr, EditStyle)) { bIsEditing = true; EditPoolIndex = PoolIndex; EditTeamIndex = TeamNum - 1; EditJudgeIndex = ScoresIndex; } } else { GUILayout.Label(" " + ResultsStr, labelStyle); } } else if (bInEditingMode && (ScoresIndex == 0 || tdd.Data.RoutineScores.GetResultsString(ScoresIndex - 1, CurCat, true).Length > 0)) { if (GUILayout.Button(" Enter New Scores", EditStyle)) { bIsEditing = true; EditPoolIndex = PoolIndex; EditTeamIndex = TeamNum - 1; EditJudgeIndex = ScoresIndex; } } } } ++PoolIndex; } } else { TeamData Data = Global.AllData.AllDivisions[CurDivIndex].Rounds[CurRoundIndex].Pools[EditPoolIndex].Teams[EditTeamIndex].Data; if (CatCombo.GetSelectedItemIndex() == 0) { if (EditAIData == null) { AIData JData = null; if (EditJudgeIndex >= Data.RoutineScores.AIResults.Count) { EditAIData = new AIData((EDivision)CurDivIndex, (ERound)CurRoundIndex, (EPool)EditPoolIndex, EditTeamIndex); bEditAddNewData = true; EditJudgeName = "Judge Name"; } else { JData = Data.RoutineScores.AIResults[EditJudgeIndex]; EditAIData = new AIData(JData); } } GUILayout.BeginHorizontal(); if (EditAIData.JudgeNameId == -1) { GUILayout.Label("Judge:", labelStyle); EditJudgeName = GUILayout.TextField(EditJudgeName); char[] Seperators = new char[] { ',', ' ' }; string[] Splits = EditJudgeName.Split(Seperators, System.StringSplitOptions.RemoveEmptyEntries); NameData JudgeName = null; if (Splits.Length == 2) { JudgeName = NameDatabase.FindInDatabase(Splits[0], Splits[1]); if (JudgeName == null) { JudgeName = NameDatabase.FindInDatabase(Splits[1], Splits[0]); } } if (JudgeName != null) { EditAIData.JudgeNameId = JudgeName.Id; } } else { GUILayout.Label(NameDatabase.FindInDatabase(EditAIData.JudgeNameId).DisplayName + ": ", labelStyle); } GUILayout.Label("V: ", labelStyle); float.TryParse(GUILayout.TextField(EditAIData.Variety.ToString()), out EditAIData.Variety); GUILayout.Label("T: ", labelStyle); float.TryParse(GUILayout.TextField(EditAIData.Teamwork.ToString()), out EditAIData.Teamwork); GUILayout.Label("M: ", labelStyle); float.TryParse(GUILayout.TextField(EditAIData.Music.ToString()), out EditAIData.Music); GUILayout.Label("Fm: ", labelStyle); float.TryParse(GUILayout.TextField(EditAIData.Form.ToString()), out EditAIData.Form); GUILayout.Label("Fw: ", labelStyle); float.TryParse(GUILayout.TextField(EditAIData.Flow.ToString()), out EditAIData.Flow); GUILayout.Label("G: ", labelStyle); float.TryParse(GUILayout.TextField(EditAIData.General.ToString()), out EditAIData.General); GUILayout.Label("Total: " + EditAIData.GetTotalPoints().ToString(), labelStyle); GUILayout.EndHorizontal(); } else if (CatCombo.GetSelectedItemIndex() == 1) { if (EditExData == null) { ExData JData = null; if (EditJudgeIndex >= Data.RoutineScores.ExResults.Count) { EditExData = new ExData((EDivision)CurDivIndex, (ERound)CurRoundIndex, (EPool)EditPoolIndex, EditTeamIndex); bEditAddNewData = true; EditJudgeName = "Judge Name"; } else { JData = Data.RoutineScores.ExResults[EditJudgeIndex]; EditExData = new ExData(JData); } } GUILayout.BeginHorizontal(); if (EditExData.JudgeNameId == -1) { GUILayout.Label("Judge:", labelStyle); EditJudgeName = GUILayout.TextField(EditJudgeName); char[] Seperators = new char[] { ',', ' ' }; string[] Splits = EditJudgeName.Split(Seperators, System.StringSplitOptions.RemoveEmptyEntries); NameData JudgeName = null; if (Splits.Length == 2) { JudgeName = NameDatabase.FindInDatabase(Splits[0], Splits[1]); if (JudgeName == null) { JudgeName = NameDatabase.FindInDatabase(Splits[1], Splits[0]); } } if (JudgeName != null) { EditExData.JudgeNameId = JudgeName.Id; } } else { GUILayout.Label(NameDatabase.FindInDatabase(EditExData.JudgeNameId).DisplayName + ": ", labelStyle); } GUILayout.Label(".1: ", labelStyle); int.TryParse(GUILayout.TextField(EditExData.Point1Count.ToString()), out EditExData.Point1Count); GUILayout.Label(".2: ", labelStyle); int.TryParse(GUILayout.TextField(EditExData.Point2Count.ToString()), out EditExData.Point2Count); GUILayout.Label(".3: ", labelStyle); int.TryParse(GUILayout.TextField(EditExData.Point3Count.ToString()), out EditExData.Point3Count); GUILayout.Label(".5: ", labelStyle); int.TryParse(GUILayout.TextField(EditExData.Point5Count.ToString()), out EditExData.Point5Count); GUILayout.Label("Total: " + EditExData.GetTotalPoints().ToString(), labelStyle); GUILayout.EndHorizontal(); } else if (CatCombo.GetSelectedItemIndex() == 2) { if (EditDiffData == null) { DiffData JData = null; if (EditJudgeIndex >= Data.RoutineScores.DiffResults.Count) { EditDiffData = new DiffData(20, (EDivision)CurDivIndex, (ERound)CurRoundIndex, (EPool)EditPoolIndex, EditTeamIndex); bEditAddNewData = true; EditJudgeName = "Judge Name"; } else { JData = Data.RoutineScores.DiffResults[EditJudgeIndex]; EditDiffData = new DiffData(JData); } } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Number of Scores: ", labelStyle); int.TryParse(GUILayout.TextField(EditDiffData.NumScores.ToString()), out EditDiffData.NumScores); EditDiffData.NumScores = Mathf.Clamp(EditDiffData.NumScores, 0, 20); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (EditDiffData.JudgeNameId == -1) { GUILayout.Label("Judge:", labelStyle); EditJudgeName = GUILayout.TextField(EditJudgeName); char[] Seperators = new char[] { ',', ' ' }; string[] Splits = EditJudgeName.Split(Seperators, System.StringSplitOptions.RemoveEmptyEntries); NameData JudgeName = null; if (Splits.Length == 2) { JudgeName = NameDatabase.FindInDatabase(Splits[0], Splits[1]); if (JudgeName == null) { JudgeName = NameDatabase.FindInDatabase(Splits[1], Splits[0]); } } if (JudgeName != null) { EditDiffData.JudgeNameId = JudgeName.Id; } } else { GUILayout.Label(NameDatabase.FindInDatabase(EditDiffData.JudgeNameId).DisplayName + ": ", labelStyle); } for (int i = 0; i < EditDiffData.NumScores; ++i) { string DiffStr = GUILayout.TextField(EditDiffData.DiffScores[i].ToString() + EditDiffData.GetConsecString(i)); if (DiffStr.Contains("-")) { DiffStr = DiffStr.Replace("-", ""); EditDiffData.ConsecScores[i] = -1; } else if (DiffStr.Contains("+")) { DiffStr = DiffStr.Replace("+", ""); EditDiffData.ConsecScores[i] = 1; } else { EditDiffData.ConsecScores[i] = 0; } float.TryParse(DiffStr, out EditDiffData.DiffScores[i]); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (CatCombo.GetSelectedItemIndex() != 3) { if (!bInEditingMode && GUILayout.Button("Enter Edit Mode", GUILayout.Height(Screen.height * .1f))) { bInEditingMode = true; } else if (bInEditingMode) { if (bIsEditing) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Delete Score", GUILayout.Height(Screen.height * .1f))) { TeamData Data = Global.AllData.AllDivisions[CurDivIndex].Rounds[CurRoundIndex].Pools[EditPoolIndex].Teams[EditTeamIndex].Data; if (CatCombo.GetSelectedItemIndex() == 0) { if (!bEditAddNewData && EditJudgeIndex < Data.RoutineScores.AIResults.Count) { Data.RoutineScores.AIResults[EditJudgeIndex] = new AIData(); } EditAIData = null; } else if (CatCombo.GetSelectedItemIndex() == 1) { if (!bEditAddNewData && EditJudgeIndex < Data.RoutineScores.ExResults.Count) { Data.RoutineScores.ExResults[EditJudgeIndex] = new ExData(); } EditExData = null; } else if (CatCombo.GetSelectedItemIndex() == 2) { if (!bEditAddNewData && EditJudgeIndex < Data.RoutineScores.DiffResults.Count) { Data.RoutineScores.DiffResults[EditJudgeIndex] = new DiffData(); } EditDiffData = null; } bIsEditing = false; EditAIData = null; EditExData = null; EditDiffData = null; bEditAddNewData = false; Global.AllData.Save(); } if (GUILayout.Button("Discard Changes", GUILayout.Height(Screen.height * .1f))) { bIsEditing = false; EditAIData = null; EditExData = null; EditDiffData = null; bEditAddNewData = false; } if (GUILayout.Button("Save Changes", GUILayout.Height(Screen.height * .1f))) { TeamData Data = Global.AllData.AllDivisions[CurDivIndex].Rounds[CurRoundIndex].Pools[EditPoolIndex].Teams[EditTeamIndex].Data; if (CatCombo.GetSelectedItemIndex() == 0) { if (bEditAddNewData) { Data.RoutineScores.AIResults.Add(new AIData(EditAIData)); } else { Data.RoutineScores.AIResults[EditJudgeIndex] = new AIData(EditAIData); } EditAIData = null; } else if (CatCombo.GetSelectedItemIndex() == 1) { if (bEditAddNewData) { Data.RoutineScores.ExResults.Add(new ExData(EditExData)); } else { Data.RoutineScores.ExResults[EditJudgeIndex] = new ExData(EditExData); } EditExData = null; } else if (CatCombo.GetSelectedItemIndex() == 2) { if (bEditAddNewData) { Data.RoutineScores.DiffResults.Add(new DiffData(EditDiffData)); } else { Data.RoutineScores.DiffResults[EditJudgeIndex] = new DiffData(EditDiffData); } EditDiffData = null; } bIsEditing = false; bEditAddNewData = false; Global.AllData.Save(); } GUILayout.EndHorizontal(); } else if (GUILayout.Button("Exit Edit Mode", GUILayout.Height(Screen.height * .1f))) { bInEditingMode = false; } } } GUILayout.EndVertical(); GUILayout.EndArea(); } }
void WriteRawResults() { StringWriter OutStr = new StringWriter(); OutStr.WriteLine((EDivision)(CurDivIndex) + " " + (ERound)(CurRoundIndex) + " Results"); List <PoolData> Pools = Global.AllData.AllDivisions[CurDivIndex].Rounds[CurRoundIndex].Pools; foreach (PoolData pd in Pools) { OutStr.WriteLine("Pool " + pd.PoolName); string CatHeaders = "\t"; string JudgeHeaders = "\t"; if (pd.Teams.Count > 0) { for (int i = 0; i < pd.Teams[0].Data.RoutineScores.AIResults.Count; ++i) { if (i == 0) { CatHeaders += "AI"; } CatHeaders += "\t"; JudgeHeaders += NameDatabase.FindInDatabase(pd.Teams[0].Data.RoutineScores.AIResults[i].JudgeNameId).DisplayName + "\t"; } for (int i = 0; i < pd.Teams[0].Data.RoutineScores.ExResults.Count; ++i) { if (i == 0) { CatHeaders += "Ex"; } CatHeaders += "\t"; JudgeHeaders += NameDatabase.FindInDatabase(pd.Teams[0].Data.RoutineScores.ExResults[i].JudgeNameId).DisplayName + "\t"; } for (int i = 0; i < pd.Teams[0].Data.RoutineScores.DiffResults.Count; ++i) { if (i == 0) { CatHeaders += "Diff"; } CatHeaders += "\t"; JudgeHeaders += NameDatabase.FindInDatabase(pd.Teams[0].Data.RoutineScores.DiffResults[i].JudgeNameId).DisplayName + "\t"; } } OutStr.WriteLine(CatHeaders); OutStr.WriteLine(JudgeHeaders + "\tTotal\tRank"); int TeamNum = 1; foreach (TeamDataDisplay tdd in pd.Teams) { string TeamStr = TeamNum + ": " + tdd.Data.PlayerNames + "\t"; foreach (AIData aid in tdd.Data.RoutineScores.AIResults) { TeamStr += aid.GetTotalPoints() + "\t"; } foreach (ExData ed in tdd.Data.RoutineScores.ExResults) { TeamStr += ed.GetTotalPoints() + "\t"; } foreach (DiffData dd in tdd.Data.RoutineScores.DiffResults) { TeamStr += dd.GetTotalPoints() + "\t"; } OutStr.WriteLine(TeamStr + "\t" + tdd.Data.RoutineScores.GetTotalPoints() + "\t" + GetTeamPlace(pd.Teams, tdd)); ++TeamNum; } OutStr.WriteLine(); OutStr.WriteLine(); if (pd.Teams.Count > 0) { int ResultsIndex = 0; foreach (AIData aid in pd.Teams[0].Data.RoutineScores.AIResults) { string AIHeader = (EDivision)(CurDivIndex) + " " + (ERound)(CurRoundIndex) + " Results\tArtistic Impression\t" + "Pool " + pd.PoolName + "\t" + NameDatabase.FindInDatabase(aid.JudgeNameId).DisplayName; OutStr.WriteLine(AIHeader); OutStr.WriteLine("\tVariety\tTeamwork\tMusic\tFlow\tForm\tGeneral Impression\tTotal\tRank"); int TeamIndex = 1; foreach (TeamDataDisplay tdd in pd.Teams) { if (ResultsIndex < tdd.Data.RoutineScores.AIResults.Count) { AIData Data = tdd.Data.RoutineScores.AIResults[ResultsIndex]; int Rank = 1; foreach (TeamDataDisplay OtherTdd in pd.Teams) { if (ResultsIndex < OtherTdd.Data.RoutineScores.AIResults.Count && OtherTdd.Data.RoutineScores.AIResults[ResultsIndex].GetTotalPoints() > Data.GetTotalPoints()) { ++Rank; } } string TeamStr = TeamIndex + ": " + tdd.Data.PlayerNames + "\t" + Data.Variety + "\t" + Data.Teamwork + "\t" + Data.Music + "\t" + Data.Flow + "\t" + Data.Form + "\t" + Data.General + "\t" + Data.GetTotalPoints() + "\t" + Rank; OutStr.WriteLine(TeamStr); ++TeamIndex; } } ++ResultsIndex; OutStr.WriteLine(); } OutStr.WriteLine(); ResultsIndex = 0; foreach (ExData ed in pd.Teams[0].Data.RoutineScores.ExResults) { string ExHeader = (EDivision)(CurDivIndex) + " " + (ERound)(CurRoundIndex) + " Results\tExecution\t" + "Pool " + pd.PoolName + "\t" + NameDatabase.FindInDatabase(ed.JudgeNameId).DisplayName; OutStr.WriteLine(ExHeader); OutStr.WriteLine("\t.1\t.2\t.3\t.5\tTotal\tRank"); int TeamIndex = 1; foreach (TeamDataDisplay tdd in pd.Teams) { if (ResultsIndex < tdd.Data.RoutineScores.ExResults.Count) { ExData Data = tdd.Data.RoutineScores.ExResults[ResultsIndex]; int Rank = 1; foreach (TeamDataDisplay OtherTdd in pd.Teams) { if (ResultsIndex < OtherTdd.Data.RoutineScores.ExResults.Count && OtherTdd.Data.RoutineScores.ExResults[ResultsIndex].GetTotalPoints() > Data.GetTotalPoints()) { ++Rank; } } string TeamStr = TeamIndex + ": " + tdd.Data.PlayerNames + "\t" + Data.Point1Count + "\t" + Data.Point2Count + "\t" + Data.Point3Count + "\t" + Data.Point5Count + "\t" + Data.GetTotalPoints() + "\t" + Rank; OutStr.WriteLine(TeamStr); ++TeamIndex; } } ++ResultsIndex; OutStr.WriteLine(); } OutStr.WriteLine(); ResultsIndex = 0; foreach (DiffData dd in pd.Teams[0].Data.RoutineScores.DiffResults) { string ExHeader = (EDivision)(CurDivIndex) + " " + (ERound)(CurRoundIndex) + " Results\tDifficulty\t" + "Pool " + pd.PoolName + "\t" + NameDatabase.FindInDatabase(dd.JudgeNameId).DisplayName; OutStr.WriteLine(ExHeader); string BlockHeader = "\t"; for (int i = 0; i < dd.NumScores; ++i) { BlockHeader += (i + 1) + "\t"; } OutStr.WriteLine(BlockHeader + "Total\tRank"); int TeamIndex = 1; foreach (TeamDataDisplay tdd in pd.Teams) { if (ResultsIndex < tdd.Data.RoutineScores.DiffResults.Count) { DiffData Data = tdd.Data.RoutineScores.DiffResults[ResultsIndex]; int Rank = 1; foreach (TeamDataDisplay OtherTdd in pd.Teams) { if (ResultsIndex < OtherTdd.Data.RoutineScores.DiffResults.Count && OtherTdd.Data.RoutineScores.DiffResults[ResultsIndex].GetTotalPoints() > Data.GetTotalPoints()) { ++Rank; } } string TeamStr = TeamIndex + ": " + tdd.Data.PlayerNames + "\t"; for (int i = 0; i < Data.NumScores; ++i) { TeamStr += Data.DiffScores[i] + "\t"; } TeamStr += Data.GetTotalPoints() + "\t" + Rank; OutStr.WriteLine(TeamStr); ++TeamIndex; } } ++ResultsIndex; OutStr.WriteLine(); } } } string TempFilePath = Application.persistentDataPath + "/TempExcelStr.txt"; if (File.Exists(TempFilePath)) { File.Delete(TempFilePath); } StreamWriter TempFile = new StreamWriter(TempFilePath); TempFile.Write(OutStr.ToString()); TempFile.Close(); OutStr.Close(); TempFilePath = TempFilePath.Replace('/', '\\'); if (File.Exists(ExcelPath)) { Process.Start(ExcelPath, "\"" + TempFilePath + "\""); } }
public override void ResetScoreData() { CurData = new ExData(CurDivision, CurRound, CurPool, CurTeam); }