当前位置: 首页>>代码示例>>C#>>正文


C# Item.Prefix方法代码示例

本文整理汇总了C#中System.Item.Prefix方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Prefix方法的具体用法?C# Item.Prefix怎么用?C# Item.Prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Item的用法示例。


在下文中一共展示了Item.Prefix方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupStartInventory

		public static IList<Item> SetupStartInventory(Player player)
		{
			IList<Item> items = new List<Item>();
			Item item = new Item();
			item.SetDefaults("Copper Shortsword");
			item.Prefix(-1);
			items.Add(item);
			item = new Item();
			item.SetDefaults("Copper Pickaxe");
			item.Prefix(-1);
			items.Add(item);
			item = new Item();
			item.SetDefaults("Copper Axe");
			item.Prefix(-1);
			items.Add(item);
			foreach (ModPlayer modPlayer in player.modPlayers)
			{
				modPlayer.SetupStartInventory(items);
			}
			IDictionary<int, int> counts = new Dictionary<int, int>();
			foreach (Item item0 in items)
			{
				if (item0.maxStack > 1)
				{
					if (!counts.ContainsKey(item0.netID))
					{
						counts[item0.netID] = 0;
					}
					counts[item0.netID] += item0.stack;
				}
			}
			int k = 0;
			while (k < items.Count)
			{
				bool flag = true;
				int id = items[k].netID;
				if (counts.ContainsKey(id))
				{
					items[k].stack = counts[id];
					if (items[k].stack > items[k].maxStack)
					{
						items[k].stack = items[k].maxStack;
					}
					counts[id] -= items[k].stack;
					if (items[k].stack <= 0)
					{
						items.RemoveAt(k);
						flag = false;
					}
				}
				if (flag)
				{
					k++;
				}
			}
			return items;
		}
开发者ID:JavidPack,项目名称:TerraCustom,代码行数:57,代码来源:PlayerHooks.cs

示例2: Load

        public static void Load(Item item, TagCompound tag)
        {
            if (tag.Count == 0)
            {
                item.netDefaults(0);
                return;
            }

            string modName = tag.GetString("mod");
            if (modName == "Terraria")
            {
                item.netDefaults(tag.GetInt("id"));
                if (tag.HasTag("legacyData"))
                    LoadLegacyModData(item, tag.GetByteArray("legacyData"), tag.GetBool("hasGlobalSaving"));
            }
            else
            {
                int type = ModLoader.GetMod(modName)?.ItemType(tag.GetString("name")) ?? 0;
                if (type > 0)
                {
                    item.netDefaults(type);
                    if (tag.HasTag("legacyData"))
                        LoadLegacyModData(item, tag.GetByteArray("legacyData"), tag.GetBool("hasGlobalSaving"));
                    else
                        item.modItem.Load(tag.GetCompound("data"));
                }
                else
                {
                    item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem"));
                    ((MysteryItem)item.modItem).Setup(tag);
                }
            }

            item.Prefix(tag.GetByte("prefix"));
            item.stack = tag.GetTag<int?>("stack") ?? 1;
            item.favorited = tag.GetBool("fav");

            if (!(item.modItem is MysteryItem))
                LoadGlobals(item, tag.GetList<TagCompound>("globalData"));
        }
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:40,代码来源:ItemIO.cs

示例3: ReadItem

		public static void ReadItem(Item item, BinaryReader reader, bool readStack = false, bool readFavorite = false)
		{
			string modName = reader.ReadString();
			bool hasGlobalSaving = false;
			if (modName.Length == 0)
			{
				hasGlobalSaving = true;
				modName = reader.ReadString();
			}
			if (modName == "Terraria")
			{
				item.netDefaults(reader.ReadInt32());
				ReadCustomData(item, GetCustomData(item.type, reader, hasGlobalSaving), hasGlobalSaving);
			}
			else
			{
				string itemName = reader.ReadString();
				int type = ModLoader.GetMod(modName)?.ItemType(itemName) ?? 0;
				byte[] data = GetCustomData(type == 0 ? Int32.MaxValue : type, reader, hasGlobalSaving);
				if (type != 0)
				{
					item.netDefaults(type);
					ReadCustomData(item, data, hasGlobalSaving);
				}
				else
				{
					item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem"));
					((MysteryItem)item.modItem).Setup(modName, itemName, data, hasGlobalSaving);
				}
			}
			
			item.Prefix(reader.ReadByte());

			if (readStack)
				item.stack = reader.ReadInt32();

			if (readFavorite)
				item.favorited = reader.ReadBoolean();
		}
