Esempio n. 1
0
    /// <summary>
    /// Show and control UI for knockout stage
    /// </summary>
    private void SetFinalsPanel()
    {
        //Set cup image
        Tournament tourCup = Resources.Load <Tournament>("Tours/" + tourInfo.tourName);

        tourCupImage.sprite = tourCup.cupImage;

        int index, limit = 0, matchListIndex = 0;

        if (tourInfo.teamsForKnockoutStage == 16)
        {
            index = 0;
            tourFinalsStructure.sprite = round16Structure;
            if (tourInfo.matchesRound == 3)
            {
                limit = 1;
                tourFinalsRound.text = "Round of 16";
                roundText.text       = "Round of 16";
            }
            else if (tourInfo.matchesRound == 4)
            {
                limit = 2;
                tourFinalsRound.text = "Quarter finals";
                roundText.text       = "Quarter finals";
            }
            else if (tourInfo.matchesRound == 5)
            {
                limit = 3;
                tourFinalsRound.text = "Semi-finals";
                roundText.text       = "Semi-finals";
            }
            else if (tourInfo.matchesRound == 6)
            {
                limit = 3;
                tourFinalsRound.text = "FINAL";
                roundText.text       = "FINAL";
                SetFinalUI();
            }
        }
        else
        {
            index = 1;
            tourFinalsStructure.sprite = round8Strucure;
            if (tourInfo.matchesRound == 3)
            {
                limit = 2;
                tourFinalsRound.text = "Quarter finals";
                roundText.text       = "Quarter finals";
            }
            else if (tourInfo.matchesRound == 4)
            {
                limit = 3;
                tourFinalsRound.text = "Semi-finals";
                roundText.text       = "Semi-finals";
            }
            else if (tourInfo.matchesRound == 5)
            {
                limit = 3;
                tourFinalsRound.text = "FINAL";
                roundText.text       = "FINAL";
                SetFinalUI();
            }
        }


        if (tourInfo.matchesRound >= 3)
        {
            leftKeyFinals.gameObject.SetActive(true);
            rightKeyFinals.gameObject.SetActive(true);
            for (int i = index; i < limit; i++)
            {
                Transform leftMatchUI  = leftKeyFinals.GetChild(i);
                Transform rightMatchUI = rightKeyFinals.GetChild(i);
                leftMatchUI.gameObject.SetActive(true);
                rightMatchUI.gameObject.SetActive(true);

                for (int j = 0; j < leftMatchUI.childCount; j++)
                {
                    //////////////////////////////////////////// //Left key UI
                    Transform     matchUI = leftMatchUI.GetChild(j).transform;
                    MatchTourInfo match   = tourInfo.leftKeyFinalMatches[matchListIndex];

                    Image localFlag = matchUI.GetChild(0).GetComponent <Image>();
                    Image visitFlag = matchUI.GetChild(1).GetComponent <Image>();

                    localFlag.sprite = GetTeamInformation(match.localTeam.teamName).flag;
                    visitFlag.sprite = GetTeamInformation(match.visitTeam.teamName).flag;

                    if (match.played)
                    {
                        if (tourInfo.GetMatchWinnerString(match) == "local")
                        {
                            localFlag.gameObject.SetActive(false);
                            visitFlag.gameObject.SetActive(true);
                        }
                        else
                        {
                            localFlag.gameObject.SetActive(true);
                            visitFlag.gameObject.SetActive(false);
                        }
                    }

                    ///////////////////////////Right key UI
                    matchUI = rightMatchUI.GetChild(j).transform;
                    match   = tourInfo.rightKeyFinalMatches[matchListIndex];

                    localFlag = matchUI.GetChild(0).GetComponent <Image>();
                    visitFlag = matchUI.GetChild(1).GetComponent <Image>();

                    localFlag.sprite = GetTeamInformation(match.localTeam.teamName).flag;
                    visitFlag.sprite = GetTeamInformation(match.visitTeam.teamName).flag;


                    if (match.played)
                    {
                        if (tourInfo.GetMatchWinnerString(match) == "local")
                        {
                            localFlag.gameObject.SetActive(false);
                            visitFlag.gameObject.SetActive(true);
                        }
                        else
                        {
                            localFlag.gameObject.SetActive(true);
                            visitFlag.gameObject.SetActive(false);
                        }
                    }

                    matchListIndex++;
                }
            }
        }
    }