Ejemplo n.º 1
0
 public AIData(EDivision InDiv, ERound InRound, EPool InPool, int InTeam)
 {
     Division = InDiv;
     Round    = InRound;
     Pool     = InPool;
     Team     = InTeam;
 }
        public void Init(MainWindow parent, ERound inRound, EPool inPool)
        {
            parentWindow = parent;

            round = inRound;
            pool  = inPool;
        }
Ejemplo n.º 3
0
    public ResultsData(EDivision InDiv, ERound InRound, EPool InPool)
    {
        Division = InDiv;
        Round    = InRound;

        Pool = InPool;
    }
 public DiffData(int InNumScores, EDivision InDiv, ERound InRound, EPool InPool, int InTeam)
 {
     NumScores = InNumScores;
     Division  = InDiv;
     Round     = InRound;
     Pool      = InPool;
     Team      = InTeam;
 }
Ejemplo n.º 5
0
    public static TeamData GetTeamData(EDivision InDiv, ERound InRound, EPool InPool, int InTeam)
    {
        if (!DataExists(InDiv, InRound, InPool, InTeam))
        {
            return(null);
        }

        return(Global.AllData.AllDivisions[(int)InDiv].Rounds[(int)InRound].Pools[(int)InPool].Teams[InTeam].Data);
    }
Ejemplo n.º 6
0
    public void SetCurrentPool(EPool NewCurPool)
    {
        CurPool = NewCurPool;

        if (NewCurPool != EPool.None && Global.IsValid(CurDivision, CurRound, NewCurPool, 0))
        {
            CurTeam = 0;
        }
    }
Ejemplo n.º 7
0
    public static bool DataExists(EDivision InDiv, ERound InRound, EPool InPool, int InTeam)
    {
        if (Global.AllData == null || InPool == EPool.None || (int)InPool >= Global.AllData.AllDivisions[(int)InDiv].Rounds[(int)InRound].Pools.Count ||
            InTeam < 0 || InTeam >= Global.AllData.AllDivisions[(int)InDiv].Rounds[(int)InRound].Pools[(int)InPool].Teams.Count)
        {
            return(false);
        }

        return(true);
    }
