public CustomItemWrapper(CustomItem customItem)
 {
     if (customItem == null)
     {
         throw new ArgumentNullException("customItem");
     }
     _customItem = customItem;
 }
Esempio n. 2
0
        public PlayerVendorCustomizeGump(Mobile v, Mobile from)
            : base(30, 40)
        {
            m_Vendor = v;
            int x, y;

            from.CloseGump(typeof(PlayerVendorCustomizeGump));

            AddPage(0);
            AddBackground(0, 0, 585, 393, 5054);
            AddBackground(195, 36, 387, 275, 3000);
            AddHtmlLocalized(10, 10, 565, 18, 1011356, false, false);   // <center>VENDOR CUSTOMIZATION MENU</center>
            AddHtmlLocalized(60, 355, 150, 18, 1011036, false, false);  // OKAY
            AddButton(25, 355, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(320, 355, 150, 18, 1011012, false, false); // CANCEL
            AddButton(285, 355, 4005, 4007, 0, GumpButtonType.Reply, 0);

            y = 35;
            for (int i = 0; i < Categories.Length; i++)
            {
                CustomCategory cat = Categories[i];
                AddHtmlLocalized(5, y, 150, 25, cat.LocNumber, true, false);
                AddButton(155, y, 4005, 4007, 0, GumpButtonType.Page, i + 1);
                y += 25;
            }

            for (int i = 0; i < Categories.Length; i++)
            {
                CustomCategory cat = Categories[i];
                AddPage(i + 1);

                for (int c = 0; c < cat.Entries.Length; c++)
                {
                    CustomItem entry = cat.Entries[c];
                    x = 198 + (c % 3) * 129;
                    y = 38 + (c / 3) * 67;

                    AddHtmlLocalized(x, y, 100, entry.LongText ? 36 : 18, entry.LocNumber, false, false);

                    if (entry.ArtNumber != 0)
                    {
                        AddItem(x + 20, y + 25, entry.ArtNumber);
                    }

                    AddRadio(x, y + (entry.LongText ? 40 : 20), 210, 211, false, (c << 8) + i);
                }

                if (cat.CanDye)
                {
                    AddHtmlLocalized(327, 239, 100, 18, 1011402, false, false); // Color
                    AddRadio(327, 259, 210, 211, false, 100 + i);
                }

                AddHtmlLocalized(456, 239, 100, 18, 1011403, false, false); // Remove
                AddRadio(456, 259, 210, 211, false, 200 + i);
            }
        }
Esempio n. 3
0
 public void UpdateQuality()
 {
     foreach (var item in Items)
     {
         CustomItem customItem = ItemFactory.CreateCustomItem(item);
         customItem.UpdateSellIn(item);
         customItem.UpdateQuality(item);
     }
 }
Esempio n. 4
0
 private static void AddItem()
 {
     customItem = new CustomItem(AssetHelper.PickaxeBlackmetalPrefab, true);
     UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["PickaxeBlackmetal"]);
     if ((bool)balance["PickaxeBlackmetal"]["enabled"])
     {
         ItemManager.Instance.AddItem(customItem);
     }
 }
Esempio n. 5
0
        /// <inheritdoc/>
        public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            if (!sender.CheckPermission("customitems.list"))
            {
                response = "Permission Denied, required: customitems.list";
                return(false);
            }

            if (arguments.Count < 2)
            {
                response = "spawn [Custom item name] [Location name]\nspawn [Custom item name] [Nickname/PlayerID/UserID]\nspawn [Custom item name] [X] [Y] [Z]";
                return(false);
            }

            if (!CustomItem.TryGet(arguments.At(0), out CustomItem item))
            {
                response = $" {arguments.At(0)} is not a valid custom item.";
                return(false);
            }

            Vector3 position;

            if (Enum.TryParse(arguments.At(1), out SpawnLocation location))
            {
                position = location.GetPosition();
            }
            else if (Player.Get(arguments.At(1)) is Player player)
            {
                if (player.IsDead)
                {
                    response = $"Cannot spawn custom items under dead players!";
                    return(false);
                }

                position = player.Position;
            }
            else if (arguments.Count > 3)
            {
                if (!float.TryParse(arguments.At(1), out float x) || !float.TryParse(arguments.At(2), out float y) || !float.TryParse(arguments.At(3), out float z))
                {
                    response = "Invalid coordinates selected.";
                    return(false);
                }

                position = new Vector3(x, y, z);
            }
            else
            {
                response = $"Unable to find spawn location: {arguments.At(1)}.";
                return(false);
            }

            item.Spawn(position);

            response = $"{item.Name} ({item.Type}) has been spawned at {position}.";
            return(true);
        }
