Exemple #1
0
        public static void ShowResultsUiFor(BasePlayer player,
                                            IemUtils.IIemTeamGame teamData)
        {
            int    teamSlot = 0;
            string gui      = "game_results_overlay";

            guiList.Add(gui);
            CuiHelper.DestroyUi(player, gui);

            var elements = new CuiElementContainer();
            var mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.6 0.3 0.3 1.0"
                },
                RectTransform =
                {
                    AnchorMin = "0.15 0.12",
                    AnchorMax = "0.85 0.9"
                },
                CursorEnabled = true
            }, "Overlay", gui);



            elements.Add(new CuiButton
            {
                Button =
                {
                    //Command = "iem.menu toggle",
                    Close = mainName,
                    Color = "128 64 0 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.94 0.94",
                    AnchorMax = "0.98 0.98",
                },
                Text =
                {
                    Text     = "X",
                    FontSize =                      22,
                    Align    = TextAnchor.MiddleCenter,
                    Color    = "255 255 255             1"
                }
            }, mainName);

            elements.Add(new CuiButton
            {
                Button =
                {
                    Close = mainName,
                    Color = "0 255 0 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.4 0.16",
                    AnchorMax = "0.6 0.2"
                },
                Text =
                {
                    Text     = "OK",
                    FontSize =   22,
                    Align    = TextAnchor.MiddleCenter
                }
            }, mainName);

            string winnerMessage = "";

            if (teamData.Winner() != null)
            {
                winnerMessage += "Team " + teamData.Winner().Name + "won!";
            }

            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = winnerMessage,
                    FontSize =            28,
                    Align    = TextAnchor.UpperCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.2 0.8",
                    AnchorMax = "0.8 0.95"
                }
            }, mainName);

            foreach (var team in teamData.Teams.Values)
            {
                //IemUtils.DLog(item.TeamName);
                CuiHelper.DestroyUi(player, team.Name);



                elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text     = team.Name,
                        FontSize =        28,
                        Align    = TextAnchor.UpperCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = teamSlotsResults[teamSlot, 0],
                        AnchorMax = teamSlotsResults[teamSlot, 1]
                    }
                }, mainName);

                string playerListString = "\n\n";
                foreach (var teamPlayer in team.Players.Values)
                {
                    playerListString = playerListString + teamPlayer.Name + ":" + teamPlayer.Score + "\n";
                }

                elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text     = $"{playerListString}",
                        FontSize =                    18,
                        Align    = TextAnchor.UpperCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = teamSlotsResults[teamSlot, 0],
                        AnchorMax = teamSlotsResults[teamSlot, 1]
                    }
                }, mainName);


                teamSlot++;
            }
            CuiHelper.AddUi(player, elements);
        }