Ejemplo n.º 8
0
        private bool TryGetAutoGeneratePools(EDivision division, ERound round, EPool pool, out PoolData pool1, out PoolData pool2, out PoolData nextPool)
        {
            if (round == ERound.Quarterfinals)
            {
                if (pool == EPool.A || pool == EPool.C)
                {
                    pool1    = tournamentData.GetPool(division, ERound.Quarterfinals, EPool.A);
                    pool2    = tournamentData.GetPool(division, ERound.Quarterfinals, EPool.C);
                    nextPool = tournamentData.GetPool(division, ERound.Semifinals, EPool.A);
                }
                else
                {
                    pool1    = tournamentData.GetPool(division, ERound.Quarterfinals, EPool.B);
                    pool2    = tournamentData.GetPool(division, ERound.Quarterfinals, EPool.D);
                    nextPool = tournamentData.GetPool(division, ERound.Semifinals, EPool.B);
                }
            }
            else if (round == ERound.Semifinals)
            {
                pool1    = tournamentData.GetPool(division, ERound.Semifinals, EPool.A);
                pool2    = tournamentData.GetPool(division, ERound.Semifinals, EPool.B);
                nextPool = tournamentData.GetPool(division, ERound.Finals, EPool.A);
            }
            else
            {
                pool1    = null;
                pool2    = null;
                nextPool = null;

                return(false);
            }

            if (pool1.resultRank.Count > 0 && pool2.resultRank.Count > 0)
            {
                foreach (int rank in pool1.resultRank)
                {
                    if (rank == 0)
                    {
                        return(false);
                    }
                }

                foreach (int rank in pool2.resultRank)
                {
                    if (rank == 0)
                    {
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 销毁对象,真正的销毁!!
 /// </summary>
 public static void BeyondTimeObject()
 {
     if (effectsList == null)
     {
         return;
     }
     foreach (EffectsPool EPool in effectsList.Values)
     {
         EPool.BeyondEffect();
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 销毁对象池,真正的销毁!!
 /// </summary>
 public static void Destroy()
 {
     if (effectsList == null)
     {
         return;
     }
     foreach (EffectsPool EPool in effectsList.Values)
     {
         EPool.Destory();
     }
     effectsList = null;
 }
Ejemplo n.º 11
0
 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;
 }
Ejemplo n.º 12
0
    public static bool IsValid(EDivision InDivision, ERound InRound, EPool InPool, int InTeam)
    {
        if ((int)InDivision >= 0 && (int)InRound >= 0 && InPool >= 0 && InTeam >= 0 &&
            (int)InDivision < Global.AllData.AllDivisions.Length &&
            (int)InRound < Global.AllData.AllDivisions[(int)InDivision].Rounds.Length &&
            (int)InPool < Global.AllData.AllDivisions[(int)InDivision].Rounds[(int)InRound].Pools.Count &&
            InTeam < Global.AllData.AllDivisions[(int)InDivision].Rounds[(int)InRound].Pools[(int)InPool].Teams.Count)
        {
            return(true);
        }

        return(false);
    }
Ejemplo n.º 13
0
 public void GenerateFuturePools()
 {
     for (EDivision division = EDivision.Open; division < EDivision.Max; ++division)
     {
         for (ERound round = ERound.Finals; round != ERound.Max; ++round)
         {
             for (EPool pool = EPool.A; pool != EPool.Max; ++pool)
             {
                 GenerateNextPool(division, round, pool);
             }
         }
     }
 }
 public DiffData(DiffData InData)
 {
     JudgeNameId = InData.JudgeNameId;
     Division    = InData.Division;
     Round       = InData.Round;
     Pool        = InData.Pool;
     Team        = InData.Team;
     NumScores   = InData.NumScores;
     for (int i = 0; i < InData.DiffScores.Length; ++i)
     {
         DiffScores[i]   = InData.DiffScores[i];
         ConsecScores[i] = InData.ConsecScores[i];
     }
 }
Ejemplo n.º 15
0
 public AIData(AIData InData)
 {
     JudgeNameId = InData.JudgeNameId;
     Division    = InData.Division;
     Round       = InData.Round;
     Pool        = InData.Pool;
     Team        = InData.Team;
     Variety     = InData.Variety;
     Teamwork    = InData.Teamwork;
     Music       = InData.Music;
     Flow        = InData.Flow;
     Form        = InData.Form;
     General     = InData.General;
 }
Ejemplo n.º 16
0
        public void GetPlayingTeams(EDivision division, ERoundJudgeDisplay round, int controlIndex, out ObservableCollection <TeamData> outPlayingTeams)
        {
            EPool pool = EnumConverter.ConvertPoolValue(round, controlIndex);

            if (pool != EPool.None)
            {
                PoolData pd = tournamentData.GetPool(division, EnumConverter.ConvertRoundValue(round), pool);
                outPlayingTeams = pd.teamList.teams;
            }
            else
            {
                outPlayingTeams = null;
            }
        }
Ejemplo n.º 17
0
        public T Spawn <T>(EPool poolType, Vector3 position, Quaternion rotation, Transform parent = null)
        {
            Pool       pool = _pools.Find(p => p.Type == poolType);
            GameObject obj  = pool.GetObject();

            if (parent != null)
            {
                obj.transform.parent = parent;
            }
            obj.transform.position = position;
            obj.transform.rotation = rotation;

            //obj.SetActive(true);

            return(obj.GetComponent <T>());
        }
Ejemplo n.º 18
0
    public static ResultsData FindResultsData(EDivision InDiv, ERound InRound, EPool InPool)
    {
        if (Global.AllData.ResultsList == null)
        {
            return(null);
        }

        foreach (ResultsData rd in Global.AllData.ResultsList)
        {
            if (rd.Division == InDiv && rd.Round == InRound && rd.Pool == InPool)
            {
                return(rd);
            }
        }

        return(null);
    }
Ejemplo n.º 19
0
        void ImportDivisionData(TournamentData importedData, XmlNode node, EDivision division)
        {
            DivisionData divisionData = new DivisionData(division);

            foreach (XmlNode roundNode in node.ChildNodes)             // Rounds
            {
                ERound round = ERound.Finals;
                foreach (XmlNode roundDataNode in roundNode.ChildNodes)
                {
                    RoundData roundData = new RoundData(division, round);
                    EPool     pool      = EPool.A;
                    foreach (XmlNode poolDataNode in roundDataNode.FirstChild.ChildNodes)                     // Pools
                    {
                        PoolData poolData = new PoolData(pool);
                        foreach (XmlNode poolDataChildNode in poolDataNode.ChildNodes)
                        {
                            if (poolDataChildNode.Name == "PoolName")
                            {
                                poolData.pool = (EPool)Enum.Parse(typeof(EPool), poolDataChildNode.FirstChild.Value);
                            }
                            else if (poolDataChildNode.Name == "Teams")
                            {
                                ImportTeams(importedData, divisionData, poolData, poolDataChildNode);
                                ImportJudges(importedData, divisionData, poolData, poolDataChildNode);
                            }
                            else if (poolDataChildNode.Name == "ResultsByTeamIndex")
                            {
                                ImportPoolResults(poolData, poolDataChildNode);
                            }
                        }

                        roundData.pools.Add(poolData);

                        ++pool;
                    }

                    divisionData.rounds.Add(roundData);

                    ++round;
                }
            }

            importedData.divisions.Add(divisionData);
        }
Ejemplo n.º 20
0
        public PoolData GetPool(EDivision division, ERound round, EPool pool)
        {
            int divisionIndex = (int)division;

            if (divisionIndex >= 0 && divisionIndex < (int)EDivision.Max)
            {
                int roundIndex = (int)round;
                if (roundIndex >= 0 && roundIndex < (int)ERound.Max)
                {
                    int PoolIndex = (int)pool;
                    if (PoolIndex >= 0 && PoolIndex < divisions[divisionIndex].rounds[roundIndex].pools.Count)
                    {
                        return(divisions[divisionIndex].rounds[roundIndex].pools[PoolIndex]);
                    }
                }
            }

            return(new PoolData());
        }
Ejemplo n.º 21
0
    void OnGUI()
    {
        float SelectButWidth  = Screen.width * .25f;
        float SelectButHeight = Screen.height * .08f;
        float SelectY         = Screen.height * .04f;

        DivisionCombo.Draw(new Rect(20, SelectY, SelectButWidth, SelectButHeight));
        RoundCombo.Draw(new Rect(20 + SelectButWidth + Screen.width * .02f, SelectY, SelectButWidth, SelectButHeight));

        ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);

        float    InfoY     = Screen.height * .02f + SelectY + SelectButHeight;
        GUIStyle InfoStyle = new GUIStyle("label");

        InfoStyle.fontSize = 30;
        GUIContent TimeDate     = new GUIContent(DateTime.Now.ToString());
        Vector2    TimeDateSize = InfoStyle.CalcSize(TimeDate);

        GUI.Label(new Rect(20, InfoY, TimeDateSize.x, TimeDateSize.y), TimeDate, InfoStyle);

        bool bValidDivisionRoundSettings = Global.AllData.AllDivisions.Length > (int)CurDivision &&
                                           Global.AllData.AllDivisions[(int)CurDivision].Rounds.Length > (int)CurRound;

        if (bValidDivisionRoundSettings)
        {
            RoundData  Round        = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound];
            int        TotalSeconds = bJudging ? (int)(DateTime.Now - RoutineStartTime).TotalSeconds : 0;
            int        Minutes      = Mathf.FloorToInt(TotalSeconds / 60f);
            int        Seconds      = Mathf.FloorToInt(TotalSeconds) % 60;
            int        RoundMinutes = Mathf.FloorToInt(Round.RoutineLengthMinutes);
            int        RoundSeconds = Mathf.FloorToInt(Round.RoutineLengthMinutes * 60) % 60;
            GUIContent RoutineTime  = new GUIContent(String.Format("{0}:{1:00} / {2}:{3:00}", Minutes, Seconds, RoundMinutes, RoundSeconds));
            Vector2    TimeSize     = InfoStyle.CalcSize(RoutineTime);
            GUI.Label(new Rect(Screen.width - 20 - TimeSize.x, InfoY, TimeSize.x, TimeSize.y), RoutineTime, InfoStyle);

            if (TotalSeconds > Round.RoutineLengthMinutes * 60 && !bRoutineTimeElapsed)
            {
                bRoutineTimeElapsed = true;

                // Send ready to livestream
                TeamData finishedTeam = Global.GetTeamData(CurDivision, CurRound, CurPool, CurTeam);
                SendRestMessageAsync(finishedTeam, LiveStream.TeamStates.Finished);
            }
        }

        if (bFestivalJudging)
        {
            float     PoolButWidth  = Screen.width * .09f;
            RoundData Round         = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound];
            GUIStyle  SelectedStyle = new GUIStyle("button");
            SelectedStyle.normal.textColor = Color.green;
            SelectedStyle.hover.textColor  = Color.green;
            SelectedStyle.fontStyle        = FontStyle.Bold;
            GUIStyle ButtonStyle = new GUIStyle("button");
            if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .1f, SelectY, PoolButWidth, SelectButHeight),
                           "Pool: " + Round.Pools[(int)CurFestivalPool].PoolName, CurPool == CurFestivalPool ? SelectedStyle : ButtonStyle))
            {
                SetCurrentPool(CurFestivalPool);
                InitJudgersNameIds();
                ++Global.CurDataState;
            }

            if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .12f + PoolButWidth, SelectY, PoolButWidth, SelectButHeight),
                           "Pool: " + Round.Pools[(int)CurFestivalPool + 2].PoolName, CurPool == CurFestivalPool + 2 ? SelectedStyle : ButtonStyle))
            {
                SetCurrentPool(CurFestivalPool + 2);
                InitJudgersNameIds();
                ++Global.CurDataState;
            }

            if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .14f + 2f * PoolButWidth, SelectY, PoolButWidth, SelectButHeight),
                           "AI Scores", (CurPool > EPool.Max) ? SelectedStyle : ButtonStyle))
            {
                EPool newPool = EPool.None;
                if (CurPool == EPool.A || CurPool == EPool.C)
                {
                    newPool = EPool.PostScoresAC;
                }
                else if (CurPool == EPool.B || CurPool == EPool.D)
                {
                    newPool = EPool.PostScoresBD;
                }
                else
                {
                    switch (CurPool)
                    {
                    case EPool.PostScoresAC:
                        newPool = EPool.PostScoresCA;
                        break;

                    case EPool.PostScoresCA:
                        newPool = EPool.PostScoresAC;
                        break;

                    case EPool.PostScoresBD:
                        newPool = EPool.PostScoresDB;
                        break;

                    case EPool.PostScoresDB:
                        newPool = EPool.PostScoresBD;
                        break;
                    }
                }

                SetCurrentPool(newPool);
                InitJudgersNameIds();
                ++Global.CurDataState;
            }
        }

        #region Teams
        if (!DivisionCombo.IsPicking && !RoundCombo.IsPicking && bValidDivisionRoundSettings)
        {
            Rect LeftRect = new Rect(20, Screen.height * .22f, Screen.width / 2 - 40, Screen.height * .5f);
            if (CurPool == EPool.None && !bFestivalJudging)
            {
                GUILayout.BeginArea(LeftRect);
                PoolsScrollPos = GUILayout.BeginScrollView(PoolsScrollPos);
                GUILayout.BeginVertical();

                RoundData Round = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound];
                if (Round.Pools.Count <= 2)
                {
                    for (int PoolIndex = 0; PoolIndex < Round.Pools.Count; ++PoolIndex)
                    {
                        PoolData Pool     = Round.Pools[PoolIndex];
                        string   PoolText = "";
                        PoolText += Pool.PoolName + "\n";
                        for (int TeamIndex = 0; TeamIndex < Pool.Teams.Count; ++TeamIndex)
                        {
                            TeamData Team = Pool.Teams[TeamIndex].Data;
                            PoolText += (TeamIndex + 1) + ". " + Team.PlayerNames + "\n";
                        }

                        GUIStyle ButtonStyle = new GUIStyle("button");
                        GUIStyle PoolStyle   = new GUIStyle("button");
                        PoolStyle.alignment        = TextAnchor.UpperLeft;
                        PoolStyle.normal.textColor = (EPool)PoolIndex == CurPool ? Color.green : ButtonStyle.normal.textColor;
                        PoolStyle.hover.textColor  = (EPool)PoolIndex == CurPool ? Color.green : ButtonStyle.hover.textColor;
                        PoolStyle.fontStyle        = (EPool)PoolIndex == CurPool ? FontStyle.Bold : ButtonStyle.fontStyle;
                        Vector2 PoolTextSize = PoolStyle.CalcSize(new GUIContent(PoolText));
                        if (GUILayout.Button(PoolText, PoolStyle, GUILayout.Width(LeftRect.width * .9f), GUILayout.Height(PoolTextSize.y)))
                        {
                            SetCurrentPool((EPool)PoolIndex);
                            InitJudgersNameIds();
                            ++Global.CurDataState;
                            bFestivalJudging = false;
                        }
                    }
                }
                else if (Round.Pools.Count == 4)
                {
                    for (int ButIndex = 0; ButIndex < 2; ++ButIndex)
                    {
                        string PoolText = "";

                        for (int PoolIndex = 0; PoolIndex < 2; ++PoolIndex)
                        {
                            PoolData Pool = Round.Pools[2 * PoolIndex + ButIndex];
                            PoolText += Pool.PoolName + "\n";
                            for (int TeamIndex = 0; TeamIndex < Pool.Teams.Count; ++TeamIndex)
                            {
                                TeamData Team = Pool.Teams[TeamIndex].Data;
                                PoolText += (TeamIndex + 1) + ". " + Team.PlayerNames + "\n";
                            }

                            PoolText += "\n";
                        }

                        GUIStyle ButtonStyle = new GUIStyle("button");
                        GUIStyle PoolStyle   = new GUIStyle("button");
                        PoolStyle.alignment        = TextAnchor.UpperLeft;
                        PoolStyle.normal.textColor = ButIndex == (int)CurPool ? Color.green : ButtonStyle.normal.textColor;
                        PoolStyle.hover.textColor  = ButIndex == (int)CurPool ? Color.green : ButtonStyle.hover.textColor;
                        PoolStyle.fontStyle        = ButIndex == (int)CurPool ? FontStyle.Bold : ButtonStyle.fontStyle;
                        Vector2 PoolTextSize = PoolStyle.CalcSize(new GUIContent(PoolText));
                        if (GUILayout.Button(PoolText, PoolStyle, GUILayout.Width(LeftRect.width * .9f), GUILayout.Height(PoolTextSize.y)))
                        {
                            CurFestivalPool  = (EPool)ButIndex;
                            bFestivalJudging = true;
                        }
                    }
                }

                GUILayout.EndVertical();
                GUILayout.EndScrollView();
                GUILayout.EndArea();
            }
            else if (!bFestivalJudging || CurPool != EPool.None)
            {
                float LeftRectWidth = Screen.width * .45f;
                //new Rect(Screen.width - RightRectWidth - 20, AreaRect.y, RightRectWidth, Screen.height - AreaRect.y - 20);
                GUILayout.BeginArea(LeftRect);
                GUILayout.BeginVertical();

                GUIStyle TeamStyle = new GUIStyle("button");
                TeamStyle.fontSize  = 17;
                TeamStyle.alignment = TextAnchor.MiddleLeft;
                GUIStyle        BackStyle = new GUIStyle(TeamStyle);
                List <PoolData> Pools     = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools;
                if (CurPool >= 0 && (int)CurPool < Pools.Count)
                {
                    for (int TeamIndex = 0; TeamIndex < Pools[(int)CurPool].Teams.Count; ++TeamIndex)
                    {
                        TeamData Data = Pools[(int)CurPool].Teams[TeamIndex].Data;
                        if (Data != null)
                        {
                            GUIContent TeamContent = new GUIContent((TeamIndex + 1) + ". " + Data.PlayerNames);
                            Vector2    TeamSize    = TeamStyle.CalcSize(TeamContent);
                            TeamStyle.fontStyle = TeamIndex == CurTeam ? FontStyle.Bold : FontStyle.Normal;

                            if (!bLockedForJudging)
                            {
                                TeamStyle.normal.textColor = TeamIndex == CurTeam ? Color.green : new GUIStyle("button").normal.textColor;
                                TeamStyle.hover.textColor  = TeamIndex == CurTeam ? Color.green : new GUIStyle("button").hover.textColor;
                            }
                            else
                            {
                                TeamStyle.normal.textColor = TeamIndex == CurTeam ? Color.green : Color.gray;
                                TeamStyle.hover.textColor  = TeamIndex == CurTeam ? Color.green : Color.gray;
                                TeamStyle.active.textColor = TeamIndex == CurTeam ? Color.green : Color.gray;
                            }

                            if (GUILayout.Button(TeamContent, TeamStyle, GUILayout.Width(LeftRectWidth), GUILayout.Height(TeamSize.y)))
                            {
                                if (!bLockedForJudging)
                                {
                                    CurTeam = TeamIndex;
                                    ++Global.CurDataState;
                                }
                            }
                        }
                    }
                }

                GUILayout.Space(Screen.height * .03f);

                GUIContent BackContent = new GUIContent("<- Back To Pool Selection");
                Vector2    BackSize    = BackStyle.CalcSize(BackContent);
                if (GUILayout.Button(BackContent, BackStyle, GUILayout.Width(LeftRectWidth), GUILayout.Height(BackSize.y)))
                {
                    SetCurrentPool(EPool.None);
                    CurTeam          = -1;
                    bFestivalJudging = false;
                }

                GUILayout.EndVertical();
                GUILayout.EndArea();

                // Ready Buttons
                if (CurTeam >= 0)
                {
                    DrawControlButtons();
                }
            }
        }
        else
        {
            SetCurrentPool(EPool.None);
            bFestivalJudging = false;
        }
        #endregion

        #region Judges
        if (CurPool != EPool.None && RData != null)
        {
            Rect RightRect = new Rect(Screen.width * .5f + 20, Screen.height * .22f, Screen.width / 2 - 40, Screen.height * .88f - 20);
            GUILayout.BeginArea(RightRect);
            GUILayout.BeginVertical();

            GUIStyle CatHeaderStyle = new GUIStyle("label");
            CatHeaderStyle.fontSize  = 17;
            CatHeaderStyle.fontStyle = FontStyle.Bold;


            GUILayout.Label("AI Judges:", CatHeaderStyle);
            foreach (int id in RData.AIJudgeIds)
            {
                DrawJudgeLabel(RData, id);
            }
            GUILayout.Label("Ex Judges:", CatHeaderStyle);
            foreach (int id in RData.ExJudgeIds)
            {
                DrawJudgeLabel(RData, id);
            }
            GUILayout.Label("Diff Judges:", CatHeaderStyle);
            foreach (int id in RData.DiffJudgeIds)
            {
                DrawJudgeLabel(RData, id);
            }

            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
        #endregion
    }