Esempio n. 6
0
        //#region Propertys

        //private TempCustomItem _selectedItem;
        ///// <summary>
        ///// 当前选项
        ///// </summary>
        //public override TempCustomItem SelectedItem
        //{
        //    get { return _selectedItem; }
        //    set
        //    {
        //        this.PriorSelectedItem = _selectedItem;

        //        if (_selectedItem != value)
        //        {


        //            _selectedItem = value;
        //            if (_selectedItem != null)
        //            {
        //               // _selectedItem.Acitve();

        //                if (_selectedItem.View == null)
        //                {
        //                    _selectedItem.View = View.GetItemView(value);
        //                }
        //            }
        //        }

        //        if (AppData.MainMV.ListViewModel != this)
        //        {
        //            AppData.MainMV.ListViewModel = this;
        //        }


        //        AppData.MainMV.ChangeTrayWindowSize();

        //       // App.Current.MainWindow.Activate();

        //        this.OnPropertyChanged();
        //    }
        //}


        //#endregion

        private async void LoadTempCustomServiceHistoryChats()
        {
            await SDKClient.SDKClient.Instance.GetTempCSRoomlist().ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    return;
                }
                var chats = t.Result;
                foreach (var item in chats)
                {
                    CustomItem chat  = new CustomItem();
                    chat.DisplayName = item.userName;
                    chat.HeadImg     = item.photo ?? ImagePathHelper.DefaultUserHead;
                    chat.ID          = item.userId;

                    TempCustomItem chatVM = this.Items.FirstOrDefault(info => info.ID == chat.ID);
                    if (chatVM == null)
                    {
                        var last = new MessageModel()
                        {
                            Sender   = chat,
                            Content  = item.message,
                            SendTime = item.msgTime,
                        };

                        chatVM             = new TempCustomItem(chat, last);
                        chatVM.UnReadCount = item.UnreadCount;

                        Items.Add(chatVM);
                    }
                }
            }, View.UItaskScheduler);

            await Task.Run(() =>
            {
                var userIds = Items.Select(t => t.ID).ToArray();

                return(SDKClient.SDKClient.Instance.Postbaseinfo(userIds.Select(i => i.ToString()).ToArray()));
            }).ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    return;
                }
                foreach (SDKClient.DTO.baseInfoEntity item in t.Result)
                {
                    TempCustomItem chatVM = this.Items.FirstOrDefault(info => info.ID == item.userId);
                    if (chatVM != null)
                    {
                        chatVM.Chat.DisplayName = item.userName;
                        chatVM.Chat.HeadImg     = item.photo ?? ImagePathHelper.DefaultUserHead;
                    }
                }
            }, View.UItaskScheduler);
        }
Esempio n. 7
0
        private static void AddItem()
        {
            customItemFire      = new CustomItem(AssetHelper.BombFirePrefab, true);
            customItemFrost     = new CustomItem(AssetHelper.BombFrostPrefab, true);
            customItemLightning = new CustomItem(AssetHelper.BombLightningPrefab, true);

            ItemManager.Instance.AddItem(customItemFire);
            ItemManager.Instance.AddItem(customItemFrost);
            ItemManager.Instance.AddItem(customItemLightning);
        }
Esempio n. 8
0
        /// <summary>
        ///   Maps the specified source.
        /// </summary>
        /// <typeparam name="TDestination">The type of the destination.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        internal static TDestination Map <TDestination>(CustomItem source, TDestination destination, ResolutionContext context)
        {
            destination = destination == null?context.Mapper.CreateObject <TDestination>() : destination;

            var destTypeDetails = context.ConfigurationProvider.Configuration.CreateTypeDetails(destination.GetType());

            context.Mapper.Map(source.InnerItem, destination, source.InnerItem.GetType(), destTypeDetails.Type);

            return(destination);
        }
        public void UpdateQualityShouldDegradeOutOfDateItemTwiceAsFast(string name, int sellIn, int quality)
        {
            var ItemWrapper = new CustomItem {
                Name = name, SellIn = sellIn, Quality = quality
            };

            ItemWrapper.UpdateItem();

            Assert.That(ItemWrapper.Quality == quality - 2);
        }
Esempio n. 10
0
        private static void AddItem()
        {
            customItem = new CustomItem(AssetHelper.AtgeirSilverPrefab, true);
            UtilityFunctions.ModifyWeaponDamage(ref customItem, balance["AtgeirSilver"]);

            if ((bool)balance["AtgeirSilver"]["enabled"])
            {
                ItemManager.Instance.AddItem(customItem);
            }
        }
Esempio n. 11
0
        public void CheckSaAltAllele()
        {
            var customItem = new CustomItem("chr1", 100, "ATATA", "TTT", "test", "cust101", true, null, null);

            var spc = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(100));

            customItem.SetSupplementaryAnnotations(spc);

            Assert.Equal("5TTT", spc.SaPosition.CustomItems[0].SaAltAllele);
        }
Esempio n. 12
0
        public void SetChoiceText_Test()
        {
            var itm = new CustomItem();

            itm.SetChoice(i => i.CustomChoice, "The Choice Number Two");
            Assert.That(itm.CustomChoice, Is.EqualTo(TheChoice.Choice2));

            itm.SetChoice(i => i.CustomChoice, "Choice3");
            Assert.That(itm.CustomChoice, Is.EqualTo(TheChoice.Choice3));
        }
