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


C# Item.Clone方法代码示例

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


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

示例1: EquipSwap

 private static Item EquipSwap(Item item, Item[] inv, int slot, out bool success)
 {
     success = false;
     Player arg_0E_0 = Main.player[Main.myPlayer];
     item.favorited = false;
     Item result = inv[slot].Clone();
     inv[slot] = item.Clone();
     Main.PlaySound(7, -1, -1, 1);
     Recipe.FindRecipes();
     success = true;
     return result;
 }
开发者ID:MEFBAEA,项目名称:mefbaea,代码行数:12,代码来源:ItemSlot.cs

示例2: Up

            /**
             * traverse upwards
             */
            private int Up() {
                Item i = new Item();
                int res = 0;

                if (ns.Count == 0)
                    return -1;

                if (cur != 0 && parent.sc[cur] == 0)
                    return parent.lo[cur];

                bool climb = true;

                while (climb) {
                    i = (Item)ns.Pop();
                    i.child++;
                    switch (i.child) {
                        case (char)1:
                            if (parent.sc[i.parent] != 0) {
                                res = parent.eq[i.parent];
                                ns.Push(i.Clone());
                                ks.Append(parent.sc[i.parent]);
                            } else {
                                i.child++;
                                ns.Push(i.Clone());
                                res = parent.hi[i.parent];
                            }
                            climb = false;
                            break;

                        case (char)2:
                            res = parent.hi[i.parent];
                            ns.Push(i.Clone());
                            if (ks.Length > 0)
                                ks.Length = ks.Length - 1;    // pop
                            climb = false;
                            break;

                        default:
                            if (ns.Count == 0)
                                return -1;
                            climb = true;
                            break;
                    }
                }
                return res;
            }
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:49,代码来源:TernaryTree.cs

示例3: ArmorSwap

 private static Item ArmorSwap(Item item, out bool success)
 {
     success = false;
     if (item.headSlot == -1 && item.bodySlot == -1 && item.legSlot == -1 && !item.accessory)
     {
         return item;
     }
     Player player = Main.player[Main.myPlayer];
     int num = (item.vanity && !item.accessory) ? 10 : 0;
     item.favorited = false;
     Item result = item;
     if (item.headSlot != -1)
     {
         result = player.armor[num].Clone();
         player.armor[num] = item.Clone();
     }
     else if (item.bodySlot != -1)
     {
         result = player.armor[num + 1].Clone();
         player.armor[num + 1] = item.Clone();
     }
     else if (item.legSlot != -1)
     {
         result = player.armor[num + 2].Clone();
         player.armor[num + 2] = item.Clone();
     }
     else if (item.accessory)
     {
         int num2 = 5 + Main.player[Main.myPlayer].extraAccessorySlots;
         for (int i = 3; i < 3 + num2; i++)
         {
             if (player.armor[i].type == 0)
             {
                 ItemSlot.accSlotCount = i - 3;
                 break;
             }
         }
         for (int j = 0; j < player.armor.Length; j++)
         {
             if (item.IsTheSameAs(player.armor[j]))
             {
                 ItemSlot.accSlotCount = j - 3;
             }
             if (j < 10 && item.wingSlot > 0 && player.armor[j].wingSlot > 0)
             {
                 ItemSlot.accSlotCount = j - 3;
             }
         }
         if (ItemSlot.accSlotCount >= num2)
         {
             ItemSlot.accSlotCount = 0;
         }
         if (ItemSlot.accSlotCount < 0)
         {
             ItemSlot.accSlotCount = num2 - 1;
         }
         int num3 = 3 + ItemSlot.accSlotCount;
         for (int k = 0; k < player.armor.Length; k++)
         {
             if (item.IsTheSameAs(player.armor[k]))
             {
                 num3 = k;
             }
         }
         result = player.armor[num3].Clone();
         player.armor[num3] = item.Clone();
         ItemSlot.accSlotCount++;
         if (ItemSlot.accSlotCount >= num2)
         {
             ItemSlot.accSlotCount = 0;
         }
     }
     Main.PlaySound(7, -1, -1, 1);
     Recipe.FindRecipes();
     success = true;
     return result;
 }
