コード例 #1
0
        public void RemoveItem(int nID)
        {
            int nPos = 0;
            int nMin = 99;

            KeyValuePair <int, int>[] arItemIDs = ItemIDs.ToArray();
            for (int i = 0; i < ItemIDs.Count(); ++i)
            {
                if (arItemIDs[i].Key != nID)
                {
                    continue;
                }

                if (nMin > arItemIDs[i].Value)
                {
                    nMin = arItemIDs[i].Value;
                    nPos = i;
                }
            }

            int nAmount = GetAmount(nPos) - 1;

            if (nAmount == 0)
            {
                nID = 0;
            }

            SetItemAt(nPos, nID, nAmount);
        }
コード例 #2
0
        public int AddItem(int nID, int nAmount)
        {
            Item item = Item.GetItemByID(nID);

            while (nAmount != 0)
            {
                int pos = ItemIDs.ToList().FindIndex(obj => obj.Key == nID && item.MaxStack > obj.Value);
                if (pos < 0)
                {
                    pos = ItemIDs.ToList().FindIndex(obj => obj.Key == 0);
                }

                if (pos < 0)
                {
                    return(nAmount);
                }

                int nTemp = item.MaxStack - GetAmount(pos);
                if (nAmount > nTemp)
                {
                    SetItemAt(pos, nID, item.MaxStack);
                    nAmount -= nTemp;
                }
                else
                {
                    SetItemAt(pos, nID, GetAmount(pos) + nAmount);
                    nAmount = 0;
                }
            }

            return(0);
        }
コード例 #3
0
    public ItemIcon SetItemID(int itemID)
    {
        this.itemID = itemID;

        var sprites = Resources.LoadAll <Sprite>("Arts/UI2/Item/AllItems");

        this.itemIcon.sprite = sprites[ItemIDs.ItemID2ItemIndex(itemID)];

        return(this);
    }
コード例 #4
0
        public void LoadItems()
        {
            string    dataPath = "assets/Data/ItemInfo.json";
            ItemsData items    = null;

            try
            {
                items = Helper.GetHelper().Data.ReadJsonFile <ItemsData>(dataPath);
                if (items == null)
                {
                    Printer.Error($"The {dataPath} file seems to be missing or invalid.");
                }
            }
            catch (Exception ex)
            {
                Printer.Error($"The {dataPath} file seems to be missing or invalid.\n{ex}");
            }
            ItemIDNames.Clear();
            ItemNames.Clear();
            ItemIDs.Clear();
            ItemDescriptions.Clear();
            var currLang = LocalizedContentManager.CurrentLanguageCode;

            for (int i = 0; i < items.itemsData.Count; i++)
            {
                ItemIDNames.Add(items.itemsData[i].IDName);
                if (currLang != LocalizedContentManager.LanguageCode.en)
                {
                    if (items.itemsData[i].NameLocalization.ContainsKey(currLang.ToString()) &&
                        items.itemsData[i].NameLocalization[currLang.ToString()].Length > 0)
                    {
                        ItemNames.Add(items.itemsData[i].IDName, items.itemsData[i].NameLocalization[currLang.ToString()]);
                    }
                    else
                    {
                        ItemNames.Add(items.itemsData[i].IDName, items.itemsData[i].Name);
                    }
                    if (items.itemsData[i].DescriptionLocalization.ContainsKey(currLang.ToString()) &&
                        items.itemsData[i].DescriptionLocalization[currLang.ToString()].Length > 0)
                    {
                        ItemDescriptions.Add(items.itemsData[i].IDName, items.itemsData[i].DescriptionLocalization[currLang.ToString()]);
                    }
                    else
                    {
                        ItemDescriptions.Add(items.itemsData[i].IDName, items.itemsData[i].Description);
                    }
                }
                else
                {
                    ItemNames.Add(items.itemsData[i].IDName, items.itemsData[i].Name);
                    ItemDescriptions.Add(items.itemsData[i].IDName, items.itemsData[i].Description);
                }
                ItemIDs.Add(items.itemsData[i].IDName, items.itemsData[i].ID);
            }
        }
        public void Validate()
        {
            View.ValidateRequired("View");

            ItemIDs.ValidateOptional("ItemIDs");
            Keys.ValidateOptional("Keys");
            Filters.ValidateOptional <ItemFilter>("Filter");
            ClientIDs.ValidateOptional("ClientIDs");
            MaxResults.ValidateOptional("MaxResults");
            MaxFullItems.ValidateOptional("MaxFullItems");
        }