Esempio n. 13
0
        public void ItemQualityShouldBeLessThan50AndNotBeNegative(string name, int sellIn, int quality)
        {
            var ItemWrapper = new CustomItem {
                Name = name, SellIn = sellIn, Quality = quality
            };

            ItemWrapper.UpdateItem();

            Assert.That(ItemWrapper.Quality < 50);
            Assert.That(ItemWrapper.Quality >= 0);
        }
Esempio n. 14
0
        public void UpdateQualityShouldReduceSellInValueAndQuality(string name, int sellIn, int quality)
        {
            var ItemWrapper = new CustomItem {
                Name = name, SellIn = sellIn, Quality = quality
            };

            ItemWrapper.UpdateItem();

            Assert.That(ItemWrapper.SellIn == sellIn - 1);
            Assert.That(ItemWrapper.Quality == quality - 1);
        }
Esempio n. 15
0
        public void GetFieldName_Test()
        {
            var itm = new CustomItem();

            var fieldName = itm.GetFieldName(ci => ci.Тыдыщ);

            Assert.That(fieldName, Is.EqualTo("_x0422__x044b__x0434__x044b__x04"));

            fieldName = Item.GetFieldName <CustomItem>(c => c.Тыдыщ);
            Assert.That(fieldName, Is.EqualTo("_x0422__x044b__x0434__x044b__x04"));
        }
Esempio n. 16
0
    private static void AddCustomItems()
    {
      //Create a clone of existing game asset helmet troll leather for our Surtling Helm
      var mock = Mock<ItemDrop>.Create("HelmetTrollLeather");
      var cloned = Prefab.GetRealPrefabFromMock<ItemDrop>(mock).gameObject.InstantiateClone($"{LanguageData.TokenValue}", true);
      cloned.name = LanguageData.TokenValue;

      //Set the new data on the ItemDrop component of our new helm
      var newItemPrefab = cloned;
      var helm = new CustomItem(cloned, fixReference: true);
      var item = helm.ItemDrop;
      item.m_itemData.m_dropPrefab = newItemPrefab;
      item.m_itemData.m_shared.m_name = LanguageData.TokenName;
      item.m_itemData.m_shared.m_description = LanguageData.TokenDescriptionName;
      item.m_itemData.m_shared.m_icons = new Sprite[] { AssetHelper.Icon };
      item.m_itemData.m_shared.m_setName = string.Empty;
      item.m_itemData.m_shared.m_setSize = 0;
      item.m_itemData.m_shared.m_setStatusEffect = null;
      item.m_itemData.m_shared.m_equipStatusEffect = Prefab.Cache.GetPrefab<SE_SurtlingEquippedEffect>(LanguageData.EffectValue);
      item.m_itemData.m_shared.m_backstabBonus = 1;

      //Tweak the material to make the helmet purple
      var meshRenderer = newItemPrefab.transform.GetComponentInChildren<MeshRenderer>();
      var colorTarget = new Color(255f / 255f, 0f, 194f / 255f, 255f / 255f);
      meshRenderer.material.color = colorTarget;
      var skinnedRenderer = newItemPrefab.transform.Find("attach_skin/hood").GetComponent<SkinnedMeshRenderer>();
      skinnedRenderer.material.color = colorTarget;

      //Add to the object db, along with our new network-synced prefabs
      ObjectDBHelper.Add(helm);
      Prefab.NetworkRegister(AssetHelper.EyeGlowPrefab);
      Prefab.NetworkRegister(AssetHelper.EyeBeamPrefab);
      Prefab.NetworkRegister(AssetHelper.EyeHitPrefab);

      //Create a recipe to craft the helm
      var recipe = ScriptableObject.CreateInstance<Recipe>();
      recipe.name = "Recipe_SurtlingHelm";
      recipe.m_item = helm.ItemDrop;
      recipe.m_enabled = true;
      recipe.m_minStationLevel = Math.Max(Math.Min(SH.WorkbenchLevelRequired.Value, 5), 0);
      recipe.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
      var req = new List<Piece.Requirement>();

      //Add required items list to recipe
      if (SH.SurtlingRequired.Value > 0) req.Add(MR.Create("SurtlingCore", SH.SurtlingRequired.Value));
      if (SH.TrollHideRequired.Value > 0) req.Add(MR.Create("TrollHide", SH.TrollHideRequired.Value));
      if (SH.LinenThreadRequired.Value > 0) req.Add(MR.Create("LinenThread", SH.LinenThreadRequired.Value));
      if (SH.SurtlingTrophyRequired.Value > 0) req.Add(MR.Create("TrophySurtling", SH.SurtlingTrophyRequired.Value));
      if (req.Count == 0) req.Add(MR.Create("Wood", 1));
      recipe.m_resources = req.ToArray();

      var helmRecipe = new CustomRecipe(recipe, true, true);
      ObjectDBHelper.Add(helmRecipe);
    }
