Esempio n. 1
0
    public void UpdatePoints()
    {
        CountButtonUIList[0].GetComponent <Text>().text = CurData.Point1Count.ToString();
        CountButtonUIList[1].GetComponent <Text>().text = CurData.Point2Count.ToString();
        CountButtonUIList[2].GetComponent <Text>().text = CurData.Point3Count.ToString();
        CountButtonUIList[3].GetComponent <Text>().text = CurData.Point5Count.ToString();

        PointsUIList[0].GetComponent <Text>().text = (CurData.Point1Count * .1f).ToString("0.0");
        PointsUIList[1].GetComponent <Text>().text = (CurData.Point2Count * .2f).ToString("0.0");
        PointsUIList[2].GetComponent <Text>().text = (CurData.Point3Count * .3f).ToString("0.0");
        PointsUIList[3].GetComponent <Text>().text = (CurData.Point5Count * .5f).ToString("0.0");

        TotalScoreUI.GetComponent <Text>().text = CurData.GetTotalPoints().ToString("0.0");
    }
    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 + "\"");
        }
    }