public static List <MatchInfo> GetMatchInfos(TournamentItem item)
 {
     if (item.ItemType == TournamentItem.Type.CUP)
     {
         return(createMatchInfosForCup(item));
     }
     else
     {
         return(createMatchInfosForLeague(item));
     }
 }
示例#2
0
    void ShowDetail(GameObject obj)
    {
        TournamentItem currentselect = obj.GetComponent <TournamentItem>();

        CheckWinner(currentselect.info);

        if (currentShow != null)
        {
            if (currentShow.info.tournamentId != currentselect.info.tournamentId)
            {
                currentShow = currentselect;
                detail.SetData(currentShow.info);
                GameManager.Instance.currentTournamentInfo = currentShow.info;
            }
        }
        else
        {
            currentShow = obj.GetComponent <TournamentItem>();
            detail.SetData(currentShow.info);
        }

        if (currentShow.info.zoneId < 0 || currentShow.info.roomId < 0)
        {
            btnShow.gameObject.SetActive(false);
            btnRegister.gameObject.SetActive(false);
            lblStatus.gameObject.SetActive(false);
        }
        else
        {
            btnShow.gameObject.SetActive(true);
            if (!currentShow.info.isRegister)
            {
                if (currentShow.info.remainStartTime > 0)
                {
                    btnRegister.gameObject.SetActive(true);
                    lblStatus.gameObject.SetActive(false);
                }
                else
                {
                    btnRegister.gameObject.SetActive(false);
                    lblStatus.text = "(Hết thời gian đăng ký)";
                }
            }
            else
            {
                btnRegister.gameObject.SetActive(false);
                lblStatus.gameObject.SetActive(true);
                lblStatus.text = "(Đã đang ký)";
            }
        }
    }
示例#3
0
    void updateRoundSection()
    {
        clearRoundSection();
        currentItem = OnlineTournamentHandler.Controller.Tournament.SchemeData.Rounds[currentlyShownRoundIndex].TournamentItems[currentlyShownItemIndex];

        if (currentItem.ItemType == TournamentItem.Type.CUP)
        {
            buildCupScheme();
        }
        else if (currentItem.ItemType == TournamentItem.Type.LEAGUE)
        {
            buildLeagueScheme();
        }
    }
    static List <MatchInfo> createMatchInfosForCup(TournamentItem item)
    {
        List <MatchInfo> result = new List <MatchInfo>();

        foreach (MatchConfiguration conf in item.Schedule.MatchConfigurations)
        {
            if (conf.GuestAlias == GameData.CurrentTeam.TeamAlias || conf.HostAlias == GameData.CurrentTeam.TeamAlias)
            {
                continue;
            }

            PackedScene scene = (PackedScene)ResourceLoader.Load("Scenes/AdvancedComponents/MatchInfo.tscn");
            MatchInfo   info  = (MatchInfo)scene.Instance();
            info.Initiailze(conf.HostAlias, conf.GuestAlias);
            result.Add(info);
        }

        return(result);
    }
示例#5
0
 private void OnProcessPluginMessage(string command, string action, EsObject paremeters)
 {
     if (command == Fields.RESPONSE.COMMAND_TOURNAMENT)
     {
         EsObject[] esObject = paremeters.getEsObjectArray("tournaments");
         for (int i = 0; i < esObject.Length; i++)
         {
             TournamentInfo info = new TournamentInfo(esObject[i]);
             GameObject     obj  = NGUITools.AddChild(gridTournament.gameObject, tournamentItemPrefab);
             obj.name = "Tournament" + info.tournamentId;
             TournamentItem item = obj.GetComponent <TournamentItem>();
             item.UpdateInfo(info);
             tournamentItems.Add(item);
         }
         gridTournament.Reposition();
         gridTournament.GetComponent <UICenterOnChild>().Recenter();
         WaitingView.Instance.Close();
     }
     if (command == "updateTournament")
     {
         if (paremeters.variableExists("tournamentId"))
         {
             int            id   = paremeters.getInteger("tournamentId");
             TournamentItem item = this.tournamentItems.Find(x => x.info.tournamentId == id);
             if (item != null)
             {
                 if (paremeters.variableExists("zoneId"))
                 {
                     item.info.zoneId = paremeters.getInteger("zoneId");
                 }
                 if (paremeters.variableExists("roomId"))
                 {
                     item.info.roomId = paremeters.getInteger("roomId");
                 }
             }
         }
         NGUITools.SetActive(btnShow.gameObject, currentShow.info.roomId >= 0);
     }
 }
    static List <MatchInfo> createMatchInfosForLeague(TournamentItem item)
    {
        List <MatchInfo> result = new List <MatchInfo>();

        int matchesPerTurn     = item.TeamCount / 2;
        int alreadyLoadedCount = (OnlineTournamentHandler.Controller.CurrentTurn - 1) * matchesPerTurn;

        for (int i = alreadyLoadedCount; i < alreadyLoadedCount + matchesPerTurn; i++)
        {
            if (item.Schedule.MatchConfigurations[i].GuestAlias == GameData.CurrentTeam.TeamAlias || item.Schedule.MatchConfigurations[i].HostAlias == GameData.CurrentTeam.TeamAlias)
            {
                continue;
            }

            PackedScene scene = (PackedScene)ResourceLoader.Load("Scenes/AdvancedComponents/MatchInfo.tscn");
            MatchInfo   info  = (MatchInfo)scene.Instance();
            info.Initiailze(item.Schedule.MatchConfigurations[i].HostAlias, item.Schedule.MatchConfigurations[i].GuestAlias);
            result.Add(info);
        }

        return(result);
    }
示例#7
0
 private static bool TournamentIsFree(TournamentItem item)
 {
     return(item.Type != "passwordProtected" && item.MaxCapacity - item.Capacity > 0);
     //|| (item.Status != "inProgress" && item.Type != "passwordProtected" && /*DateTime.Now.Subtract(item.CreatedTime).TotalMinutes > 20 && */item.MaxCapacity - item.Capacity > 0);
 }