Esempio n. 17
0
    public Sundial()
    {
        {
            LanguageAPI.Add("SUNDIAL_ITEM_TOKEN", "Rechargable Quantum Core");
            LanguageAPI.Add("SUNDIAL_ITEM_DESCRIPTION_TOKEN", "Chance to become elite upon interaction. +5% chance per stack.");
            LanguageAPI.Add("SUNDIAL_ITEM_PICKUP_TOKEN", "Chance to become elite upon interaction.");

            ItemTag[] tags = new ItemTag[2]
            {
                ItemTag.Utility,
                ItemTag.AIBlacklist
            };

            var itemDef = new ItemDef
            {
                pickupModelPath  = "Prefabs/PickupModels/PickupMystery",
                pickupIconPath   = "Textures/MiscIcons/texMysteryIcon",
                pickupToken      = "SUNDIAL_ITEM_PICKUP_TOKEN",
                nameToken        = "SUNDIAL_ITEM_TOKEN",
                name             = "WeirdSundial",
                descriptionToken = "SUNDIAL_ITEM_DESCRIPTION_TOKEN",
                tier             = ItemTier.Tier2,
                tags             = tags
            };

            BuffDef solarBuffDef = new BuffDef
            {
                buffColor  = new Color(235, 182, 92),
                buffIndex  = BuffIndex.Count,
                canStack   = false,
                eliteIndex = EliteIndex.None,
                iconPath   = "Textures/BuffIcons/texbuffpulverizeicon",
                isDebuff   = false,
                name       = "SolarGain"
            };
            solarBuff = BuffAPI.Add(new CustomBuff(solarBuffDef));
            //solarBuff = ItemAPI.Add(new CustomBuff(solarbuff.name, solarbuff));

            var prefab = Resources.Load <GameObject>("Prefabs/PickupModels/PickupMystery");

            var rule = new ItemDisplayRule
            {
                ruleType       = ItemDisplayRuleType.ParentedPrefab,
                followerPrefab = prefab,
                childName      = "Chest",
                localScale     = new Vector3(0f, 0, 0f),
                localAngles    = new Vector3(0f, 0f, 0f),
                localPos       = new Vector3(0, 0f, 0f)
            };

            var item = new CustomItem(itemDef, new[] { rule });
            itemIndex = ItemAPI.Add(item);
        };
    }
Esempio n. 18
0
        public void EqualityAndHash()
        {
            var customItem = new CustomItem("chr1", 100, "A", "C", "test", "cust101", true, null, null);

            var customHash = new HashSet <CustomItem> {
                customItem
            };

            Assert.Equal(1, customHash.Count);
            Assert.True(customHash.Contains(customItem));
        }
Esempio n. 19
0
        public static void Init()
        {
            LanguageAPI.Add("GENETIC_EMPTY_TOKEN", "This is better than null I guess");
            tokenDict = new Dictionary <GeneStat, Dictionary <GeneMod, ItemDef> >();

            //GeneToken Items
            foreach (GeneStat stat in Enum.GetValues(typeof(GeneStat)))
            {
                tokenDict.Add(stat, new Dictionary <GeneMod, ItemDef>());
                foreach (GeneMod mod in Enum.GetValues(typeof(GeneMod)))
                {
                    ItemDef def = ScriptableObject.CreateInstance <ItemDef>();

                    def.name              = "GENETOKEN_" + stat.ToString().ToUpper() + "_" + mod.ToString().ToUpper();
                    def.nameToken         = "GENETIC_EMPTY_TOKEN";
                    def.pickupToken       = "GENETIC_EMPTY_TOKEN";
                    def.descriptionToken  = "GENETIC_EMPTY_TOKEN";
                    def.loreToken         = "GENETIC_EMPTY_TOKEN";
                    def.pickupIconSprite  = null;
                    def.pickupModelPrefab = null;
                    def.tags              = new ItemTag[] { ItemTag.CannotCopy, ItemTag.CannotSteal };
                    def.tier              = ItemTier.NoTier;
                    def.hidden            = true;
                    def.canRemove         = false;

                    CustomItem item = new CustomItem(def, new ItemDisplayRuleDict());
                    ItemAPI.Add(item);
                    //ContentAddition.AddItemDef(def);

                    tokenDict[stat].Add(mod, def);
                }
            }

            //GeneBlocker Item
            blockerDef = ScriptableObject.CreateInstance <ItemDef>();

            blockerDef.name              = "GENETOKEN_BLOCKER";
            blockerDef.nameToken         = "GENETIC_EMPTY_TOKEN";
            blockerDef.pickupToken       = "GENETIC_EMPTY_TOKEN";
            blockerDef.descriptionToken  = "GENETIC_EMPTY_TOKEN";
            blockerDef.loreToken         = "GENETIC_EMPTY_TOKEN";
            blockerDef.pickupIconSprite  = null;
            blockerDef.pickupModelPrefab = null;
            blockerDef.tags              = new ItemTag[] { ItemTag.CannotCopy, ItemTag.CannotSteal };
            blockerDef.tier              = ItemTier.NoTier;
            blockerDef.hidden            = true;
            blockerDef.canRemove         = false;

            CustomItem blockerItem = new CustomItem(blockerDef, new ItemDisplayRuleDict());

            ItemAPI.Add(blockerItem);
            //ContentAddition.AddItemDef(blockerDef);
        }