Ejemplo n.º 22
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();
        }
    }
Ejemplo n.º 23
0
    private void UpdateFinishRoutineAndGoToNextTeam()
    {
        if (bJudging && ActiveJudgingJudgers == 0)
        {
            ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);
            if (RData != null)
            {
                int JudgesCount = 0;
                foreach (int id in RData.AIJudgeIds)
                {
                    ++JudgesCount;
                }
                foreach (int id in RData.ExJudgeIds)
                {
                    ++JudgesCount;
                }
                foreach (int id in RData.DiffJudgeIds)
                {
                    ++JudgesCount;
                }

                TeamData TData = Global.GetTeamData(CurDivision, CurRound, CurPool, CurTeam);
                if (TData.RoutineScores.GetTotalValidScores() >= JudgesCount)
                {
                    // If we got all results
                    StopRoutine();

                    if (Global.IsValid(CurDivision, CurRound, CurPool, CurTeam))
                    {
                        int curPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[(int)CurPool].Teams.Count;

                        if (bFestivalJudging)
                        {
                            int cachedTeamIndex = CurTeam;
                            int newPool         = (int)CurPool + 2;

                            if (newPool >= 4)
                            {
                                newPool = newPool % 4;
                                if (newPool < Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools.Count)
                                {
                                    int newPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[newPool].Teams.Count;

                                    if (cachedTeamIndex < newPoolTeamCount - 1)
                                    {
                                        CurPool = (EPool)newPool;
                                        InitJudgersNameIds();
                                        CurTeam = cachedTeamIndex + 1;
                                        ++Global.CurDataState;
                                    }
                                    else if (cachedTeamIndex < curPoolTeamCount - 1)
                                    {
                                        CurTeam = cachedTeamIndex + 1;
                                        ++Global.CurDataState;
                                    }
                                    else
                                    {
                                        // End of pools
                                    }
                                }
                            }
                            else
                            {
                                int newPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[newPool].Teams.Count;

                                if (cachedTeamIndex >= newPoolTeamCount && cachedTeamIndex < curPoolTeamCount - 1)
                                {
                                    CurTeam = cachedTeamIndex + 1;
                                    ++Global.CurDataState;
                                }
                                else if (cachedTeamIndex < newPoolTeamCount)
                                {
                                    CurPool = (EPool)newPool;
                                    CurTeam = cachedTeamIndex;
                                    InitJudgersNameIds();
                                    ++Global.CurDataState;
                                }
                                else
                                {
                                    // End of Pools
                                }
                            }
                        }
                        else
                        {
                            if (CurTeam < curPoolTeamCount - 1)
                            {
                                ++CurTeam;
                                ++Global.CurDataState;
                            }
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 24
0
 public PoolKey(EDivision inDivision, ERound inRound, EPool inPool)
 {
     division = inDivision;
     round    = inRound;
     pool     = inPool;
 }
Ejemplo n.º 25
0
        public void Init()
        {
            if (divisions.Count == 0)
            {
                for (int i = 0; i < (int)EDivision.Max; ++i)
                {
                    DivisionData dd = new DivisionData((EDivision)i);
                    dd.CreateData();
                    divisions.Add(dd);
                }
            }
            else
            {
                for (EDivision division = EDivision.Open; division < EDivision.Max; ++division)
                {
                    if ((int)division < divisions.Count)
                    {
                        DivisionData dd = divisions[(int)division];

                        if (dd.division == EDivision.None)
                        {
                            dd.division = division;
                        }

                        for (ERound round = ERound.Finals; round < ERound.Max; ++round)
                        {
                            if ((int)round < dd.rounds.Count)
                            {
                                RoundData rd = dd.rounds[(int)round];
                                if (rd.round == ERound.None || rd.round == ERound.Max)
                                {
                                    rd.round = round;
                                }

                                if (rd.maxTeams == 0)
                                {
                                    rd.InitMaxTeams(division, round);
                                }

                                int poolCount = GetPoolCount(round);
                                for (EPool pool = EPool.A; (int)pool < poolCount; ++pool)
                                {
                                    if ((int)pool < rd.pools.Count)
                                    {
                                        PoolData pd = rd.pools[(int)pool];

                                        if (pd.pool == EPool.None)
                                        {
                                            pd.pool = pool;
                                        }
                                    }
                                    else
                                    {
                                        PoolData pd = new PoolData(pool);
                                        pd.CreateData();
                                        rd.pools.Add(pd);
                                    }
                                }
                            }
                            else
                            {
                                RoundData rd = new RoundData(division, round);
                                rd.CreateData();
                                dd.rounds.Add(rd);
                            }
                        }
                    }
                    else
                    {
                        DivisionData dd = new DivisionData(division);
                        dd.CreateData();
                        divisions.Add(dd);
                    }
                }
            }
        }
Ejemplo n.º 26
0
 public PoolData(EPool inPool)
 {
     pool = inPool;
 }
Ejemplo n.º 27
0
    void SendCurDataRPC(int InCurState, int InDivision, int InRound, int InPool, int InTeam, int InActiveJudgingJudgers)
    {
        JudgerBase Judger = Global.GetActiveJudger();

        if (Judger)
        {
            Debug.Log(" got SendCurDataRPC " + Judger.bIsJudging + "  " + Judger.bLockedForJudging + "  " + Judger.bClientReadyToBeLocked +
                      " " + Judger.bHeadJudgeRequestingReady + " " + Judger.bIsEditing + " " + Judger.bRoutineTimeEnded);
        }

        if (Judger && !Judger.bIsJudging && !Judger.bIsEditing)
        {
            EPool newPool = (EPool)InPool;
            int   oldJudgeCategoryIndex = Judger.JudgeCategoryIndex;
            bool  bIsScoresPool         = newPool > EPool.Max;
            bool  bIsDiffJudger         = Global.ActiveInterface == EInterface.DiffJudger || Global.bOverrideInterfaceAiScores;

            Global.SetOverrideInterfaceAiScores(bIsScoresPool && bIsDiffJudger);
            Judger = Global.GetActiveJudger();
            Judger.JudgeCategoryIndex = oldJudgeCategoryIndex;
            Judger.ResetJudgeNameId();

            if (bIsScoresPool)
            {
                if (newPool == EPool.PostScoresAC)
                {
                    newPool = Global.bOverrideInterfaceAiScores ? EPool.A : EPool.C;
                }
                else if (newPool == EPool.PostScoresCA)
                {
                    newPool = Global.bOverrideInterfaceAiScores ? EPool.C : EPool.A;
                }
                else if (newPool == EPool.PostScoresBD)
                {
                    newPool = Global.bOverrideInterfaceAiScores ? EPool.B : EPool.D;
                }
                else
                {
                    newPool = Global.bOverrideInterfaceAiScores ? EPool.D : EPool.B;
                }
            }

            Judger.CurDivision           = (EDivision)InDivision;
            Judger.CurRound              = (ERound)InRound;
            Judger.CurPool               = newPool;
            Judger.CurTeam               = InTeam;
            Judger.WaitingForJudgesCount = InActiveJudgingJudgers;

            Global.CurDataState = InCurState;
            LastSyncedCurState  = InCurState;

            Debug.Log("!!!!!!!!!!!!!! set judge data");
        }

        if (Global.Obj.OverlayGo && Global.Obj.OverlayGo.activeSelf)
        {
            Overlay OverlayScript = Global.Obj.OverlayGo.GetComponent <Overlay>();
            if (OverlayScript)
            {
                OverlayScript.CurDivision = (EDivision)InDivision;
                OverlayScript.CurRound    = (ERound)InRound;
                OverlayScript.CurPool     = (EPool)InPool;
                OverlayScript.CurTeam     = InTeam;
            }
        }
    }
Ejemplo n.º 28
0
        public void GenerateNextPool(EDivision division, ERound round, EPool pool)
        {
            PoolData pool1;
            PoolData pool2;
            PoolData nextPool;

            if (!TryGetAutoGeneratePools(division, round, pool, out pool1, out pool2, out nextPool))
            {
                return;
            }

            var nextPoolTeams = nextPool.teamList.teams;

            nextPoolTeams.Clear();
            if (nextPoolTeams.Count == 0)
            {
                var pool1Teams     = pool1.teamList.teams;
                var pool2Teams     = pool2.teamList.teams;
                int maxTeamsInPool = Math.Max(pool1Teams.Count, pool2Teams.Count);
                for (int rank = 1; rank <= maxTeamsInPool; ++rank)
                {
                    int teamIndex1 = GetRankTeamIndex(pool1.resultRank, rank);
                    int teamIndex2 = GetRankTeamIndex(pool2.resultRank, rank);

                    if (teamIndex1 < 0)
                    {
                        nextPoolTeams.Insert(0, pool2Teams[teamIndex2]);
                        continue;
                    }
                    else if (teamIndex2 < 0)
                    {
                        nextPoolTeams.Insert(0, pool1Teams[teamIndex1]);
                        continue;
                    }

                    if (teamIndex1 >= pool1Teams.Count || teamIndex2 >= pool2Teams.Count)
                    {
                        break;
                    }

                    if (GetTeamRankingPoints(pool1Teams[teamIndex1]) < GetTeamRankingPoints(pool2Teams[teamIndex2]))
                    {
                        nextPoolTeams.Insert(0, pool2Teams[teamIndex2]);
                        nextPoolTeams.Insert(0, pool1Teams[teamIndex1]);
                    }
                    else
                    {
                        nextPoolTeams.Insert(0, pool1Teams[teamIndex1]);
                        nextPoolTeams.Insert(0, pool2Teams[teamIndex2]);
                    }

                    if (nextPoolTeams.Count >= GetMaxTeamsForPool(division, round))
                    {
                        break;
                    }
                }
            }
            else
            {
                // Warning about not being able to generate next teams pools because there is already data
            }
        }
Ejemplo n.º 29
0
 public void OnPoolRankingsChanged(ERound round, EPool pool)
 {
     GenerateNextPool(poolsDivision, round, pool);
 }
Ejemplo n.º 30
0
 private bool TryGetAutoGeneratePools(ERound round, EPool pool, out PoolData pool1, out PoolData pool2, out PoolData nextPool)
 {
     return(TryGetAutoGeneratePools(poolsDivision, round, pool, out pool1, out pool2, out nextPool));
 }
Ejemplo n.º 31
0
 private void ParseCondition(string vsCondition)
 {
     string[] parts = vsCondition.Split(' ');
     foreach (string sPart in parts) {
         string s = sPart.ToUpper().Trim();
         if (sPart.Trim().Length == 0)
             continue;
         foreach (var e in Enum.GetValues(typeof(EPool)))
             if (s.Equals(((EPool)e).ToString("F")))
                 EntityPool = (EPool)e;
         foreach (var e in Enum.GetValues(typeof(EMatch)))
             if (s.Equals(((EMatch)e).ToString("F")))
                 EntityMatch = (EMatch)e;
         foreach (var e in Enum.GetValues(typeof(EOrder)))
             if (s.Equals(((EOrder)e).ToString("F")))
                 EntityOrder = (EOrder)e;
         if (s.Equals("MAX"))
             EMin = false;
     }
 }