Exemplo n.º 1
0
    void showGames()
    {
        if (mRoom == null || mGames == null)
        {
            return;
        }

        setText(transform, "title/roomid", "房间号:" + mRoom.room_id);
        setText(transform, "title/desc", mRoom.info.huafen + "/" + mRoom.info.huafen + (mRoom.info.maima ? "带苍蝇" : "不带苍蝇") + mRoom.info.maxGames + "局");

        for (int i = 0; i < mGames.Count; i++)
        {
            HistoryGame game = mGames[i];
            Transform   item = getItem(i);

            setText(item, "id", "" + (game.game_index + 1));
            setText(item, "time", PUtils.formatTime(game.create_time, "yyyy/MM/dd HH:mm:ss"));

            Transform           seats = item.Find("seats");
            UITable             table = seats.GetComponent <UITable>();
            List <HistorySeats> ss    = mRoom.info.seats;

            int j = 0;

            for (; j < seats.childCount && j < ss.Count; j++)
            {
                Transform    seat = seats.GetChild(j);
                HistorySeats s    = ss[j];

                seat.gameObject.SetActive(true);
                setText(seat, "name", s.name);
                setText(seat, "score", "" + game.result [j]);
                setIcon(seat, "bghead/icon", s.uid);
            }

            for (int k = j; k < seats.childCount; k++)
            {
                Transform seat = seats.GetChild(k);
                seat.gameObject.SetActive(false);
            }

            table.Reposition();

            setBtnEvent(item, "btn_share", () => {
            });

            setBtnEvent(item, "btn_replay", () => {
                onBtnReplay(game.id);
            });
        }

        updateItems(mGames.Count);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the wins for both teams
        /// </summary>
        /// <returns>KeyValuePair TeamBlue TeamRed</returns>
        public static KeyValuePair <int, int> GetWins(History history)
        {
            if (history == null)
            {
                throw new ArgumentNullException(nameof(history));
            }

            int teamRedWins  = 0;
            int teamBlueWins = 0;

            foreach (HistoryEvent curEvent in history.Events)
            {
                if (curEvent.Game == null)
                {
                    continue;
                }

                HistoryGame curGame = curEvent.Game;

                if (curGame.Scores == null)
                {
                    continue;
                }

                int teamRedCurrent  = 0;
                int teamBlueCurrent = 0;

                foreach (HistoryScore CurScore in curGame.Scores)
                {
                    switch (CurScore.Match.Team.ToLower(CultureInfo.CurrentCulture))
                    {
                    case "red":
                        teamRedCurrent++;
                        break;

                    case "blue":
                        teamBlueCurrent++;
                        break;
                    }
                }

                if (teamRedCurrent > teamBlueCurrent)
                {
                    teamRedWins++;
                }
                else if (teamBlueCurrent > teamRedCurrent)
                {
                    teamBlueWins++;
                }
            }
            return(new KeyValuePair <int, int>(teamBlueWins, teamRedWins));
        }