Esempio n. 20
0
 void ShowEditPage(object sender, RoutedEventArgs e)
 {
     if (table.SelectedItem != null)
     {
         CustomItem item = (CustomItem)table.SelectedItem;
         _window.Content = new ItemEditAddPage(item.SellerId, item.BuyerId, item.AuctionId, item.Id, _window);
     }
     else
     {
         MessageBox.Show("Строка не выбрана");
     }
 }
Esempio n. 21
0
        private static bool Prefix(FragGrenade __instance, Pickup item)
        {
            if (!CustomItem.TryGet(item, out CustomItem customItem) || !(customItem is CustomGrenade customGrenade))
            {
                return(true);
            }

            item.Delete();
            customGrenade.Spawn(item.position, Vector3.zero, customGrenade.FuseTime, customGrenade.Type);

            return(false);
        }
Esempio n. 22
0
        /// <inheritdoc/>
        public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            if (!sender.CheckPermission("customitems.give"))
            {
                response = "Permission Denied, required: customitems.give";
                return(false);
            }

            if (arguments.Count < 2)
            {
                response = "give [Custom item name/Custom item ID] [Nickname/PlayerID/UserID/all/*]";
                return(false);
            }

            if (!CustomItem.TryGet(arguments.At(0), out CustomItem item))
            {
                response = $"Custom item {arguments.At(0)} not found!";
                return(false);
            }

            string identifier = string.Join(" ", arguments.Skip(1));

            switch (identifier)
            {
            case "*":
            case "all":
                var eligiblePlayers = Player.List.Where(CheckEligible).ToList();
                foreach (var ply in eligiblePlayers)
                {
                    item.Give(ply);
                }

                response = $"Custom item {item.Name} given to all players who can receive them ({eligiblePlayers.Count} players)";
                return(true);

            default:
                if (!(Player.Get(identifier) is Player player))
                {
                    response = $"Unable to find player: {identifier}.";
                    return(false);
                }

                if (!CheckEligible(player))
                {
                    response = "Player cannot receive custom items!";
                    return(false);
                }

                item.Give(player);
                response = $"{item.Name} given to {player.Nickname} ({player.UserId})";
                return(true);
            }
        }
    private void AddItem()
    {
        CustomItem currentItem = new CustomItem();

        currentItem.name = $"Item";

        currentItem.itemIconDirectory = "";
        currentItem.uid = Guid.NewGuid().ToString();
        items.Add(currentItem);

        SaveData();
    }
        public void StoreEmbeddedPart_EmbedsPartDetails()
        {
            var item = new CustomItem();
            var part = new DataItem();

            part["Hello"] = "World";
            item.StoreEmbeddedPart("Hello", part);

            var loadedPart = item.LoadEmbeddedPart <DataItem>("Hello");

            loadedPart["Hello"].ShouldBe("World");
        }
Esempio n. 25
0
 private void JupmToChat(object para)
 {
     if (this.Model is CustomItem user && user.ID > 0)
     {
         CustomItem item = this.Model as CustomItem;
         AppData.MainMV.JumpToChatModel(item);
         System.Threading.ThreadPool.QueueUserWorkItem(o =>
         {
             SDKClient.SDKClient.Instance.SendCSSyncMsgStatus(item.ID, item.HeadImg, item.DisplayName);
         });
     }
 }
        public void Objects_CanBeStored()
        {
            var item = new CustomItem();

            item.StoreEmbeddedObject("Object", new EmbeddableComponent {
                Hello = "World"
            });

            var stored = item.LoadEmbeddedObject <EmbeddableComponent>("Object");

            stored.Hello.ShouldBe("World");
        }
        public void StoreEmbeddedPart_EmbedsPartProperties()
        {
            var item = new CustomItem();

            item.StoreEmbeddedPart("Hello", new DataItem {
                Title = "Hello World"
            });

            var part = item.LoadEmbeddedPart <DataItem>("Hello");

            part.Title.ShouldBe("Hello World");
        }