开发者ID:JavidPack,项目名称:TerraCustom,代码行数:39,代码来源:ItemIO.cs

示例4: LoadChests

 private static void LoadChests(BinaryReader reader)
 {
     int num = (int)reader.ReadInt16();
     int num2 = (int)reader.ReadInt16();
     int num3;
     int num4;
     if (num2 < 40)
     {
         num3 = num2;
         num4 = 0;
     }
     else
     {
         num3 = 40;
         num4 = num2 - 40;
     }
     int i;
     for (i = 0; i < num; i++)
     {
         Chest chest = new Chest(false);
         chest.x = reader.ReadInt32();
         chest.y = reader.ReadInt32();
         chest.name = reader.ReadString();
         for (int j = 0; j < num3; j++)
         {
             short num5 = reader.ReadInt16();
             Item item = new Item();
             if (num5 > 0)
             {
                 item.netDefaults(reader.ReadInt32());
                 item.stack = (int)num5;
                 item.Prefix((int)reader.ReadByte());
             }
             else if (num5 < 0)
             {
                 item.netDefaults(reader.ReadInt32());
                 item.Prefix((int)reader.ReadByte());
                 item.stack = 1;
             }
             chest.item[j] = item;
         }
         for (int j = 0; j < num4; j++)
         {
             short num5 = reader.ReadInt16();
             if (num5 > 0)
             {
                 reader.ReadInt32();
                 reader.ReadByte();
             }
         }
         Main.chest[i] = chest;
     }
     List<Point16> list = new List<Point16>();
     for (int k = 0; k < i; k++)
     {
         if (Main.chest[k] != null)
         {
             Point16 item2 = new Point16(Main.chest[k].x, Main.chest[k].y);
             if (list.Contains(item2))
             {
                 Main.chest[k] = null;
             }
             else
             {
                 list.Add(item2);
             }
         }
     }
     while (i < 1000)
     {
         Main.chest[i] = null;
         i++;
     }
     if (WorldFile.versionNumber < 115)
     {
         WorldFile.FixDresserChests();
     }
 }
开发者ID:MEFBAEA,项目名称:mefbaea,代码行数:78,代码来源:WorldFile.cs

示例5: PickItemMovementAction

 public static int PickItemMovementAction(Item[] inv, int context, int slot, Item checkItem)
 {
     Player player = Main.player[Main.myPlayer];
     int result = -1;
     if (context == 0)
     {
         result = 0;
     }
     else if (context == 1)
     {
         if (checkItem.type == 0 || checkItem.type == 71 || checkItem.type == 72 || checkItem.type == 73 || checkItem.type == 74)
         {
             result = 0;
         }
     }
     else if (context == 2)
     {
         if (((checkItem.type == 0 || checkItem.ammo > 0 || checkItem.bait > 0) && !checkItem.notAmmo) || checkItem.type == 530)
         {
             result = 0;
         }
     }
     else if (context == 3)
     {
         result = 0;
     }
     else if (context == 4)
     {
         result = 0;
     }
     else if (context == 5)
     {
         if (checkItem.Prefix(-3) || checkItem.type == 0)
         {
             result = 0;
         }
     }
     else if (context == 6)
     {
         result = 0;
     }
     else if (context == 7)
     {
         if (checkItem.material || checkItem.type == 0)
         {
             result = 0;
         }
     }
     else if (context == 8)
     {
         if (checkItem.type == 0 || (checkItem.headSlot > -1 && slot == 0) || (checkItem.bodySlot > -1 && slot == 1) || (checkItem.legSlot > -1 && slot == 2))
         {
             result = 1;
         }
     }
     else if (context == 9)
     {
         if (checkItem.type == 0 || (checkItem.headSlot > -1 && slot == 10) || (checkItem.bodySlot > -1 && slot == 11) || (checkItem.legSlot > -1 && slot == 12))
         {
             result = 1;
         }
     }
     else if (context == 10)
     {
         if (checkItem.type == 0 || (checkItem.accessory && !ItemSlot.AccCheck(checkItem, slot)))
         {
             result = 1;
         }
     }
     else if (context == 11)
     {
         if (checkItem.type == 0 || (checkItem.accessory && !ItemSlot.AccCheck(checkItem, slot)))
         {
             result = 1;
         }
     }
     else if (context == 12)
     {
         result = 2;
     }
     else if (context == 15)
     {
         if (checkItem.type == 0 && inv[slot].type > 0)
         {
             if (player.BuyItem(inv[slot].value))
             {
                 result = 3;
             }
         }
         else if (inv[slot].type == 0 && checkItem.type > 0 && (checkItem.type < 71 || checkItem.type > 74))
         {
             result = 4;
         }
     }
     else if (context == 16)
     {
         if (checkItem.type == 0 || Main.projHook[checkItem.shoot])
         {
             result = 1;
         }
//.........这里部分代码省略.........
开发者ID:MEFBAEA,项目名称:mefbaea,代码行数:101,代码来源:ItemSlot.cs

示例6: ToItem

        public Item ToItem()
        {
            Item item = new Item();
              item.netDefaults((int)this.Type);
              item.Prefix((int)this.Prefix);
              item.stack = this.StackSize;

              return item;
        }
开发者ID:Tygra,项目名称:PluginCommonLibrary,代码行数:9,代码来源:ItemData.cs

示例7: ToItem

        public Item ToItem()
        {
            Item item = new Item();
              if (this.StackSize > 0) {
            item.netDefaults((int)this.Type);
            item.Prefix((int)this.Prefix);
            item.stack = this.StackSize;
              } else {
            item.netDefaults(0);
              }

              return item;
        }
开发者ID:CoderCow,项目名称:PluginCommonLibrary,代码行数:13,代码来源:ItemData.cs

示例8: LoadLegacy

        public static void LoadLegacy(Item item, BinaryReader reader, bool readStack = false, bool readFavorite = false)
        {
            string modName = reader.ReadString();
            bool hasGlobalSaving = false;
            if (modName.Length == 0)
            {
                hasGlobalSaving = true;
                modName = reader.ReadString();
            }
            if (modName == "Terraria")
            {
                item.netDefaults(reader.ReadInt32());
                LoadLegacyModData(item, LegacyModData(item.type, reader, hasGlobalSaving), hasGlobalSaving);
            }
            else
            {
                string itemName = reader.ReadString();
                int type = ModLoader.GetMod(modName)?.ItemType(itemName) ?? 0;
                byte[] data = LegacyModData(type == 0 ? int.MaxValue : type, reader, hasGlobalSaving);
                if (type != 0)
                {
                    item.netDefaults(type);
                    LoadLegacyModData(item, data, hasGlobalSaving);
                }
                else
                {
                    item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem"));
                    var tag = new TagCompound {
                        ["mod"] = modName,
                        ["name"] = itemName,
                        ["hasGlobalSaving"] = hasGlobalSaving,
                        ["legacyData"] = data
                    };
                    ((MysteryItem)item.modItem).Setup(tag);
                }
            }

            item.Prefix(reader.ReadByte());

            if (readStack)
                item.stack = reader.ReadInt32();

            if (readFavorite)
                item.favorited = reader.ReadBoolean();
        }
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:45,代码来源:ItemIO.cs

示例9: Receive

 public static void Receive(Item item, BinaryReader reader, bool readStack = false, bool readFavorite = false)
 {
     item.netDefaults(reader.ReadInt16());
     item.Prefix(reader.ReadByte());
     if (readStack) item.stack = reader.ReadInt16();
     if (readFavorite) item.favorited = reader.ReadBoolean();
     ReceiveModData(item, reader);
 }
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:8,代码来源:ItemIO.cs

示例10: Item

		TextSnippet ITagHandler.Parse(string text, Color baseColor, string options)
		{
			Item item = new Item();
			int type;
			if (int.TryParse(text, out type))
			{
				item.netDefaults(type);
			}
			else
			{
				item.SetDefaults(text);
			}
			if (item.type <= 0)
			{
				return new TextSnippet(text);
			}
			item.stack = 1;
			if (options != null)
			{
				string[] array = options.Split(new char[]
				{
					','
				});
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].Length != 0)
					{
						char c = array[i][0];
						int value2;
						if (c != 'p')
						{
							int value;
							if ((c == 's' || c == 'x') && int.TryParse(array[i].Substring(1), out value))
							{
								item.stack = Utils.Clamp<int>(value, 1, item.maxStack);
							}
						}
						else if (int.TryParse(array[i].Substring(1), out value2))
						{
							item.Prefix((int)((byte)Utils.Clamp<int>(value2, 0, 84)));
						}
					}
				}
			}
			string str = "";
			if (item.stack > 1)
			{
				str = " (" + item.stack + ")";
			}
			return new ItemTagHandler.ItemSnippet(item)
			{
				Text = "[" + item.AffixName() + str + "]",
				CheckForHover = true,
				DeleteWhole = true
			};
		}
开发者ID:thegamingboffin,项目名称:Ulterraria_Reborn_GitHub,代码行数:56,代码来源:ItemTagHandler.cs


注:本文中的System.Item.Prefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。