コード例 #6
0
ファイル: Tester.cs プロジェクト: dynamiquel/Polaris-IO
            public override bool Equals(object obj)
            {
                try
                {
                    var newObj = (TestObject)obj;
                    if (newObj != null && newObj.PlayerName == PlayerName && newObj.ModsEnabled == ModsEnabled &&
                        newObj.Kills == Kills &&
                        !newObj.ItemIDs.Except(ItemIDs).Any() && !ItemIDs.Except(newObj.ItemIDs).Any())
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    return(false);
                }

                return(false);
            }
コード例 #7
0
        public static Tuple <int, int> GetItemIdFromString(string name)
        {
            string[] data = name.Replace("minecraft:", "").Replace(" ", "_").ToUpper().Split(':');
            int      id   = 0;
            int      meta = 0;

            if (data.Length == 1)
            {
                int.TryParse(data[0], out id);
            }

            if (data.Length == 2)
            {
                int.TryParse(data[0], out id);
                int.TryParse(data[1], out meta);
            }

            ItemIDs   ids  = new ItemIDs();
            FieldInfo info = ids.GetType().GetField(data[0]);

            if (info != null)
            {
                id = (int)info.GetValue(ids);
            }
            else
            {
                BlockIDs  ids2  = new BlockIDs();
                FieldInfo info2 = ids2.GetType().GetField(data[0]);
                if (info2 != null)
                {
                    id = (int)info2.GetValue(ids2);
                    if (id > 255)
                    {
                        id = -id + 255;
                    }
                }
            }
            return(new Tuple <int, int>(id, meta));
        }