Esempio n. 28
0
        private static void registerPrefabs()
        {
            foreach (string foodName in affectedFood)
            {
                // we skip default value(0)
                for (int index = 1; index < qualityPrefixes.Length; index++)
                {
                    // check for base prefab existance
                    ItemDrop basePrefab = Prefab.Cache.GetPrefab <ItemDrop>(foodName);
                    if (basePrefab == null)
                    {
                        Log.LogInfo($"No prefab registered for meal: {foodName}");
                        continue;
                    }

                    string qualityPrefix = qualityPrefixes[index];

                    // skipping default quality mostly, cuz those items are already exists,
                    // but modyfing to match the rest
                    string qualifiedPrefabName = foodName + "_" + qualityPrefix;
                    Log.LogInfo($"trying to make clone named: {qualifiedPrefabName}");

                    // create new quality items
                    GameObject clonedBasePrefabObject = basePrefab.gameObject.InstantiateClone(qualifiedPrefabName);
                    CustomItem newMealItem            = new CustomItem(clonedBasePrefabObject, fixReference: true);

                    newMealItem.ItemDrop.m_itemData.m_shared.m_name = $"${qualifiedPrefabName}";
                    Log.LogInfo($"newMealItem named: {newMealItem.ItemDrop.m_itemData.m_shared.m_name}");

                    // setting quality representation for food
                    newMealItem.ItemDrop.m_itemData.m_quality             = index;
                    newMealItem.ItemDrop.m_itemData.m_shared.m_maxQuality = qualityPrefixes.Length;

                    // increase/decrease stats
                    float baseFoodHealth = newMealItem.ItemDrop.m_itemData.m_shared.m_food;
                    newMealItem.ItemDrop.m_itemData.m_shared.m_food =
                        (int)Math.Round(baseFoodHealth * ((100f + (index * JustAnotherCookingSkill.foodIncreasePerQuality.Value) - 20) / 100f));

                    float baseFoodStamina = newMealItem.ItemDrop.m_itemData.m_shared.m_foodStamina;
                    newMealItem.ItemDrop.m_itemData.m_shared.m_foodStamina =
                        (int)Math.Round(baseFoodStamina * ((100f + (index * JustAnotherCookingSkill.foodIncreasePerQuality.Value) - 20) / 100f));

                    // increase regen for better quality items
                    if (index > 2)
                    {
                        newMealItem.ItemDrop.m_itemData.m_shared.m_foodRegen += index - 2;
                    }

                    ObjectDBHelper.Add(newMealItem);
                }
            }
        }
        internal void Patch(ItemTypes itemType)
        {
            string name = this.GetType().Assembly.GetName().Name;

            Logger.Log(Logger.Level.Info, $"Received Custom {itemType} pack from '{name}'");

            // Check for required data
            string errors = string.Empty;

            if (this.EnergyCapacity <= 0)
            {
                errors += "Missing required data 'EnergyCapacity" + Environment.NewLine;
            }

            if (string.IsNullOrEmpty(this.ID))
            {
                errors += "Missing required data 'ID'" + Environment.NewLine;
            }

            if (string.IsNullOrEmpty(this.Name))
            {
                errors += "Missing required data 'Name'" + Environment.NewLine;
            }

            if (string.IsNullOrEmpty(this.FlavorText))
            {
                errors += "Missing required data 'FlavorText'";
            }

            if (!string.IsNullOrEmpty(errors))
            {
                string msg = "Unable to patch:" + Environment.NewLine + errors;
                Logger.Log(Logger.Level.Error, msg);
                throw new InvalidOperationException(msg);
            }

            // Prepare
            var item = new CustomItem(this, itemType)
            {
                PluginPackName    = name,
                FriendlyName      = this.Name,
                Description       = this.FlavorText,
                PowerCapacity     = this.EnergyCapacity,
                RequiredForUnlock = this.UnlocksWith,
                Parts             = this.CraftingMaterials
            };

            // Patch
            item.Patch();

            _techType = item.TechType;
        }
