Иконка ресурса

FREE Batia : 1.0.1 1.0.1

Нет прав для скачивания
C#:
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Rust;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
namespace Oxide.Plugins {
    [Info("Batia", "OxideBro <3", "1.0.1")]
    internal class Batia : RustPlugin {
        public List<BaseEntity> BaseEntityList = new List<BaseEntity>();
        [PluginReference]
        Plugin ImageLibrary;
        void Loaded() {
            ins = this;
            LoadSounds();
        }
        void OnServerInitialized() {
            if (ImageLibrary) {
                var images = config.bottleSetting.CustomItemsShop.Where(p => !string.IsNullOrEmpty(p.ImageURL));
                foreach (var check in images) ImageLibrary.Call("AddImage", check.ImageURL, check.ImageURL);
                //foreach (var check in config.bottleSetting.CustomItemsShop.Where(p => string.IsNullOrEmpty(p.ImageURL)))
                //    ImageLibrary.Call("AddImage", $"https://rustlabs.com/img/items180/{check.defaultItem.ShortName}.png", check.defaultItem.ShortName + 128);
                foreach (var check in config.artefactsSettings.ItemsAdded) {
                    ImageLibrary.Call("AddImage", check.ImageURL, check.ImageURL);
                }
                ImageLibrary.Call("AddImage", "https://i.imgur.com/ZS57k7Y.png", "https://i.imgur.com/ZS57k7Y.png");
                ImageLibrary.Call("AddImage", "https://i.imgur.com/CidcicJ.png", "https://i.imgur.com/CidcicJ.png");
                ImageLibrary.Call("AddImage", "https://i.imgur.com/yLsGJrM.png", "https://i.imgur.com/yLsGJrM.png");
                ImageLibrary.Call("AddImage", "https://i.imgur.com/ghyCq0Q.png", "https://i.imgur.com/ghyCq0Q.png");
            }
            if (config.gameStoresSettings == null) {
                config.gameStoresSettings = new GameStoresSettings() {
                    Secret = "", ShopID = ""
                }
                ;
                SaveConfig();
            }
            ServerMgr.Instance.StartCoroutine(DownloadImage("https://i.imgur.com/7fIELSt.png"));
            FindPositions();
            foreach (var player in BasePlayer.activePlayerList) {
                OnPlayerConnected(player);
            }
        }
        public string External = "UI_Batia_External";
        public string Internal = "UI_Batia_Internal";
        void DrawNPCUI(BasePlayer player) {
            CuiElementContainer container = new CuiElementContainer();
            CuiHelper.DestroyUi(player, External);
            CuiHelper.DestroyUi(player, Internal);
            container.Add(new CuiPanel {
                CursorEnabled = true, RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.235 0.227 0.180 0.90"
                }
            }
            , "Overlay", External);
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0.2"
                }
            }
            , External);
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.141 0.137 0.109 1", Sprite = "assets/content/ui/ui.background.transparent.radial.psd"
                }
            }
            , External);
            container.Add(new CuiElement {
                Parent = External, Name = External + ".Mood", Components = {
                    new CuiRawImageComponent {
                        Png = (string)ImageLibrary.Call("GetImage", GetImageInMood()), Color = "0.929 0.882 0.847 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "50 -110", OffsetMax = "150 -10"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = External + ".Mood", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 0.7", Text = $"<color=#EDE1D8>НАСТРОЕНИЕ: <b>{GetMoodTranslate(com.mood)}</b></color>\n{GetMoodInfoRmation(com.mood)}", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "110 -200", OffsetMax = "800 -30"
                    }
                }
            }
            );
            CuiHelper.AddUi(player, container);
            InitializeLayers(player);
            if (com != null && com.EndExpeditions.ContainsKey(player.userID)) CreateInfoPlayer(player, true);
        }
        void CreateInfoPlayer(BasePlayer player, bool opened) {
            CuiHelper.DestroyUi(player, External + ".Mood1" + ".panel");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiElement {
                Name = External + ".Mood1" + ".panel", Parent = "Overlay", Components = {
                    new CuiImageComponent {
                        FadeIn = 1f, Color = opened? "0.235 0.227 0.180 0.6" : "0.235 0.227 0.180 0" , Sprite = "assets/content/ui/ui.background.transparent.linear.psd"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = opened ? "-240 -81" : "-240 -141", OffsetMax = opened ? "-60 -30" : "-60 -90"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = External + ".Mood1" + ".panel", Name = External + ".Mood1", Components = {
                    new CuiRawImageComponent {
                        FadeIn = 1f, Png = (string)ImageLibrary.Call("GetImage", "https://i.imgur.com/ghyCq0Q.png"), Color = "0.929 0.882 0.847 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-30 -60", OffsetMax = "50 20"
                    }
                }
            }
            );
            if (opened) {
                container.Add(new CuiElement {
                    Parent = External + ".Mood1" + ".panel", Components = {
                        new CuiTextComponent {
                            FadeIn = 1f, Color = "0.929 0.882 0.847 0.5", Text = $"<color=#EDE1D8>ВАМ ПОСЫЛКА</color>", Align = TextAnchor.UpperLeft  /*,Font="robotocondensed-regular.ttf"*/
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0.03 0", AnchorMax = "1 0.9"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = External + ".Mood1" + ".panel", Components = {
                        new CuiTextComponent {
                            FadeIn = 1f, Color = "0.929 0.882 0.847 0.4", Text = $"НАЖМИТЕ ЧТОБЫ ЗАБРАТЬ", Align = TextAnchor.MiddleLeft , Font="robotocondensed-regular.ttf", FontSize = 12
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0.03 0", AnchorMax = "1 0.8"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = External + ".Mood1" + ".panel", Components = {
                        new CuiButtonComponent {
                            Color = "0.929 0.882 0.847 0", Command = "UI_Batia givepackage"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
            }
            else {
                container.Add(new CuiElement {
                    Parent = External + ".Mood1", Components = {
                        new CuiTextComponent {
                            FadeIn = 1f, Color = "0.929 0.882 0.847 0.4   ", Text = $"ЗАБРАТЬ", Align = TextAnchor.UpperCenter , Font="robotocondensed-regular.ttf"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 -0.3", AnchorMax = "1 0.05"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = External + ".Mood1", Components = {
                        new CuiButtonComponent {
                            Color = "0.929 0.882 0.847 0", Command = "UI_Batia givepackage"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
            }
            CuiHelper.AddUi(player, container);
        }
        string GetMoodTranslate(FatherComponent.Mood mood) {
            switch (mood) {
                case FatherComponent.Mood.Neutral : return "НЕЙТРАЛЬНЫЙ";
                case FatherComponent.Mood.Kind : return "ВЕСЁЛЫЙ";
                case FatherComponent.Mood.Evil : return "ЗЛОЙ";
            }
            return "НЕЙТРАЛЬНЫЙ";
        }
        string GetMoodInfoRmation(FatherComponent.Mood mood) {
            switch (mood) {
                case FatherComponent.Mood.Neutral : return "От его настроения зависит дальнейший диалог с ним.Предметы какие обменяет батя будут стандартные.Чем лучше настроение, тем больше предметов предложит батя";
                case FatherComponent.Mood.Kind : return "От его настроения зависит дальнейший диалог с ним.Предметы какие обменяет батя будут увеличенные.Чем лучше настроение тем, больше предметов предложит батя";
                case FatherComponent.Mood.Evil : return "Предметы какие обменяет батя будут уменьшены.Смотри осторожно, есть возможность получить леща от него.Батя не особо дружелюбный, бонусов не накинет.";
            }
            return "От его настроения зависит дальнейший диалог с ним.Предметы какие обменяет батя будут стандартные.Чем лучше настроение, тем больше предметов предложит батя";
        }
        string InitialLayer = "UI_Batia_InitialLayer";
        private void InitializeLayers(BasePlayer player, string SelectMenu = "") {
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , External, InitialLayer);
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.7 0", AnchorMax = "0.9 1", OffsetMin = "0 0", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0", Material = ""
                }
            }
            , InitialLayer, InitialLayer + ".C");
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "0.05 0.01", AnchorMax = "1 0.1"
                }
                , Button = {
                    Command = "UI_Batia close", Color = "0 0 0 0"
                }
                , Text = {
                    Text = "ВЫХОД", Align = TextAnchor.MiddleRight, Font = "robotocondensed-bold.ttf", FontSize = 26, Color = "0.929 0.882 0.847 0.4"
                }
            }
            , InitialLayer + ".C");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.01 0", AnchorMax = "0.65 0.75", OffsetMin = "0 0", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0", Material = ""
                }
            }
            , InitialLayer, InitialLayer + ".R");
            CuiHelper.DestroyUi(player, InitialLayer);
            CuiHelper.AddUi(player, container);
            DrawMenuPoints(player);
        }
        //void CreateExpeditionInfo(BasePlayer player, int page)
        //{
        //    if (UIList.Count > 0)
        //    {
        //        CuiHelper.DestroyUi(player, InitialLayer + ".Expedition");
        //        CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo { connection = player.net.connection }, null, "AddUI", UIList[page]);
        //    }
        //}
        void CreateInfoJson(BasePlayer player, int page) {
            CuiHelper.DestroyUi(player, InitialLayer + ".Expedition");
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Expedition");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.1 0.01", AnchorMax = "0.9 0.5"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Expedition", InitialLayer + ".ItemsList");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".ItemsList", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"СПИСОК ПРЕДМЕТОВ И ОЧКИ ЗА НИХ:", Align = TextAnchor.UpperLeft , FontSize = 15
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 1", AnchorMax = "1 1.1"
                    }
                }
            }
            );
            var pos = GetPositions(10, 5, 0.01f, 0.02f);
            int count = 0;
            var itemsList = config.expeditionSettings.ItemsAdded.OrderBy(p => p.Value.amount).Skip(page * 50).Take(50);
            foreach (var item in itemsList) {
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = pos[count].AnchorMin, AnchorMax = pos[count].AnchorMax
                    }
                    , Image = {
                        Color = "0.77 0.74 0.71 0.05", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
                    }
                }
                , InitialLayer + ".ItemsList", InitialLayer + item.Key);
                container.Add(new CuiElement {
                    Parent = InitialLayer + item.Key, Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", item.Key), Color = "1 1 1 0.6"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0.1 0.05", AnchorMax = "0.9 0.95"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = InitialLayer + item.Key, Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 1", Text = $"{item.Value.amount}", Align = TextAnchor.MiddleCenter , FontSize = 23, Font="robotocondensed-regular.ttf"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = InitialLayer + item.Key, Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 0.5", Text = $"MAX {item.Value.maxCount}", Align = TextAnchor.LowerCenter , FontSize = 12, Font="robotocondensed-regular.ttf"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0.05", AnchorMax = "1 1"
                        }
                    }
                }
                );
                count++;
            }
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Expedition", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Здесь вы можете увидеть список предметов которые вы можете отдать бате, и количество очков которые они дают.Батя может отправить 5 разных посылок , в зависимости от количества набранных очков.\n\n<size=14><b>Виды посылок:</b>\n        Потрепанная посылка (<b>от 0 до 20 очков</b>).\n        Слегка порванная посылка (<b>от 20 до 40 очков</b>).\n        Обычная посылка (<b>от 40 до 60 очков</b>).\n        Отличная посылка (<b>от 60 до 80 очков</b>).\n        Подгон от бати (<b>от 80 до 100 очков</b>).\n\n*<size=12>Максимально количество очков - 100.</size></size>", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 16
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.95"
                    }
                }
            }
            );
            container.Add(new CuiButton {
                Button = {
                    Color = "0 0 0 0" , Command = page > 0 ? $"UI_Batia expedition {page -1}" : ""
                }
                , Text = {
                    Text = "◀", FontSize = 55, Align = TextAnchor.LowerRight, Color = page > 0 ? "0.929 0.882 0.847 0.7" : "0.929 0.882 0.847 0.1"
                }
                , RectTransform = {
                    AnchorMin = $"0 0.2", AnchorMax = $"0.1 0.4"
                }
            }
            , InitialLayer + ".Expedition");
            container.Add(new CuiButton {
                Button = {
                    Color = "0 0 0 0", Command = page < 2 ? $"UI_Batia expedition {page +1}" : ""
                }
                , Text = {
                    Text = "▶", FontSize = 55, Align = TextAnchor.LowerLeft, Color = page < 2 ? "0.929 0.882 0.847 0.7" : "0.929 0.882 0.847 0.1"
                }
                , RectTransform = {
                    AnchorMin = $"0.9 0.2", AnchorMax = $"1 0.4"
                }
            }
            , InitialLayer + ".Expedition");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.5 0.6", AnchorMax = "0.89 0.85"
                }
                , Image = {
                    Color = "0.77 0.74 0.71 0"
                }
            }
            , InitialLayer + ".Expedition", InitialLayer + ".buttonAccept");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".buttonAccept", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Нажми что бы передать бате предметы на обмен".ToUpper(), Align = TextAnchor.UpperCenter , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "0.9 0.95"
                    }
                }
            }
            );
            container.Add(new CuiButton {
                Button = {
                    Color = "0.41 0.47 0.26 1.00" , Command = $"UI_Batia startLoot", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
                }
                , Text = {
                    Text = "НАЧАТЬ", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "0.59 0.69 0.42 0.7"
                }
                , RectTransform = {
                    AnchorMin = $"0.1 0.2", AnchorMax = $"0.9 0.6"
                }
            }
            , InitialLayer + ".buttonAccept");
            CuiHelper.AddUi(player, container);
            //UIList.Add(container.ToJson());
        }
        void CreateInfo(BasePlayer player) {
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Info");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Это батя, и он может облегчить твою жизнь на этом сервере, если ты конечно заслужишь это.", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 16
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.95"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = $"Батя имеет <b>настроение</b>, от которого будет зависеть напрямую количество и качество предметов которые ты можешь получить от него (настроение указанно в верхней части экрана, узнать его настроение можно только тогда когда подойдешь к нему и начнешь диалог)", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.9"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = "<size=18><b>Вкладка 'Подгон от БАТИ'</b></size> \nБатя может забрать твои предметы, позвонить своим браткам и дать что-то лучше, чем ты предложил ему.\nКаждый предмет имеет определенное количество очков равноценное его редкости и сложности получения.(чем предмет легче получить, тем меньше очков он дает).\nМаксимальное внесенное количество предметов: <b>10 единиц</b>\nМаксимальное количество получаемых предметов: <b>от 4 до 6 единиц</b>\nТак что не надейся получить за свое копье какой-нибудь AK47 или LR300.\nКогда Батя закончит с твоей посылкой он пришлет ее тебе.Появиться соответствующее уведомление на экране.\nКоличество и качество предметов зависит напрямую от настроения бати.\nВремя на каждый 'Подгон от Бати' рандомное.\nПопросить следующий подгон нельзя пока активен предыдущий.", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.78"
                    }
                }
            }
            );
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text = "<size=18><b>Вкладка 'Обменник Бати'</b></size> \nБатя с удовольствием заберет твой мусор-бутылки и обменяет его на что-то ценное.\nПредметы и цены в обменнике меняться рандомно раз в некоторое время.\nБутылки выпадают из бочек возле дороги.", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 14
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "1 0.4"
                    }
                }
            }
            );
            CuiHelper.DestroyUi(player, InitialLayer + ".Info");
            CuiHelper.AddUi(player, container);
        }
        void ShowTOPArtefacts(BasePlayer player) {
            CuiElementContainer container = new CuiElementContainer();
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Info");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".Info", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 1", Text =$"Каждый вайп, игроки сервера имеют возможность обменивать артефакты на баланс магазина\n<b>Артефакты:</b> ВОДКА, БАТИНЫ 'ПЕЗДЮЛИ', 'БОРЩ', 'ПОДОРОЖНИК', 'КОМПОТ', 'ПИВАСИК'\n<b>Награда:</b> Первые три игрока получат <b>300 рублей</b> на баланс магазина\nПоторопитесь количество мест ограниченно!\n<size=19><b>Нужно собрать все 6 артефактов третьего уровня.</b></size>", Align = TextAnchor.UpperLeft , Font="robotocondensed-regular.ttf", FontSize = 16
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0.1 0", AnchorMax = "0.9 0.99"
                    }
                }
            }
            );
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.05 0.32", AnchorMax = "1 0.74"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Info", InitialLayer + ".Artefacts.Players");
            var playerPos = GetPositions(3, 1, 0.05f, 0.08f);
            for (int i = 0; i < 3; i++) {
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = playerPos[i].AnchorMin, AnchorMax = playerPos[i].AnchorMax
                    }
                    , Image = {
                        Color = "0.815 0.776 0.741 0.25", Sprite = "assets/content/ui/ui.background.transparent.linear.psd"
                    }
                }
                , InitialLayer + ".Artefacts.Players", InitialLayer + ".Artefacts.Players" + i);
                if (ArtefactsList.Count > i) {
                    var playerID = ArtefactsList[i];
                    container.Add(new CuiElement {
                        Parent = InitialLayer + ".Artefacts.Players" + i, Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary?.Call("GetImage", playerID.ToString())
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                    container.Add(new CuiPanel() {
                        RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                        , Image = {
                            Color = "0.235 0.227 0.180 0.90"
                        }
                    }
                    , InitialLayer + ".Artefacts.Players" + i);
                    container.Add(new CuiElement {
                        Parent = InitialLayer + ".Artefacts.Players" + i, Components = {
                            new CuiTextComponent {
                                Color = "0.929 0.882 0.847 1", Text = permission.GetUserData(playerID.ToString()).LastSeenNickname.ToUpper(), Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 20
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
                else {
                    container.Add(new CuiElement {
                        Parent = InitialLayer + ".Artefacts.Players" + i, Components = {
                            new CuiTextComponent {
                                Color = "0.929 0.882 0.847 1", Text = $"ПУСТО", Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 20
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
            }
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.05 0.1", AnchorMax = "1 0.25"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Info", InitialLayer + ".Artefacts.Invectory");
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0.05 0.12", AnchorMax = "0.75 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0"
                }
            }
            , InitialLayer + ".Artefacts.Invectory", InitialLayer + ".Artefacts.ItemList");
            if (ArtefactsList.Count < config.artefactsSettings.MaxCount && !ArtefactsList.Contains(player.userID)) {
                var invectoryPos = GetPositions(6, 1, 0.05f, 0.08f);
                int count = 0;
                List<ulong> IgnoreList = new List<ulong>();
                for (int i = 0; i < 6; i++) {
                    container.Add(new CuiPanel() {
                        RectTransform = {
                            AnchorMin = invectoryPos[i].AnchorMin, AnchorMax = invectoryPos[i].AnchorMax
                        }
                        , Image = {
                            Color = "0.815 0.776 0.741 0.15"
                        }
                    }
                    , InitialLayer + ".Artefacts.ItemList", InitialLayer + ".Artefacts.ItemList" + i);
                    var item = config.artefactsSettings.ItemsAdded[i];
                    foreach (var invItem in player.inventory.AllItems()) {
                        if (invItem.info.shortname == item.ShortName && invItem.skin == item.SkinID && !IgnoreList.Contains(item.SkinID)) {
                            container.Add(new CuiElement {
                                Parent = InitialLayer + ".Artefacts.ItemList" + count, Components = {
                                    new CuiRawImageComponent {
                                        Png = (string) ImageLibrary?.Call("GetImage", item.ImageURL)
                                    }
                                    , new CuiRectTransformComponent {
                                        AnchorMin = "0.05 0.05", AnchorMax = "0.95 0.95"
                                    }
                                }
                            }
                            );
                            IgnoreList.Add(item.SkinID);
                            count++;
                        }
                    }
                }
                if (count == 6) {
                    container.Add(new CuiButton {
                        Button = {
                            Color = "0.41 0.47 0.26 1.00", Command = $"UI_Batia takeArt", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat"
                        }
                        , Text = {
                            Text = "ОБМЕНЯТЬ", FontSize = 17, Align = TextAnchor.MiddleCenter, Color = "0.59 0.69 0.42 0.7"
                        }
                        , RectTransform = {
                            AnchorMin = "0.78 0.14", AnchorMax = "0.9 0.97"
                        }
                    }
                    , InitialLayer + ".Artefacts.Invectory");
                }
                else {
                    container.Add(new CuiButton {
                        RectTransform = {
                            AnchorMin = "0.78 0.14", AnchorMax = "0.9 0.97"
                        }
                        , Button = {
                            Command = "", Color = "0.815 0.776 0.741 0.15"
                        }
                        , Text = {
                            Text = "ОБМЕНЯТЬ", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-bold.ttf", FontSize = 16, Color = "0.929 0.882 0.847 0.1"
                        }
                    }
                    , InitialLayer + ".Artefacts.Invectory");
                }
            }
            else if (ArtefactsList.Count >= config.artefactsSettings.MaxCount) {
                container.Add(new CuiElement {
                    Parent = InitialLayer + ".Artefacts.Invectory", Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 1", Text = $"ОБМЕН ЗАКОНЧЕН, ЕСТЬ ТРИ ПОБЕДИТЕЛЯ", Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 25
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
            }
            else if (ArtefactsList.Contains(player.userID)) {
                container.Add(new CuiElement {
                    Parent = InitialLayer + ".Artefacts.Invectory", Components = {
                        new CuiTextComponent {
                            Color = "0.929 0.882 0.847 1", Text = $"ВЫ ПОЛУЧИЛИ УЖЕ СВОЙ ПРИЗ В ЭТОМ ВАЙПЕ", Align = TextAnchor.MiddleCenter , Font="robotocondensed-regular.ttf", FontSize = 25
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
            }
            CuiHelper.DestroyUi(player, InitialLayer + ".Info");
            CuiHelper.AddUi(player, container);
        }
        bool TakeItems(BasePlayer player) {
            List<ulong> IgnoreList = new List<ulong>();
            List<Item> currentList = new List<Item>();
            for (int i = 0; i < 6; i++) {
                var item = config.artefactsSettings.ItemsAdded[i];
                foreach (var invItem in player.inventory.AllItems()) {
                    if (invItem.info.shortname == item.ShortName && invItem.skin == item.SkinID && !IgnoreList.Contains(item.SkinID)) {
                        currentList.Add(invItem);
                        IgnoreList.Add(item.SkinID);
                    }
                }
            }
            bool result = false;
            if (currentList.Count == 6) {
                result = true;
                foreach (var item in currentList) item.UseItem(1);
            }
            return result;
        }
        void CreateBottleExchange(BasePlayer player, int page = 0) {
            CuiElementContainer container = new CuiElementContainer();
            int amount = player.inventory.GetAmount(ItemManager.FindItemDefinition(config.bottleSetting.Shortname).itemid);
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0", Material = ""
                }
            }
            , InitialLayer + ".R", InitialLayer + ".Bottle");
            var itemList = config.bottleSetting.CustomItemsShop.Skip(page * 12);
            if (itemList.Count() > 12) {
                container.Add(new CuiButton {
                    Button = {
                        Command = $"UI_Gold page {page+1} ", Color = "0 0 0 0" ,
                    }
                    , Text = {
                        Text = $"▶", FontSize = 60, Align = TextAnchor.MiddleRight, Color = "0.929 0.882 0.847 0.7"
                    }
                    , RectTransform = {
                        AnchorMin = $"0.89 -0.15", AnchorMax = $"0.99 0"
                    }
                }
                , InitialLayer + ".Bottle");
            }
            int i = 0;
            var pos = GetPositions(3, 5, 0.01f, 0.02f, false);
            foreach (var item in itemList.Take(12)) {
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = pos[i].AnchorMin, AnchorMax = pos[i].AnchorMax
                    }
                    , Image = {
                        Color = "0.815 0.776 0.741 0.05", Sprite = "assets/content/ui/ui.background.transparent.radial.psd", Material = ""
                    }
                }
                , InitialLayer + ".Bottle", InitialLayer + $".Shop.{i}");
                container.Add(new CuiPanel() {
                    RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0.36 1", OffsetMin = "5 5", OffsetMax = "-5 -5"
                    }
                    , Image = {
                        Color = "0.815 0.776 0.741 0.3", Sprite = "assets/content/ui/ui.background.transparent.radial.psd"
                    }
                }
                , InitialLayer + $".Shop.{i}");
                var image = !string.IsNullOrEmpty(item.ImageURL) ? item.ImageURL : item.defaultItem.ShortName + 128;
                container.Add(new CuiElement {
                    Parent = InitialLayer + $".Shop.{i}", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary?.Call("GetImage", image)
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0.08", AnchorMax = "0.34 0.92", OffsetMin = "10 5", OffsetMax = "-10 -5"
                        }
                    }
                }
                );
                container.Add(new CuiLabel {
                    RectTransform = {
                        AnchorMin = "0.36 0.7", AnchorMax = "1 1"
                    }
                    , Text = {
                        Text = item.Title, Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 15, Color = "0.929 0.882 0.847 1"
                    }
                }
                , InitialLayer + $".Shop.{i}");
                container.Add(new CuiLabel {
                    RectTransform = {
                        AnchorMin = "0.36 0.3", AnchorMax = "1 0.7"
                    }
                    , Text = {
                        Text = $"КОЛИЧЕСТВО БУТЫЛОК: {item.NeedGold} шт.", Align = TextAnchor.MiddleCenter, Font = "robotocondensed-regular.ttf", FontSize = 12, Color = "0.929 0.882 0.847 0.7"
                    }
                }
                , InitialLayer + $".Shop.{i}");
                var color = amount >= item.NeedGold ? "0.815 0.776 0.741 0.2" : "0.815 0.776 0.741 0.05";
                var Tcolor = amount >= item.NeedGold ? "0.929 0.882 0.847 1" : "0.929 0.882 0.847 0.1";
                container.Add(new CuiButton {
                    Button = {
                        Color = color, Command = $"UI_Batia buy {i}", Material = ""
                    }
                    , Text = {
                        Text = "ОБМЕНЯТЬ", Color = Tcolor, Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter
                    }
                    , RectTransform = {
                        AnchorMin = $"0.35 0.05", AnchorMax = $"0.99 0.25"
                    }
                    ,
                }
                , InitialLayer + $".Shop.{i}");
                i++;
            }
            if (amount == 0) {
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0.33 -0.3", AnchorMax = "0.67 0", OffsetMax = "0 0"
                    }
                    , Button = {
                        Color = "1 1 1 0.03"
                    }
                    , Text = {
                        Text = "У ТЕБЯ ОТСУТСТВУЮТ БУТЫЛКИ", Align = TextAnchor.UpperCenter, Font = "robotocondensed-regular.ttf", FontSize = 18, Color = "0.929 0.882 0.847 1"
                    }
                }
                , InitialLayer + ".Bottle");
            }
            else {
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0.33 -0.3", AnchorMax = "0.67 0", OffsetMax = "0 0"
                    }
                    , Button = {
                        Color = "1 1 1 0.03"
                    }
                    , Text = {
                        Text = $"У ТЕБЯ БУТЫЛОК: {amount} шт.", Align = TextAnchor.UpperCenter, Font = "robotocondensed-regular.ttf", FontSize = 18, Color = "0.929 0.882 0.847 1"
                    }
                }
                , InitialLayer + ".Bottle");
            }
            CuiHelper.DestroyUi(player, InitialLayer + ".Bottle");
            CuiHelper.AddUi(player, container);
        }
        ItemContainer.CanAcceptResult? CanAcceptItem(ItemContainer container, Item item, int pos) {
            var newItem = container.parent as Item;
            if (newItem == null) return null;
            if (newItem.info.shortname == "wrappedgift") return ItemContainer.CanAcceptResult.CannotAccept;
            return null;
        }
        public void DrawMenuPoints(BasePlayer player, MenuPoints choosed = null) {
            if (choosed == null) choosed = config.menuUISettings.PointsList.FirstOrDefault();
            CuiHelper.DestroyUi(player, InitialLayer + ".Bottle");
            CuiHelper.DestroyUi(player, InitialLayer + ".Info");
            CuiHelper.DestroyUi(player, InitialLayer + ".Expedition");
            CuiElementContainer container = new CuiElementContainer();
            float marginTop = -250;
            float originalHeight = 35;
            float freeHeight = 20;
            float padding = 5;
            container.Add(new CuiPanel() {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
                , Image = {
                    Color = "0.24 0.45 0.90 0", Material = ""
                }
            }
            , InitialLayer + ".R", InitialLayer + ".MenuInfo");
            container.Add(new CuiElement {
                Parent = InitialLayer + ".MenuInfo", Components = {
                    new CuiTextComponent {
                        Color = "0.929 0.882 0.847 0.7", Text = choosed.Title.ToUpper(), Align = TextAnchor.LowerCenter , FontSize = 20
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 1", AnchorMax = "1 1.2"
                    }
                }
            }
            );
            foreach (var point in config.menuUISettings.PointsList) {
                CuiHelper.DestroyUi(player, InitialLayer + config.menuUISettings.PointsList.IndexOf(point));
                string color = point == choosed ? "0.929 0.882 0.847 1" : "0.929 0.882 0.847 0.2";
                float elementHeight = point.DisplayName.Length > 0 ? originalHeight : freeHeight;
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"-10 {marginTop - elementHeight}", OffsetMax = $"260 {marginTop}"
                    }
                    , Button = {
                        Command = point == choosed ? "" : $"UI_Batia menu {config.menuUISettings.PointsList.IndexOf(point)}", Color = "0 0 0 0"
                    }
                    , Text = {
                        Text = point.DisplayName, Align = TextAnchor.MiddleRight, Font = "robotocondensed-bold.ttf", FontSize = 26, Color = color
                    }
                }
                , InitialLayer + ".C", InitialLayer + config.menuUISettings.PointsList.IndexOf(point));
                marginTop -= elementHeight + padding;
            }
            CuiHelper.DestroyUi(player, InitialLayer + ".MenuInfo");
            CuiHelper.AddUi(player, container);
            player.SendConsoleCommand(choosed.DrawMethod);
        }
        [ConsoleCommand("UI_Batia")]
        void cmdMenuBatia(ConsoleSystem.Arg args) {
            var player = args.Player();
            if (player == null) return;
            if (!args.HasArgs(1)) return;
            switch (args.Args[0]) {
                case "menu" : int chooseIndex = -1;
                if (!int.TryParse(args.Args[1], out chooseIndex)) return;
                var chooseElement = config.menuUISettings.PointsList.ElementAtOrDefault(chooseIndex);
                if (chooseElement == null) return;
                DrawMenuPoints(player, chooseElement);
                if (!string.IsNullOrEmpty(chooseElement.Sound)) GetSoundToPlayer(player, newPlayer.net.ID, chooseElement.Sound);
                break;
                case "bottle" : CreateBottleExchange(player);
                break;
                case "info" : CreateInfo(player);
                break;
                case "artefacts" : ShowTOPArtefacts(player);
                break;
                case "takeArt" : if (ArtefactsList.Count >= config.artefactsSettings.MaxCount) return;
                if (ArtefactsList.Contains(player.userID)) return;
                if (string.IsNullOrEmpty(config.gameStoresSettings.Secret) || string.IsNullOrEmpty(config.gameStoresSettings.ShopID)) {
                    SendReply(player, $"<color=#EDE1D8>Ошибка пополнения, обратитесь к администратору</color>");
                    return;
                }
                if (TakeItems(player)) {
                    APIChangeUserBalance(player.userID, config.artefactsSettings.Summ, null);
                    SendReply(player, $"<color=#EDE1D8>Вы успешно обменяли ваши АРТЕФАКТЫ на {config.artefactsSettings.Summ} рублей баланса магазина</color>");
                    ArtefactsList.Add(player.userID);
                    player.Command("UI_Batia close");
                }
                else SendReply(player, $"<color=#EDE1D8>У вас не хватает артефактов для обмена, требуется:\n<size=12>ВОДКА 'БАТЯ' 3 ЛВЛ, БАТИНЫ 'ПЕЗДЮЛИ' 3 ЛВЛ, 'БОРЩ' 3ЛВЛ, 'ПОДОРОЖНИК' 3ЛВЛ, 'К.О.М.П.О.Т.' 3ЛВЛ, 'ПИВАСИК' 3ЛВЛ</size></color>");
                break;
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху