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

FREE Mercenaries : 1.0 1.0

Нет прав для скачивания
C#:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Facepunch.Extend;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
namespace Oxide.Plugins {
    [Info("Mercenaries", "https://discord.gg/9vyTXsJyKR", "1.0")]
    public class Mercenaries : RustPlugin {
#region var
        [PluginReference]
        private Plugin ImageLibrary, Economics, BMenu, Inventory, BroadcastSystem;
        Dictionary<ulong, Timer> playerTimes = new Dictionary<ulong, Timer>();
        Dictionary<string, string> rarityColors = new Dictionary<string, string> {
            ["null"]
            = "#00000000", ["default"] = "#636365D9", ["rare"] = "#3e3eabD9", ["epic"] = "#673eabD9", ["legendary"] = "#dfb22fD9"
        }
        ;
        RewardItem voidItem = new RewardItem {
            DisplayName = "", Shortname = "void", IsCommand = true, Blueprint = false, Amount = 0, Category = "", Image = "void", Rarity = "null"
        }
        ;
        RewardItem fakeItem = new RewardItem {
            DisplayName = "", Shortname = "void", IsCommand = true, Blueprint = false, Amount = 0, Category = "", Image = "inv", Rarity = "null"
        }
        ;
#endregion
#region config
        class RewardItem {
            public string Shortname;
            public bool Blueprint;
            public bool IsCommand;
            public int Amount;
            public string Rarity;
            public ulong SkinId = 0;
            public string Image = "";
            public string Category = "Ресурс";
            public string DisplayName;
        }
        class Mercenary {
            public string Key;
            public string DisplayName;
            public string url;
            public double Time;
            public double Cooldown = 10;
            public double Cost;
            public double Buy = 1000;
            public List<RewardItem> RewardItems;
        }
        static Configuration config = new Configuration();
        class Configuration {
            [JsonProperty("Наемники")]
            public List<Mercenary> Mercenaries;
            [JsonProperty("Настройка редкости")]
            public Dictionary<string, double> Rarity;
            public static Configuration GetNewConfiguration() {
                return new Configuration {
                    Mercenaries = new List<Mercenary> {
                        new Mercenary {
                            Key = "lvl1", DisplayName = "John One", Cost = 100, Time = 30, Buy = 300, url = "https://gspics.org/images/2022/01/14/0QCxDD.jpg", RewardItems = new List<RewardItem> {
                                new RewardItem {
                                    Shortname = "sulfur", Blueprint = false, IsCommand = false, Amount = 10, Rarity = "default", DisplayName = "Сера"
                                }
                                , new RewardItem {
                                    Shortname = "rifle.ak", Blueprint = true, IsCommand = false, Amount = 1, Rarity = "rare", DisplayName = "Сера"
                                }
                                , new RewardItem {
                                    Shortname = "kick userid", Blueprint = false, IsCommand = true, Amount = 1, Rarity = "legendary", Image = "https://i.ibb.co/GdwsKkL/BP-For-Test.png", DisplayName = "Кик",
                                }
                                ,
                            }
                        }
                        , new Mercenary {
                            Key = "lvl2", DisplayName = "Test Two", Cost = 100, Time = 30, Buy = 400, url = "https://gspics.org/images/2021/12/25/0HQr2n.jpg", RewardItems = new List<RewardItem> {
                                new RewardItem {
                                    Shortname = "sulfur", Blueprint = false, IsCommand = false, Amount = 10, Rarity = "rare", DisplayName = "Сера"
                                }
                                , new RewardItem {
                                    Shortname = "rifle.ak", Blueprint = true, IsCommand = false, Amount = 1, Rarity = "epic", DisplayName = "Рецепт АК"
                                }
                                , new RewardItem {
                                    Shortname = "kick userid", Blueprint = false, IsCommand = true, Amount = 1, Rarity = "legendary", Image = "https://i.ibb.co/GdwsKkL/BP-For-Test.png", DisplayName = "Кик"
                                }
                                ,
                            }
                        }
                        , new Mercenary {
                            Key = "lvl3", DisplayName = "Nigga free", Cost = 500, Buy = 500, Time = 30, url = "https://gspics.org/images/2021/12/25/0HQBuu.jpg", RewardItems = new List<RewardItem> {
                                new RewardItem {
                                    Shortname = "sulfur", Blueprint = false, IsCommand = false, Amount = 10, Rarity = "rare", DisplayName = "Сера"
                                }
                                , new RewardItem {
                                    Shortname = "rifle.ak", Blueprint = true, IsCommand = false, Amount = 1, Rarity = "epic", DisplayName = "Рецепт АК"
                                }
                                , new RewardItem {
                                    Shortname = "kick userid", Blueprint = false, IsCommand = true, Amount = 1, Rarity = "legendary", Image = "https://i.ibb.co/GdwsKkL/BP-For-Test.png", DisplayName = "Кик"
                                }
                                ,
                            }
                        }
                        , new Mercenary {
                            Key = "free", DisplayName = "Негр", Cost = 500, Time = 30, Buy = 0, url = "https://gspics.org/images/2021/12/25/0HQViK.jpg", RewardItems = new List<RewardItem> {
                                new RewardItem {
                                    Shortname = "sulfur", Blueprint = false, IsCommand = false, Amount = 10, Rarity = "rare", DisplayName = "Сера"
                                }
                                , new RewardItem {
                                    Shortname = "rifle.ak", Blueprint = true, IsCommand = false, Amount = 1, Rarity = "epic", DisplayName = "Рецепт АК"
                                }
                                , new RewardItem {
                                    Shortname = "kick userid", Blueprint = false, IsCommand = true, Amount = 1, Rarity = "legendary", Image = "https://i.ibb.co/GdwsKkL/BP-For-Test.png", DisplayName = "Кик"
                                }
                                ,
                            }
                        }
                        ,
                    }
                    , Rarity = new Dictionary<string, double> {
                        ["null"]
                        = 20, ["default"] = 40, ["rare"] = 30, ["epic"] = 15, ["legendary"] = 5
                    }
                }
                ;
            }
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                config = Config.ReadObject<Configuration>();
                if (config == null) PrintWarning("NULL");
                if (config == null) LoadDefaultConfig();
            }
            catch {
                PrintError($"Не удалось найти конфигурацию 'oxide/config/{Name}', Создание конфига!!");
                LoadDefaultConfig();
            }
            NextTick(SaveConfig);
        }
        protected override void LoadDefaultConfig() => config = Configuration.GetNewConfiguration();
        protected override void SaveConfig() => Config.WriteObject(config);
#endregion
#region UI
        private string _layer = "MercUI";
        void MercUI(BasePlayer player) {
            CuiHelper.DestroyUi(player, _layer);
            if ((string)BMenu.Call("GetPage", player.userID) != "merc") return;
            var container = new CuiElementContainer();
            container.Add(new CuiPanel {
                Image = {
                    Color = "0 0 0 0"
                }
                , RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
            }
            , "SubContent_UI", _layer);
            double height = 100;
            double maxy = 600;
            foreach (var mercenary in config.Mercenaries) {
                container.Add(new CuiPanel {
                    Image = {
                        Color = "0 0 0 0"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"0 {maxy-height}", OffsetMax = $"920 {maxy}"
                    }
                }
                , _layer, _layer + $".Merc.{mercenary.Key}");
                container.Add(new CuiPanel {
                    Image = {
                        Color = "0.24 0.24 0.24 1"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"0 40", OffsetMax = $"920 125"
                    }
                }
                , _layer, _layer+".Info");
                container.Add(new CuiElement {
                    Name = _layer + ".Info" + ".Outline", Parent = _layer + ".Info", Components = {
                        new CuiOutlineComponent {
                            Color = "0.69 0.84 0.95 1", Distance = "2 2", UseGraphicAlpha = true
                        }
                        , new CuiImageComponent {
                            Color = "0 0 0 0.5"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Name = _layer + ".Info" + ".Outline", Parent = _layer + ".Info", Components = {
                        new CuiImageComponent {
                            Color = "0.11 0.17 0.27 1"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                container.Add(new CuiLabel {
                    Text = {
                        Font = "robotocondensed-regular.ttf", Text = "<color=#DDDEE0>ИНФОРМАЦИЯ:\n• Каждая структура специализируется на определенных вещах, имеет разную стоимость и время производства!\n• Постройки производят предметы, технологии или чертежи прямиком в ваше хранилище! При конце производства вы получите текстовое и звуковое уведомление.</color>\n", FontSize = 16
                    }
                    , RectTransform = {
                        AnchorMin = "0.03 0.0", AnchorMax = "0.9 0.97", OffsetMin = "0 0", OffsetMax = "0 0"
                    }
                }
                , _layer + ".Info", _layer + ".Info" + ".Text");
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}" + ".BG", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", "mercbg")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}" + ".Img", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", mercenary.Key)
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 0", OffsetMax = "100 100"
                        }
                    }
                }
                );
                container.Add(new CuiLabel {
                    Text = {
                        FontSize = 12, Font = "robotocondensed-regular.ttf", Text = $"", Align = TextAnchor.MiddleLeft, Color = "0.929 0.882 0.847 0.7"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "105 80", OffsetMax = "300 105"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".CostBuy");
                container.Add(new CuiLabel {
                    Text = {
                        FontSize = 12, Font = "robotocondensed-regular.ttf", Text = $"Цена производства: <b><color=#EBD4AE>{mercenary.Cost}</color> <color=#EDE1D8>RP</color></b>", Align = TextAnchor.MiddleLeft, Color = "0.929 0.882 0.847 0.7"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "105 62", OffsetMax = "300 87"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".CostBuy");
                container.Add(new CuiLabel {
                    Text = {
                        FontSize = 12, Font = "robotocondensed-regular.ttf", Text = $"Время производства: <b><color=#EDE1D8>{mercenary.Time} сек</color></b>", Align = TextAnchor.MiddleLeft, Color = "0.929 0.882 0.847 0.7"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "105 39", OffsetMax = "300 87"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".CostBuy");
                container.Add(new CuiLabel {
                    Text = {
                        FontSize = 12, Font = "robotocondensed-regular.ttf", Text = $"", Align = TextAnchor.MiddleLeft, Color = "0.929 0.882 0.847 0.7"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "105 39", OffsetMax = "300 72"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".CostBuy");
                container.Add(new CuiButton {
                    Button = {
                        Color = HexToCuiColor("#34405e"), Close = _layer, Command = $"mercreward {mercenary.Key}", Material = "assets/icons/greyout.mat"
                    }
                    , Text = {
                        Align = TextAnchor.MiddleCenter, Font = "robotocondensed-bold.ttf", FontSize = 12, Text = "ПРЕДМЕТЫ"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "105 5", OffsetMax = "250 45"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".Btn");
                container.Add(new CuiLabel {
                    Text = {
                        FontSize = 20, Font = "robotocondensed-bold.ttf", Text = $"<color=#EDE1D8>ИНВЕНТАРЬ</color>", Align = TextAnchor.MiddleLeft
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "415 65", OffsetMax = "610 95"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".InvLabel");
#region inv1
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage1", Components = {
                        new CuiImageComponent {
                            Color = HexToCuiColor("#33322d")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "360 10", OffsetMax = "410 60"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage1", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Item", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", "ibg")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[0] == null) {
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage1", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Item", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "inv")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
                else {
                    if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[0].Blueprint) {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage1", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", "bp")
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    if (!_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[0].IsCommand) {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage1", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", _database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[0].Shortname)
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    else {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage1", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", _database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[0].Image)
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    container.Add(new CuiPanel {
                        Image = {
                            Color = HexToCuiColor(rarityColors[_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[0].Rarity])
                        }
                        , RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 0", OffsetMax = $"0 10"
                        }
                    }
                    , _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Item", _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Item" + ".Rare");
                }
#endregion
#region inv2
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage2", Components = {
                        new CuiImageComponent {
                            Color = HexToCuiColor("#636365")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "415 10", OffsetMax = "465 60"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage2", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Item", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", "ibg")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[1] == null) {
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage2", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Item", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "inv")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
                else {
                    if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[1].Blueprint) {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage2", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", "bp")
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    if (!_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[1].IsCommand) {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage2", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", _database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[1].Shortname)
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    else {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage2", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", _database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[1].Image)
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    container.Add(new CuiPanel {
                        Image = {
                            Color = HexToCuiColor(rarityColors[_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[1].Rarity])
                        }
                        , RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 0", OffsetMax = $"0 10"
                        }
                    }
                    , _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Item", _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Item" + ".Rare");
                }
#endregion
#region inv3
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage3", Components = {
                        new CuiImageComponent {
                            Color = HexToCuiColor("#33322d")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "470 10", OffsetMax = "520 60"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage3", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Item", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", "ibg")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[2] == null) {
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage3", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Item", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "inv")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
                else {
                    if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[2].Blueprint) {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage3", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", "bp")
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    if (!_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[2].IsCommand) {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage3", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", _database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[2].Shortname)
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    else {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage3", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", _database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[2].Image)
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    container.Add(new CuiPanel {
                        Image = {
                            Color = HexToCuiColor(rarityColors[_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[2].Rarity])
                        }
                        , RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 0", OffsetMax = $"0 10"
                        }
                    }
                    , _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Item", _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Item" + ".Rare");
                }
#endregion
#region inv4
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage4", Components = {
                        new CuiImageComponent {
                            Color = HexToCuiColor("#33322d")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "525 10", OffsetMax = "575 60"
                        }
                    }
                }
                );
                container.Add(new CuiElement {
                    Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage4", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage4"+".Item", Components = {
                        new CuiRawImageComponent {
                            Png = (string) ImageLibrary.Call("GetImage", "ibg")
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[3] == null) {
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage4", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage4"+".Item", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "inv")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
                else {
                    if (_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[3].Blueprint) {
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage4", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage4"+".Item", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", "bp")
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage4", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage4"+".Item", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", _database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[3].Shortname)
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                    container.Add(new CuiPanel {
                        Image = {
                            Color = HexToCuiColor(rarityColors[_database[player.userID].Find(p=> p.Key == mercenary.Key).Inventory[3].Rarity])
                        }
                        , RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 0", OffsetMax = $"0 10"
                        }
                    }
                    , _layer + $".Merc.{mercenary.Key}"+"InvImage4"+".Item", _layer + $".Merc.{mercenary.Key}"+"InvImage4"+".Item" + ".Rare");
                }
#endregion
#region MercActive
                if (!_database[player.userID].Find(p => p.Key == mercenary.Key).Available) {
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}" + ".Img", Name = _layer + $".Merc.{mercenary.Key}" + ".Img"+".Lock", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "lock")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 0", OffsetMax = "100 100"
                            }
                        }
                    }
                    );
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage4", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage4"+".Lock", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "lock")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0"
                            }
                        }
                    }
                    );
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage3", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage3"+".Lock", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "lock")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0"
                            }
                        }
                    }
                    );
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage2", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage2"+".Lock", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "lock")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0"
                            }
                        }
                    }
                    );
                    container.Add(new CuiElement {
                        Parent = _layer + $".Merc.{mercenary.Key}"+"InvImage1", Name = _layer + $".Merc.{mercenary.Key}"+"InvImage1"+".Lock", Components = {
                            new CuiRawImageComponent {
                                Png = (string) ImageLibrary.Call("GetImage", "lock")
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "0 0", OffsetMax = "0 0"
                            }
                        }
                    }
                    );
                    container.Add(new CuiButton {
                        Button = {
                            Command = $"mercbuy {mercenary.Key}", Color = CanAccept(mercenary.Buy, player.UserIDString)?HexToCuiColor("#c27e17") : HexToCuiColor("#a1a1a1"), Material = "assets/icons/greyout.mat"
                        }
                        , Text = {
                            Align = TextAnchor.MiddleCenter, FontSize = 18, Text = CanAccept(mercenary.Buy, player.UserIDString)?"АКТИВИРОВАТЬ" : "НЕДОСТУПНО"
                        }
                        , RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "785 15", OffsetMax = "915 85"
                        }
                    }
                    , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".Btn");
                }
                else {
                    if (_database[player.userID].Find(p => p.Key == mercenary.Key).Active) {
                        container.Add(new CuiPanel {
                            Image = {
                                Color = HexToCuiColor("#763f34"), Material = "assets/icons/greyout.mat"
                            }
                            , RectTransform = {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "600 20", OffsetMax = "750 40"
                            }
                        }
                        , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}"+".BarPanel");
                        container.Add(new CuiPanel {
                            Image = {
                                Color = HexToCuiColor("#2B6992"), Material = "assets/icons/greyout.mat"
                            }
                            , RectTransform = {
                                AnchorMin = "0 0", AnchorMax = $"{1-GetTime(_database[player.userID].Find(m => m.Key == mercenary.Key).Cooldown-CurTime()).TotalSeconds/mercenary.Time} 0", OffsetMin = "0 0", OffsetMax = "0 20"
                            }
                        }
                        , _layer + $".Merc.{mercenary.Key}"+".BarPanel", _layer + $".Merc.{mercenary.Key}"+".BarPanel"+".Progress");
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}"+".BarImage", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", "run")
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "600 45", OffsetMax = "640 85"
                                }
                            }
                        }
                        );
                        container.Add(new CuiLabel {
                            Text = {
                                Align = TextAnchor.MiddleCenter, Text = $"{FormatTime(GetTime(_database[player.userID].Find(m => m.Key == mercenary.Key).Cooldown-CurTime()))}", FontSize = 16
                            }
                            , RectTransform = {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "645 45", OffsetMax = "720 85"
                            }
                        }
                        , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + $".Time");
                        container.Add(new CuiButton {
                            Button = {
                                Command = $"", Color = HexToCuiColor("#763f34"), Material = "assets/icons/greyout.mat"
                            }
                            , Text = {
                                Align = TextAnchor.MiddleCenter, FontSize = 20, Text = "На вылазке"
                            }
                            , RectTransform = {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "785 15", OffsetMax = "915 85"
                            }
                        }
                        , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".Btn");
                    }
                    else {
                        container.Add(new CuiLabel {
                            Text = {
                                Align = TextAnchor.MiddleCenter, Text =(CurTime()>_database[player.userID].Find(m => m.Key == mercenary.Key).Cooldown)? "Готов" : $"{FormatTime(GetTime(_database[player.userID].Find(m => m.Key == mercenary.Key).Cooldown-CurTime()))}", FontSize = 16
                            }
                            , RectTransform = {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "645 45", OffsetMax = "720 85"
                            }
                        }
                        , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + $".Time");
                        container.Add(new CuiElement {
                            Parent = _layer + $".Merc.{mercenary.Key}", Name = _layer + $".Merc.{mercenary.Key}"+".BarImage", Components = {
                                new CuiRawImageComponent {
                                    Png = (string) ImageLibrary.Call("GetImage", "zzz")
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "600 45", OffsetMax = "640 85"
                                }
                            }
                        }
                        );
                        container.Add(new CuiButton {
                            Button = {
                                Color = (CanAccept(mercenary.Cost, player.UserIDString)&&_database[player.userID].Find(m => m.Key == mercenary.Key).Cooldown<=CurTime())?HexToCuiColor("#2B6992") : HexToCuiColor("#a1a1a1"), Command = $"mercstart {mercenary.Key}", Material = "assets/icons/greyout.mat"
                            }
                            , Text = {
                                Align = TextAnchor.MiddleCenter, FontSize = 18, Text = "НАЧАТЬ ПРОИЗВОДСТВО"
                            }
                            , RectTransform = {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "785 15", OffsetMax = "915 85"
                            }
                        }
                        , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".Btn");
                    }
                }
                container.Add(new CuiPanel {
                    Image = {
                        Color = "0 0 0 0.98"
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 0", OffsetMax = "100 20"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}" + ".Img", _layer + $".Merc.{mercenary.Key}" + ".Img" + ".Name");
                container.Add(new CuiLabel {
                    Text = {
                        FontSize = 12, Text = mercenary.DisplayName, Align = TextAnchor.MiddleCenter
                    }
                    , RectTransform = {
                        AnchorMin = "0 0", AnchorMax = "1 1"
                    }
                }
                , _layer + $".Merc.{mercenary.Key}" + ".Img" + ".Name", _layer + $".Merc.{mercenary.Key}" + ".Img" + ".Name" + ".Text");
                if (HasItems(player, mercenary)) {
                    container.Add(new CuiButton {
                        Button = {
                            Color = HexToCuiColor("#34405e"), Command = $"takereward {mercenary.Key}", Material = "assets/icons/greyout.mat"
                        }
                        , Text = {
                            Align = TextAnchor.MiddleCenter, Text = "ЗАБРАТЬ", FontSize = 12
                        }
                        , RectTransform = {
                            AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "255 5", OffsetMax = "325 45"
                        }
                    }
                    , _layer + $".Merc.{mercenary.Key}", _layer + $".Merc.{mercenary.Key}" + ".Take");
                }
                maxy -= height + 15;
#endregion
            }
            CuiHelper.AddUi(player, container);
        }
        void RewardUI(BasePlayer player, string merc, int page = 0) {
            Mercenary mercenary = config.Mercenaries.Find(p => p.Key == merc);
            if (merc == null) return;
            if ((string)BMenu.Call("GetPage", player.userID) != "merc") {
                PrintError("Notmerc");
                return;
            }
            CuiHelper.DestroyUi(player, _layer);
            var container = new CuiElementContainer();
            container.Add(new CuiPanel {
                Image = {
                    Color = "0 0 0 0"
                }
                , RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1"
                }
            }
            , "SubContent
// ... [Code preview truncated due to length. Full source in attached file] ...

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