Esempio n. 30
0
        private void OnPlayeJoinEvent(Object o, PlayerEventArgs e)
        {
            try
            {
                Player          player   = e.Player;
                JObject         datas    = player.GetPlayerDatas();
                ItemGather      inv      = datas["Inventory"].ToObject <ItemGather>();
                ItemGather      arm      = datas["Clothes"].ToObject <ItemGather>();
                PlayerInventory slot     = player.Inventory;
                LevelManager    l        = player.Level.LevelManager;
                Level           lastSeen = l.Levels.First(lv => lv.LevelName.ToLower() == datas["LastSeen"].ToString().ToLower());

                player.SpawnLevel(lastSeen, datas["Location"].ToObject <PlayerLocation>());
                player.GameMode             = datas["GameMode"].ToObject <GameMode>();
                player.Effects              = datas["Effect"].ToObject <ConcurrentDictionary <EffectType, Effect> >();
                player.HealthManager.Health = datas["Health"].ToObject <Int32>();
                player.HungerManager.Hunger = datas["Hunger"].ToObject <Int32>();
                player.ExperienceLevel      = datas["LV"].ToObject <Int32>();
                player.Experience           = datas["XP"].ToObject <Int32>();

                for (Int32 i = 0; i < inv.Count(); i++)
                {
                    slot.SetInventorySlot(i, inv[i]);
                }

                for (Int32 i = 0; i < arm.Count(); i++)
                {
                    CustomItem armor = arm[i];

                    if (i == 0)
                    {
                        slot.Helmet = armor;
                    }
                    if (i == 1)
                    {
                        slot.Chest = armor;
                    }
                    if (i == 2)
                    {
                        slot.Leggings = armor;
                    }
                    if (i == 3)
                    {
                        slot.Boots = armor;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message + ex.InnerException + "\r" + ex.StackTrace);
            }
        }
Esempio n. 31
0
        public void GetChoiceText_Test()
        {
            var itm = new CustomItem();

            itm.CustomChoice = TheChoice.Choice2;
            var fieldName = itm.GetChoice(i => i.CustomChoice);

            Assert.That(fieldName, Is.EqualTo("The Choice Number Two"));

            itm.CustomChoice = TheChoice.Choice3;
            fieldName        = itm.GetChoice(i => i.CustomChoice);
            Assert.That(fieldName, Is.EqualTo("Choice3"));
        }
        public static void DrawItem(SpriteBatch spriteBatch, CustomItem item)
        {
            var map = GnomanEmpire.Instance.Map;
            var mapCell = (item.Parent == null) ? item.Cell() : item.Parent.Cell();
            var lightLevel = mapCell.LightLevel;
            //map.TerrainProperties[this.MaterialID].ConvertColor(lightLevel);
            Color color = GameEntity.Darken(Color.White, lightLevel);
            Vector2 pos = GnomanEmpire.Instance.Camera.MapIndexToScreenCoords(item.Position);
            GameEntityManager entityManager = GnomanEmpire.Instance.EntityManager;

            foreach (var drawableComponent in item.Drawables)
            {
                int num = item.History.MaterialAtIndex(drawableComponent.MaterialIndex);
                drawableComponent.Entity.Draw(spriteBatch, pos, (drawableComponent.MaterialIndex == -1) ? color : map.TerrainProperties[num].ConvertColor(lightLevel));
            }
        }
			public CustomCategory( Layer layer, int loc, bool canDye, CustomItem[] items )
			{
				m_Entries = items;
				m_CanDye = canDye;
				m_Layer = layer;
				m_LocNum = loc;
			}
Esempio n. 34
0
 public ICustomItem BuildItem(CustomItem customItem)
 {
     return new CustomItemWrapper(customItem);
 }
	public void itemClicked(Button thisButton)
	{

		//If buy screen is active, don't entertain clicks on background
		if(currentScreen != "choose")
			return;

		//By default the item is unlcocked
		bool isThisItemLocked = false;

		//Checks if a lock exists - that means the item is locked
		if(thisButton.gameObject.transform.FindChild("lockicon").GetComponent<Image>().enabled == true)
		{
			isThisItemLocked = true;
		}

		Image sprrenderer = null;
		List<CustomItem> lst = null;

		//Checks which menu is selected
		//The appropriate scene object is selected in sprrenderer image variable
		if(selectedMenu.Contains("Masks"))
		{
			lst = Masks;
			sprrenderer = objMasks; 
		}
		else if(selectedMenu.Contains("LeftHand"))
		{
			lst = LeftHands;
			sprrenderer = objLeftHands;
		}
		else if(selectedMenu.Contains("RightHand"))
		{
			lst= RightHands;
			sprrenderer = objRightHands;

		}
		else if(selectedMenu.Contains("RightShoe"))
		{
			lst= RightShoes;
			sprrenderer = objRShoes;
			
		}
		else if(selectedMenu.Contains("LeftShoe"))
		{
			lst= LeftShoes;
			sprrenderer = objLShoes;
			
		}

		else if(selectedMenu.Contains("Shirt"))
		{
			lst= Shirts;
			sprrenderer = objShirts;

		}

		else if(selectedMenu.Contains("Curtain"))
		{
			lst= Curtains;
			sprrenderer = objCurtain;
			
		}

		else if(selectedMenu.Contains("Pant"))
		{
			lst= Pants;
			sprrenderer = objPants;
			
		}

		//Assigns the select sprite to the scene object
		int id = int.Parse(thisButton.name);
		sprrenderer.sprite = lst[id].spr;

		////Gives coins to the user for clicking
		//Debug.Log (lst[id].spr);

        if (currentItem != lst[id])
        {
            //			if(lst[id].spr==GameObject.FindWithTag()){
            //
            //
            //			}if(lst[id].spr==GameObject.FindWithTag()){
            //				
            //				
            //			}


            //Debug.Log(shirtslist[0]);
            if (lst[id].spr == shirtslist[0])
            {
                addCoins(3);
                shirtscore = 3;
                Debug.Log("whiteshirt");
            }
            if (lst[id].spr == shirtslist[1])
            {
                addCoins(4);
                shirtscore = 4;
                Debug.Log("redshirt");

            } if (lst[id].spr == shirtslist[2])
            {
                addCoins(5);
                shirtscore = 5;
                Debug.Log("blueshirt");
            }
            if (lst[id].spr == pentslist[0])
            {
                addCoins(3);
                pentscore = 3;
                Debug.Log("whitepent");
            } if (lst[id].spr == pentslist[1])
            {
                addCoins(4);
                pentscore = 4;
                Debug.Log("orangepent");
            } if (lst[id].spr == pentslist[2])
            {
                addCoins(5);
                pentscore = 5;
                Debug.Log("redpent");
            }


          
                Debug.Log("enter into");

                btnfinish.gameObject.SetActive(true);



            //addCoins (Random.Range (1, 3));
        }
       

  //      Debug.Log(lst[id]);
      //  DontDestroyOnLoad()
        total = shirtscore + pentscore;
       // Debug.Log(total);
	//	Debug.Log (shirtscore+pentscore);
        PlayerPrefs.SetInt("score", total);

		
		//Current item is updated
		currentItem = lst[id];
		//Debug.Log (currentItem.price);

		//Is the item locked? then show the buy screen
		if(isThisItemLocked)
		{
			//If the user does not have adequate coins, ask him to buy using inapp in buy all screen
			if(PlayerPrefs.GetInt("coins") < currentItem.price )
			{
				buyScreenAll.SetActive(true);
				return;
			}

			//The user has enough coins, show him the buy one screen and update the label
			buyScreenOne.SetActive(true);
			lblMessageBuyOne.text = "YOU NEED " + currentItem.price + " COINS TO BUY THIS ITEM";

			//Now the current screen is buy - not choose. So items/menus wont work
			currentScreen = "buy";
		}
		else
		{
			buyScreenOne.SetActive(false);
			currentScreen = "choose";
			lastItemClicked = thisButton;
		}


	}
Esempio n. 36
0
        void MainFormLoad(object sender, EventArgs e)
        {
            Image intImg = Image.FromFile("diamond.png");
            Image tImg = Image.FromFile("table.png");
            const int k = 5;
            Random r = new Random(255);
            try {
                for (int i = 0; i < k; i++) {
                    Structure di = new Structure(diagramContainer1, "ITEM" + i.ToString());
                    di.TitleImage = tImg;
                    Node cols = new Node("Columns", di);
                    cols.AddNode(new Node("id", true, intImg, di));
                    cols.AddNode(new Node("type", true, intImg, di));
                    cols.AddNode(new Node("name", di));
                    cols.AddNode(new Node("surname", di)).AddNode(new Node("child1", di)).AddNode(new Node("child2", di));
                    cols.AddNode(new Node("key", di));
                    cols.AddNode(new Node("anotherKey", di));
                    cols.AddNode(new Node("valid", di)).AddNode(new Node("child3", di)).AddNode(new Node("child4", di));
                    di.AddNode(cols);
                    di.AddOnDiagram(diagramContainer1, Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)));
                    di.Drawing.Location = new Point(r.Next(300), r.Next(300));
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            for (int i = 0; i < k; i++) {

                Color c = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255));
                int x = r.Next(k);
                int y = r.Next(k);
                if (x != y) {
                    diagramContainer1.AddLink(diagramContainer1.DiagramItems[x], diagramContainer1.DiagramItems[y]);
                }
            }
            diagramContainer1.Invalidate();

            CustomItem customItem = new CustomItem();
            customItem.Color = Color.Red;
            customItem.Name = "CustomItem";

            CustomDrawing customDrawing = new CustomDrawing(customItem);
            customDrawing.Movable = true;
            customDrawing.Size = new Size(100, 100);
            customItem.Drawing = customDrawing;

            Structure stru = (diagramContainer1.DiagramItems[0] as Structure);
            diagramContainer1.AddLink(stru.Nodes[0].Nodes[3], customItem);

            diagramContainer1.AddItem(customItem, customDrawing, true, true);
            diagramContainer1.AddLink(customItem, diagramContainer1.DiagramItems[0]);

            CircleDrawing customDrawing2 = new CircleDrawing(130, 130);
            customDrawing2.Movable = true;
            customDrawing2.Size = new Size(100, 100);
            diagramContainer1.AddDrawing(customDrawing2, true);

            diagramContainer1.AddLinkDrawing(customDrawing2, customDrawing);
            diagramContainer1.Invalidate();

            diagramContainer1.DrawableHeight = 705;
            diagramContainer1.DrawableWidth = 758;
        }