开发者ID:MEFBAEA,项目名称:mefbaea,代码行数:77,代码来源:ItemSlot.cs

示例4: DyeSwap

 private static Item DyeSwap(Item item, out bool success)
 {
     success = false;
     if (item.dye <= 0)
     {
         return item;
     }
     Player player = Main.player[Main.myPlayer];
     for (int i = 0; i < 10; i++)
     {
         if (player.dye[i].type == 0)
         {
             ItemSlot.dyeSlotCount = i;
             break;
         }
     }
     if (ItemSlot.dyeSlotCount >= 10)
     {
         ItemSlot.dyeSlotCount = 0;
     }
     if (ItemSlot.dyeSlotCount < 0)
     {
         ItemSlot.dyeSlotCount = 9;
     }
     Item result = player.dye[ItemSlot.dyeSlotCount].Clone();
     player.dye[ItemSlot.dyeSlotCount] = item.Clone();
     ItemSlot.dyeSlotCount++;
     if (ItemSlot.dyeSlotCount >= 10)
     {
         ItemSlot.accSlotCount = 0;
     }
     Main.PlaySound(7, -1, -1, 1);
     Recipe.FindRecipes();
     success = true;
     return result;
 }
开发者ID:MEFBAEA,项目名称:mefbaea,代码行数:36,代码来源:ItemSlot.cs

示例5: PutItemInNearbyChest

        // Modded version of Terraria's Original
        private Item PutItemInNearbyChest(TSPlayer player, Item item, Vector2 position)
        {
            float quickStackRange = this.Config.QuickStackNearbyRange * 16;

              for (int i = 0; i < Main.chest.Length; i++) {
            Chest chest = Main.chest[i];
            if (chest == null || !Main.tile[chest.x, chest.y].active())
              continue;

            bool containsSameItem = false;
            bool hasEmptySlot = false;

            bool isPlayerInChest = false;
            for (int j = 0; j < 255; j++) {
              if (Main.player[j].chest == i) {
            isPlayerInChest = true;
            break;
              }
            }

            if (!isPlayerInChest && !Chest.isLocked(chest.x, chest.y)) {
              Vector2 vector2 = new Vector2((chest.x * 16 + 16), (chest.y * 16 + 16));
              if ((vector2 - position).Length() < quickStackRange) {
            ProtectionEntry protection;
            if (this.ProtectionManager.CheckBlockAccess(player, new DPoint(chest.x, chest.y), false, out protection)) {
              bool isRefillChest = (protection != null && protection.RefillChestData != null);
              if (!isRefillChest) {
                bool isBankChest = (protection != null && protection.BankChestKey != BankChestDataKey.Invalid);

                for (int j = 0; j < chest.item.Length; j++) {
                  Item chestItem = chest.item[j];
                  if (chestItem.type <= 0 || chestItem.stack <= 0)
                    hasEmptySlot = true;
                  else if (item.IsTheSameAs(chestItem)) {
                    containsSameItem = true;
                    int stackLeft = chestItem.maxStack - chestItem.stack;
                    if (stackLeft > 0) {
                      if (stackLeft > item.stack)
                        stackLeft = item.stack;

                      item.stack = item.stack - stackLeft;
                      chestItem.stack = chestItem.stack + stackLeft;
                      if (isBankChest)
                        this.ServerMetadataHandler.EnqueueUpdateBankChestItem(protection.BankChestKey, j, ItemData.FromItem(chestItem));

                      if (item.stack <= 0) {
                        item.SetDefaults();
                        return item;
                      }
                    }
                  }
                }
                if (containsSameItem && hasEmptySlot && item.stack > 0) {
                  for (int k = 0; k < chest.item.Length; k++) {
                    Item chestItem = chest.item[k];
                    if (chestItem.type == 0 || chestItem.stack == 0) {
                      chest.item[k] = item.Clone();

                      if (isBankChest)
                        this.ServerMetadataHandler.EnqueueUpdateBankChestItem(protection.BankChestKey, k, ItemData.FromItem(item));

                      item.SetDefaults();
                      return item;
                    }
                  }
                }
              }
            }
              }
            }
              }
              return item;
        }