コード例 #8
0
        public void Init()
        {
            foreach (int key in MineNET_Registries.Block.Keys)
            {
                if (MineNET_Registries.Block.TryGetValue(key, out Block block))
                {
                    this.Set(new ItemBlock(block));
                }
            }

            FieldInfo[] fields = new ItemIDs().GetType().GetFields(); //TODO
            for (int i = 0; i < fields.Length; ++i)
            {
                FieldInfo field = fields[i];
                this.Set(new ItemUnknown((int)field.GetValue(null), field.Name));
            }

            this.Set(new ItemIronShovel());          //256
            this.Set(new ItemIronPickaxe());         //257
            this.Set(new ItemIronAxe());             //258
            this.Set(new ItemFlintAndSteel());       //259
            this.Set(new ItemApple());               //260
            this.Set(new ItemBow());                 //261
            this.Set(new ItemArrow());               //262
            this.Set(new ItemCoal());                //263
            this.Set(new ItemDiamond());             //264
            this.Set(new ItemIronIngot());           //265
            this.Set(new ItemGoldIngot());           //266
            this.Set(new ItemIronSword());           //267
            this.Set(new ItemWoodenSword());         //268
            this.Set(new ItemWoodenShovel());        //269
            this.Set(new ItemWoodenPickaxe());       //270
            this.Set(new ItemWoodenAxe());           //271
            this.Set(new ItemStoneSword());          //272
            this.Set(new ItemStoneShovel());         //273
            this.Set(new ItemStonePickaxe());        //274
            this.Set(new ItemStoneAxe());            //275
            this.Set(new ItemDiamondSword());        //276
            this.Set(new ItemDiamondShovel());       //277
            this.Set(new ItemDiamondPickaxe());      //278
            this.Set(new ItemDiamondAxe());          //279
            this.Set(new ItemStick());               //280
            this.Set(new ItemBowl());                //281
            this.Set(new ItemMushroomStew());        //282
            this.Set(new ItemGoldenSword());         //283
            this.Set(new ItemGoldenShovel());        //284
            this.Set(new ItemGoldenPickaxe());       //285
            this.Set(new ItemGoldenAxe());           //286
            this.Set(new ItemString());              //287
            this.Set(new ItemFeather());             //288
            this.Set(new ItemGunpowder());           //289
            this.Set(new ItemWoodenHoe());           //290
            this.Set(new ItemStoneHoe());            //291
            this.Set(new ItemIronHoe());             //292
            this.Set(new ItemDiamondHoe());          //293
            this.Set(new ItemGoldenHoe());           //294
            this.Set(new ItemWheatSeeds());          //295
            this.Set(new ItemWheat());               //296
            this.Set(new ItemBread());               //297
            this.Set(new ItemLeatherHelmet());       //298
            this.Set(new ItemLeatherChestplate());   //299
            this.Set(new ItemLeatherLeggings());     //300
            this.Set(new ItemLeatherBoots());        //301
            this.Set(new ItemChainmailHelmet());     //302
            this.Set(new ItemChainmailChestplate()); //303
            this.Set(new ItemChainmailLeggings());   //304
            this.Set(new ItemChainmailBoots());      //305
            this.Set(new ItemIronHelmet());          //306
            this.Set(new ItemIronChestplate());      //307
            this.Set(new ItemIronLeggings());        //308
            this.Set(new ItemIronBoots());           //309
            this.Set(new ItemDiamondHelmet());       //310
            this.Set(new ItemDiamondChestplate());   //311
            this.Set(new ItemDiamondLeggings());     //312
            this.Set(new ItemDiamondBoots());        //313
            this.Set(new ItemGoldenHelmet());        //314
            this.Set(new ItemGoldenChestplate());    //315
            this.Set(new ItemGoldenLeggings());      //316
            this.Set(new ItemGoldenBoots());         //317
            this.Set(new ItemFlint());               //318
            this.Set(new ItemPorkchop());            //319
            this.Set(new ItemCookedPorkchop());      //320
            this.Set(new ItemPainting());            //321
            this.Set(new ItemGoldenApple());         //322
            this.Set(new ItemSign());                //323
            this.Set(new ItemWoodenDoor());          //324
            this.Set(new ItemBucket());              //325

            this.Set(new ItemMinecart());            //328
            this.Set(new ItemSaddle());              //329
            this.Set(new ItemIronDoor());            //330
            this.Set(new ItemRedstone());            //331
            this.Set(new ItemSnowball());            //332
            this.Set(new ItemBoat());                //333
            this.Set(new ItemLeather());             //334
            this.Set(new ItemKelp());                //335
            this.Set(new ItemBrick());               //336
            this.Set(new ItemClayBall());            //337
            this.Set(new ItemReeds());               //338
            this.Set(new ItemPaper());               //339
            this.Set(new ItemBook());                //340
            this.Set(new ItemSlimeBall());           //341
            this.Set(new ItemChestMinecart());       //342

            this.Set(new ItemEgg());                 //344
            this.Set(new ItemCompass());             //345
            this.Set(new ItemFishingRod());          //346
            this.Set(new ItemClock());               //347
            this.Set(new ItemGlowstoneDust());       //348
            this.Set(new ItemFish());                //349
            this.Set(new ItemCookedFish());          //350
            this.Set(new ItemDye());                 //351
            this.Set(new ItemBone());                //352
        }
コード例 #9
0
ファイル: GameManager.cs プロジェクト: yesbrad/theconstant
 public bool HasItem(ItemIDs item)
 {
     return(currentItems.Contains(item));
 }
コード例 #10
0
ファイル: GameManager.cs プロジェクト: yesbrad/theconstant
 public void AddItem(ItemIDs item)
 {
     currentItems.Add(item);
 }
コード例 #11
0
 public int CompareTo(Item other)
 {
     return(ItemIDs.CompareTo(other.ItemIDs));
 }