Esempio n. 37
0
			public CustomCategory(Layer layer, int loc, bool canDye, CustomItem[] items)
			{
				Entries = items;
				CanDye = canDye;
				Layer = layer;
				LocNumber = loc;
			}
Esempio n. 38
0
 static XeedMod()
 {
     MainMod.LoadConfig();
     items = new List<CustomItem>();
     if (File.Exists(ItemFile))
     {
         CustomItem ci = null;
         foreach (string line in File.ReadAllLines(ItemFile))
             if (line.StartsWith("[") && line.EndsWith("]"))
             {
                 if (ci != null) items.Add(ci);
                 ci = new CustomItem(line.Remove(line.Length - 1, 1).Remove(0, 1));
             }
             else
             {
                 string[] data = line.Split(new char[] { '=' }, 2);
                 if (data[0].Equals("baseId")) ci.iId = int.Parse(data[1]);
                 else if (data[0].Equals("name")) ci.name = data[1];
                 else if (data[0].Equals("scope-effect")) ci.scope = bool.Parse(data[1]);
                 else if (data[0].Equals("texture-name") && !String.IsNullOrWhiteSpace(data[1]))
                     ci.ctex = ImageToByte2(System.Drawing.Image.FromFile(MainMod.Config.PluginDataDirectory + @"\Textures\" + data[1]));
                 else if (!data[0].StartsWith("#")) ci.AddField(data[0].Split(':'), data[1]);
             }
         if (ci != null) items.Add(ci);
     }
 }