开发者ID:UB1AFU,项目名称:Protector-Plugin,代码行数:74,代码来源:UserInteractionHandler.cs

示例6: AdjustWeaponSpeed

        private Item AdjustWeaponSpeed(Item weapon, float speed)
        {
            Item adjustedWeapon = weapon.Clone();

            adjustedWeapon.MinDamage = (int)Math.Round(weapon.MinDamage / weapon.Speed * speed);
            adjustedWeapon.MaxDamage = (int)Math.Round(weapon.MaxDamage / weapon.Speed * speed);
            adjustedWeapon.Speed = speed;

            return adjustedWeapon;
        }
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:10,代码来源:CalculationsRetribution.cs

示例7: TryPlacingInChest

		public static bool TryPlacingInChest(Item I, bool justCheck)
		{
			bool flag = false;
			Player player = Main.player[Main.myPlayer];
			Item[] item = player.bank.item;
			if (player.chest > -1)
			{
				item = Main.chest[player.chest].item;
				flag = (Main.netMode == 1);
			}
			else if (player.chest == -2)
			{
				item = player.bank.item;
			}
			else if (player.chest == -3)
			{
				item = player.bank2.item;
			}
			bool flag2 = false;
			if (I.maxStack > 1)
			{
				for (int i = 0; i < 40; i++)
				{
					if (item[i].stack < item[i].maxStack && I.IsTheSameAs(item[i]))
					{
						int num = I.stack;
						if (I.stack + item[i].stack > item[i].maxStack)
						{
							num = item[i].maxStack - item[i].stack;
						}
						if (justCheck)
						{
							flag2 = (flag2 || num > 0);
							break;
						}
						I.stack -= num;
						item[i].stack += num;
						Main.PlaySound(7, -1, -1, 1);
						if (I.stack <= 0)
						{
							I.SetDefaults(0, false);
							if (flag)
							{
								NetMessage.SendData(32, -1, -1, "", player.chest, (float)i, 0f, 0f, 0, 0, 0);
								break;
							}
							break;
						}
						else
						{
							if (item[i].type == 0)
							{
								item[i] = I.Clone();
								I.SetDefaults(0, false);
							}
							if (flag)
							{
								NetMessage.SendData(32, -1, -1, "", player.chest, (float)i, 0f, 0f, 0, 0, 0);
							}
						}
					}
				}
			}
			if (I.stack > 0)
			{
				int j = 0;
				while (j < 40)
				{
					if (item[j].stack == 0)
					{
						if (justCheck)
						{
							flag2 = true;
							break;
						}
						Main.PlaySound(7, -1, -1, 1);
						item[j] = I.Clone();
						I.SetDefaults(0, false);
						if (flag)
						{
							NetMessage.SendData(32, -1, -1, "", player.chest, (float)j, 0f, 0f, 0, 0, 0);
							break;
						}
						break;
					}
					else
					{
						j++;
					}
				}
			}
			return flag2;
		}
开发者ID:thegamingboffin,项目名称:Ulterraria_Reborn_GitHub,代码行数:93,代码来源:ChestUI.cs

示例8: OnCopyItem

 /// <summary>
 /// Copies an <paramref name="item"/> to the clipboard.
 /// </summary>
 /// <param name="item">An <see cref="Item"/> to copy.</param>
 /// <remarks>Invoked by the 'Copy' menu item.</remarks>
 protected virtual void OnCopyItem(Item item)
 {
     if (item == null) {
         throw new ArgumentNullException("item");
     }
     IDataObject dataObject = new DataObject(ClipboardFormat.Item, item.Clone());
     Clipboard.SetDataObject(dataObject, false);
 }
开发者ID:hksonngan,项目名称:sharptracing,代码行数:13,代码来源:Toolbox.Menu.cs

示例9: ItemContainer

 /// <summary>
 /// Creates a new instance of the ItemContainer class
 /// </summary>
 /// <param name="i">Sets the ContainedItem field</param>
 public ItemContainer(Item i)
     : this()
 {
     ContainedItem = (Item)i.Clone();
 }
开发者ID:jayands,项目名称:tAPI-SDK,代码行数:9,代码来源:ItemContainer.cs


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