Пример #1
0
 void Loaded()
 {
     lineNum     = new Dictionary <string, int>();
     openPanels  = new Dictionary <ulong, string>();
     _allData    = new Dictionary <ulong, AccuracyData>();
     _globalData = new AccuracyData();
 }
Пример #2
0
        AccuracyData GetAccData(ulong playerId)
        {
            AccuracyData data;

            if (_allData.ContainsKey(playerId))
            {
                data = _allData[playerId];
            }
            else
            {
                data = new AccuracyData();
                _allData.Add(playerId, data);
            }
            return(data);
        }
Пример #3
0
        void CreateUI(BasePlayer player)
        {
            CuiElementContainer containerMain = new CuiElementContainer();
            AccuracyData        data          = _allData[player.userID];

            #region main panel
            // Headers
            mainElementAccuracy = containerMain.Add(new CuiPanel {
                Image =
                {
                    Color = "0 0 0 0.5"
                },
                RectTransform =
                {
                    AnchorMin = "0.005 0.940",
                    AnchorMax = "0.200 0.960" //left digit is viewheight from left, right digit is Y axis, viewheight from bottom
                },
                CursorEnabled = false,
            }, "Hud", mainPanelAccuracyNameHeader);

            containerMain.Add(new CuiLabel {
                Text =
                {
                    Text     = "Overall Accuracy",
                    FontSize =                 11,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = $"0.05 0.050",
                    AnchorMax = $"0.95 0.950"
                }
            }, mainElementAccuracy);

            // Panels
            mainElementAccuracy = containerMain.Add(new CuiPanel {
                Image =
                {
                    Color = "0 0 0 0.5"
                },
                RectTransform =
                {
                    AnchorMin = "0.005 0.680",
                    AnchorMax = "0.200 0.937" //left digit is viewheight from left, right digit is Y axis, viewheight from bottom
                },
                CursorEnabled = false,
            }, "Hud", mainPanelAccuracyName);

            _UILineNum(mainElementAccuracy);
            double box1 = 0.070;
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Avg Distance", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.distanceAvg().ToString()}m", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Shots", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.shots.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Landed", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.shotsLanded.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate()}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Missed", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Missed().ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.MissedRate()}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Head", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Head.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate(HitArea.Head)}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Chest", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Chest.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate(HitArea.Chest)}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Stomach", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Stomach.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate(HitArea.Stomach)}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Arm", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Arm.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate(HitArea.Arm)}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Leg", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Leg.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate(HitArea.Leg)}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Foot", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Foot.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate(HitArea.Foot)}", 3, box1);

            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"Hand", 1, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Hand.ToString()}", 2, box1);
            AddCuiLabel(containerMain, 12, mainElementAccuracy, $"{data.Rate(HitArea.Hand)}", 3, box1);
            #endregion

            #region Buttons
            mainElementAccuracy = containerMain.Add(new CuiPanel {
                Image =
                {
                    Color = "0 0 0 0.5"
                },
                RectTransform =
                {
                    AnchorMin = "0.005 0.637",
                    AnchorMax = "0.200 0.677" //left digit is viewheight from left, right digit is Y axis, viewheight from bottom
                },
                CursorEnabled = false,
            }, "Hud", mainPanelButtons);

            CreateButton(ref containerMain, mainElementAccuracy, UIColors["buttongrey"], "Reset", 12, "0.020 0.050", "0.326 0.950", "Accuracy_ResetStats");
            CreateButton(ref containerMain, mainElementAccuracy, ShowExtraStats(player) ? UIColors["buttongreen"] : UIColors["buttonred"], "Extra Stats", 12, "0.346 0.050", "0.672 0.950", "Accuracy_ToggleExtraStats");
            CreateButton(ref containerMain, mainElementAccuracy, InfiniteAmmo(player) ? UIColors["buttongreen"] : UIColors["buttonred"], "Infinite Ammo", 12, "0.692 0.050", "0.980 0.950", "Accuracy_ToggleInfiniteAmmo");

            #endregion

            if (ShowExtraStats(player))
            {
                #region 25m panel
                // 25 meters
                AddExtraPanel(containerMain, 1, 1, "<=25m Accuracy", mainPanelAccuracyNameHeader25, mainPanelAccuracyName25, out mainElementAccuracy25);
                box1 = 0.15;

                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"Shots", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"{data.data_25m.shots.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"Landed", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"{data.data_25m.shotsLanded.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"{data.data_25m.Rate()}", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"Missed", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"{data.data_25m.Missed().ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"{data.data_25m.MissedRate()}", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"Head", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"{data.data_25m.Head.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy25, $"{data.data_25m.Rate(HitArea.Head)}", 3, box1);
                #endregion
                #region 50m panel
                // 25 meters
                AddExtraPanel(containerMain, 1, 2, "25-50m Accuracy", mainPanelAccuracyNameHeader50, mainPanelAccuracyName50, out mainElementAccuracy50);


                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"Shots", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"{data.data_50m.shots.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"Landed", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"{data.data_50m.shotsLanded.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"{data.data_50m.Rate()}", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"Missed", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"{data.data_50m.Missed().ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"{data.data_50m.MissedRate()}", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"Head", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"{data.data_50m.Head.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy50, $"{data.data_50m.Rate(HitArea.Head)}", 3, box1);
                #endregion
                #region 100m panel
                // 100 meters
                AddExtraPanel(containerMain, 1, 3, "50-100m Accuracy", mainPanelAccuracyNameHeader100, mainPanelAccuracyName100, out mainElementAccuracy100);


                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"Shots", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"{data.data_100m.shots.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"Landed", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"{data.data_100m.shotsLanded.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"{data.data_100m.Rate()}", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"Missed", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"{data.data_100m.Missed().ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"{data.data_100m.MissedRate()}", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"", 3, box1);

                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"Head", 1, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"{data.data_100m.Head.ToString()}", 2, box1);
                AddCuiLabel(containerMain, 12, mainElementAccuracy100, $"{data.data_100m.Rate(HitArea.Head)}", 3, box1);
                #endregion
            }
            openPanels.Add(player.userID, mainElementAccuracy);

            CuiHelper.AddUi(player, containerMain);
        }