本文整理汇总了C#中Terraria.Item.IsTheSameAs方法的典型用法代码示例。如果您正苦于以下问题:C# Item.IsTheSameAs方法的具体用法?C# Item.IsTheSameAs怎么用?C# Item.IsTheSameAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria.Item
的用法示例。
在下文中一共展示了Item.IsTheSameAs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: armorSwap
public static Item armorSwap(Item newItem)
{
for (int i = 0; i < Main.player[Main.myPlayer].armor.Length; i++)
{
if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[i]))
{
Main.accSlotCount = i;
}
}
if (newItem.headSlot == -1 && newItem.bodySlot == -1 && newItem.legSlot == -1 && !newItem.accessory)
{
return newItem;
}
Item result = newItem;
if (newItem.headSlot != -1)
{
result = (Item) Main.player[Main.myPlayer].armor[0].Clone();
Main.player[Main.myPlayer].armor[0] = (Item) newItem.Clone();
}
else
{
if (newItem.bodySlot != -1)
{
result = (Item) Main.player[Main.myPlayer].armor[1].Clone();
Main.player[Main.myPlayer].armor[1] = (Item) newItem.Clone();
}
else
{
if (newItem.legSlot != -1)
{
result = (Item) Main.player[Main.myPlayer].armor[2].Clone();
Main.player[Main.myPlayer].armor[2] = (Item) newItem.Clone();
}
else
{
if (newItem.accessory)
{
for (int j = 3; j < 8; j++)
{
if (Main.player[Main.myPlayer].armor[j].type == 0)
{
Main.accSlotCount = j - 3;
break;
}
}
for (int k = 0; k < Main.player[Main.myPlayer].armor.Length; k++)
{
if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[k]))
{
Main.accSlotCount = k - 3;
}
}
if (Main.accSlotCount >= 5)
{
Main.accSlotCount = 0;
}
if (Main.accSlotCount < 0)
{
Main.accSlotCount = 4;
}
result = (Item) Main.player[Main.myPlayer].armor[3 + Main.accSlotCount].Clone();
Main.player[Main.myPlayer].armor[3 + Main.accSlotCount] = (Item) newItem.Clone();
Main.accSlotCount++;
if (Main.accSlotCount >= 5)
{
Main.accSlotCount = 0;
}
}
}
}
}
Main.PlaySound(7, -1, -1, 1);
Recipe.FindRecipes();
return result;
}
示例2: TryPlacingInChest
public static bool TryPlacingInChest(Item I, bool justCheck)
{
bool flag1 = false;
Player player = Main.player[Main.myPlayer];
Item[] objArray = player.bank.item;
if (player.chest > -1)
{
objArray = Main.chest[player.chest].item;
flag1 = Main.netMode == 1;
}
else if (player.chest == -2)
objArray = player.bank.item;
else if (player.chest == -3)
objArray = player.bank2.item;
bool flag2 = false;
if (I.maxStack > 1)
{
for (int index = 0; index < 40; ++index)
{
if (objArray[index].stack < objArray[index].maxStack && I.IsTheSameAs(objArray[index]))
{
int num = I.stack;
if (I.stack + objArray[index].stack > objArray[index].maxStack)
num = objArray[index].maxStack - objArray[index].stack;
if (justCheck)
{
flag2 = flag2 || num > 0;
break;
}
I.stack -= num;
objArray[index].stack += num;
Main.PlaySound(7, -1, -1, 1);
if (I.stack <= 0)
{
I.SetDefaults(0, false);
if (flag1)
{
NetMessage.SendData(32, -1, -1, "", player.chest, (float)index, 0.0f, 0.0f, 0, 0, 0);
break;
}
break;
}
if (objArray[index].itemId == 0)
{
objArray[index] = I.Clone();
I.SetDefaults(0, false);
}
if (flag1)
NetMessage.SendData(32, -1, -1, "", player.chest, (float)index, 0.0f, 0.0f, 0, 0, 0);
}
}
}
if (I.stack > 0)
{
for (int index = 0; index < 40; ++index)
{
if (objArray[index].stack == 0)
{
if (justCheck)
{
flag2 = true;
break;
}
Main.PlaySound(7, -1, -1, 1);
objArray[index] = I.Clone();
I.SetDefaults(0, false);
if (flag1)
{
NetMessage.SendData(32, -1, -1, "", player.chest, (float)index, 0.0f, 0.0f, 0, 0, 0);
break;
}
break;
}
}
}
return flag2;
}
示例3: armorSwap
public static Item armorSwap(Item newItem)
{
for (int i = 0; i < player[myPlayer].armor.Length; i++)
{
if (newItem.IsTheSameAs(player[myPlayer].armor[i]))
{
accSlotCount = i;
}
}
if (((newItem.headSlot == -1) && (newItem.bodySlot == -1)) && ((newItem.legSlot == -1) && !newItem.accessory))
{
return newItem;
}
Item item = newItem;
if (newItem.headSlot != -1)
{
item = (Item)player[myPlayer].armor[0].Clone();
player[myPlayer].armor[0] = (Item)newItem.Clone();
}
else if (newItem.bodySlot != -1)
{
item = (Item)player[myPlayer].armor[1].Clone();
player[myPlayer].armor[1] = (Item)newItem.Clone();
}
else if (newItem.legSlot != -1)
{
item = (Item)player[myPlayer].armor[2].Clone();
player[myPlayer].armor[2] = (Item)newItem.Clone();
}
else if (newItem.accessory)
{
for (int j = 3; j < 8; j++)
{
if (player[myPlayer].armor[j].type == 0)
{
accSlotCount = j - 3;
break;
}
}
for (int k = 0; k < player[myPlayer].armor.Length; k++)
{
if (newItem.IsTheSameAs(player[myPlayer].armor[k]))
{
accSlotCount = k - 3;
}
}
if (accSlotCount >= 5)
{
accSlotCount = 0;
}
if (accSlotCount < 0)
{
accSlotCount = 4;
}
item = (Item)player[myPlayer].armor[3 + accSlotCount].Clone();
player[myPlayer].armor[3 + accSlotCount] = (Item)newItem.Clone();
accSlotCount++;
if (accSlotCount >= 5)
{
accSlotCount = 0;
}
}
PlaySound(7, -1, -1, 1);
Recipe.FindRecipes();
return item;
}
示例4: AccCheck
private static bool AccCheck(Item newItem, int slot)
{
if (Main.player[Main.myPlayer].armor[slot].IsTheSameAs(newItem))
{
return false;
}
for (int i = 0; i < Main.player[Main.myPlayer].armor.Length; i++)
{
if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[i]))
{
return true;
}
}
return false;
}
示例5: ItemSpace
public bool ItemSpace(Item newItem)
{
if (newItem.uniqueStack && this.HasItem(newItem.itemId))
return false;
if (newItem.itemId == 58 || newItem.itemId == 184 || (newItem.itemId == 1734 || newItem.itemId == 1735) || (newItem.itemId == 1867 || newItem.itemId == 1868 || ItemID.Sets.NebulaPickup[newItem.itemId]))
return true;
int num = 50;
if (newItem.itemId == 71 || newItem.itemId == 72 || (newItem.itemId == 73 || newItem.itemId == 74))
num = 54;
for (int index = 0; index < num; ++index)
{
if (this.inventory[index].itemId == 0)
return true;
}
for (int index = 0; index < num; ++index)
{
if (this.inventory[index].itemId > 0 && this.inventory[index].stack < this.inventory[index].maxStack && newItem.IsTheSameAs(this.inventory[index]))
return true;
}
if (newItem.ammo > 0 && !newItem.notAmmo)
{
if (newItem.itemId != 75 && newItem.itemId != 169 && (newItem.itemId != 23 && newItem.itemId != 408) && (newItem.itemId != 370 && newItem.itemId != 1246))
{
for (int index = 54; index < 58; ++index)
{
if (this.inventory[index].itemId == 0)
return true;
}
}
for (int index = 54; index < 58; ++index)
{
if (this.inventory[index].itemId > 0 && this.inventory[index].stack < this.inventory[index].maxStack && newItem.IsTheSameAs(this.inventory[index]))
return true;
}
}
return false;
}
示例6: AccCheck
private static bool AccCheck(Item newItem, int slot)
{
if (Main.player[Main.myPlayer].armor[slot].IsTheSameAs(newItem))
{
return false;
}
if (Main.player[Main.myPlayer].armor[slot].wingSlot > 0 && newItem.wingSlot > 0)
{
return false;
}
for (int i = 0; i < Main.player[Main.myPlayer].armor.Length; i++)
{
if (slot < 8 && i < 8)
{
if (newItem.wingSlot > 0 && Main.player[Main.myPlayer].armor[i].wingSlot > 0)
{
return true;
}
}
else
{
if (slot >= 8 && i >= 8 && newItem.wingSlot > 0 && Main.player[Main.myPlayer].armor[i].wingSlot > 0)
{
return true;
}
}
if (newItem.IsTheSameAs(Main.player[Main.myPlayer].armor[i]))
{
return true;
}
}
return false;
}
示例7: ItemSpace
public bool ItemSpace(Item newItem)
{
if (newItem.type == 58 || newItem.type == 184)
{
return true;
}
else
{
int num = 40;
if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74)
num = 44;
for (int index = 0; index < num; ++index)
{
if (this.inventory[index].type == 0)
return true;
}
for (int index = 0; index < num; ++index)
{
if (this.inventory[index].type > 0 && this.inventory[index].stack < this.inventory[index].maxStack && newItem.IsTheSameAs(this.inventory[index]))
return true;
}
return false;
}
}
示例8: ItemSpace
public bool ItemSpace(Item newItem)
{
if (newItem.type == 58)
{
return true;
}
if (newItem.type == 184)
{
return true;
}
int num = 40;
if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74)
{
num = 44;
}
for (int i = 0; i < num; i++)
{
if (this.inventory[i].type == 0)
{
return true;
}
}
for (int j = 0; j < num; j++)
{
if (this.inventory[j].type > 0 && this.inventory[j].stack < this.inventory[j].maxStack && newItem.IsTheSameAs(this.inventory[j]))
{
return true;
}
}
if (newItem.ammo > 0)
{
if (newItem.type != 75 && newItem.type != 169 && newItem.type != 23 && newItem.type != 408 && newItem.type != 370)
{
for (int k = 44; k < 48; k++)
{
if (this.inventory[k].type == 0)
{
return true;
}
}
}
for (int l = 44; l < 48; l++)
{
if (this.inventory[l].type > 0 && this.inventory[l].stack < this.inventory[l].maxStack && newItem.IsTheSameAs(this.inventory[l]))
{
return true;
}
}
}
return false;
}
示例9: GetItem
public Item GetItem(int plr, Item newItem)
{
Item result;
if (newItem.noGrabDelay <= 0)
{
int num = 0;
if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74)
{
num = -4;
}
for (int i = num; i < 40; i++)
{
int num2 = i;
if (num2 < 0)
{
num2 = 44 + i;
}
if (this.inventory[num2].type > 0 && this.inventory[num2].stack < this.inventory[num2].maxStack && newItem.IsTheSameAs(this.inventory[num2]))
{
if (newItem.stack + this.inventory[num2].stack <= this.inventory[num2].maxStack)
{
Item item = this.inventory[num2];
item.stack += newItem.stack;
this.DoCoins(num2);
if (plr == Main.myPlayer)
{
Recipe.FindRecipes();
}
result = new Item();
return result;
}
newItem.stack -= this.inventory[num2].maxStack - this.inventory[num2].stack;
this.inventory[num2].stack = this.inventory[num2].maxStack;
this.DoCoins(num2);
if (plr == Main.myPlayer)
{
Recipe.FindRecipes();
}
}
}
for (int i = num; i < 40; i++)
{
int num2 = i;
if (num2 < 0)
{
num2 = 44 + i;
}
if (this.inventory[num2].type == 0)
{
this.inventory[num2] = newItem;
this.DoCoins(num2);
if (plr == Main.myPlayer)
{
Recipe.FindRecipes();
}
result = new Item();
return result;
}
}
}
result = newItem;
return result;
}
示例10: ItemSpace
public bool ItemSpace(Item newItem)
{
bool result;
if (newItem.type == 58)
{
result = true;
}
else
{
if (newItem.type == 184)
{
result = true;
}
else
{
int num = 40;
if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74)
{
num = 44;
}
for (int i = 0; i < num; i++)
{
if (this.inventory[i].type == 0)
{
result = true;
return result;
}
}
for (int i = 0; i < num; i++)
{
if (this.inventory[i].type > 0 && this.inventory[i].stack < this.inventory[i].maxStack && newItem.IsTheSameAs(this.inventory[i]))
{
result = true;
return result;
}
}
result = false;
}
}
return result;
}
示例11: FillAmmo
public Item FillAmmo(int plr, Item newItem, bool noText = false)
{
for (int i = 54; i < 58; i++)
{
if (this.inventory[i].type > 0 && this.inventory[i].stack < this.inventory[i].maxStack && newItem.IsTheSameAs(this.inventory[i]))
{
Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1);
if (newItem.stack + this.inventory[i].stack <= this.inventory[i].maxStack)
{
this.inventory[i].stack += newItem.stack;
if (!noText)
{
ItemText.NewText(newItem, newItem.stack, false, false);
}
this.DoCoins(i);
if (plr == Main.myPlayer)
{
Recipe.FindRecipes();
}
return new Item();
}
newItem.stack -= this.inventory[i].maxStack - this.inventory[i].stack;
if (!noText)
{
ItemText.NewText(newItem, this.inventory[i].maxStack - this.inventory[i].stack, false, false);
}
this.inventory[i].stack = this.inventory[i].maxStack;
this.DoCoins(i);
if (plr == Main.myPlayer)
{
Recipe.FindRecipes();
}
}
}
if (newItem.bait <= 0 && newItem.type != 169 && newItem.type != 75 && newItem.type != 23 && newItem.type != 408 && newItem.type != 370 && newItem.type != 1246 && newItem.type != 154 && !newItem.notAmmo)
{
for (int j = 54; j < 58; j++)
{
if (this.inventory[j].type == 0)
{
this.inventory[j] = newItem;
if (!noText)
{
ItemText.NewText(newItem, newItem.stack, false, false);
}
this.DoCoins(j);
Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1);
if (plr == Main.myPlayer)
{
Recipe.FindRecipes();
}
return new Item();
}
}
}
return newItem;
}
示例12: 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 index1 = !item.vanity || item.accessory ? 0 : 10;
item.favorited = false;
Item obj = item;
if (item.headSlot != -1)
{
obj = player.armor[index1].Clone();
player.armor[index1] = item.Clone();
}
else if (item.bodySlot != -1)
{
obj = player.armor[index1 + 1].Clone();
player.armor[index1 + 1] = item.Clone();
}
else if (item.legSlot != -1)
{
obj = player.armor[index1 + 2].Clone();
player.armor[index1 + 2] = item.Clone();
}
else if (item.accessory)
{
int num = 5 + Main.player[Main.myPlayer].extraAccessorySlots;
for (int index2 = 3; index2 < 3 + num; ++index2)
{
if (player.armor[index2].itemId == 0)
{
ItemSlot.accSlotCount = index2 - 3;
break;
}
}
for (int index2 = 0; index2 < player.armor.Length; ++index2)
{
if (item.IsTheSameAs(player.armor[index2]))
ItemSlot.accSlotCount = index2 - 3;
if (index2 < 10 && (int)item.wingSlot > 0 && (int)player.armor[index2].wingSlot > 0)
ItemSlot.accSlotCount = index2 - 3;
}
if (ItemSlot.accSlotCount >= num)
ItemSlot.accSlotCount = 0;
if (ItemSlot.accSlotCount < 0)
ItemSlot.accSlotCount = num - 1;
int index3 = 3 + ItemSlot.accSlotCount;
for (int index2 = 0; index2 < player.armor.Length; ++index2)
{
if (item.IsTheSameAs(player.armor[index2]))
index3 = index2;
}
obj = player.armor[index3].Clone();
player.armor[index3] = item.Clone();
++ItemSlot.accSlotCount;
if (ItemSlot.accSlotCount >= num)
ItemSlot.accSlotCount = 0;
}
Main.PlaySound(7, -1, -1, 1);
Recipe.FindRecipes();
success = true;
return obj;
}
示例13: AccCheck
private static bool AccCheck(Item item, int slot)
{
Player player = Main.player[Main.myPlayer];
if (slot != -1 && (player.armor[slot].IsTheSameAs(item) || (int)player.armor[slot].wingSlot > 0 && (int)item.wingSlot > 0))
return false;
for (int index = 0; index < player.armor.Length; ++index)
{
if (slot < 10 && index < 10 && ((int)item.wingSlot > 0 && (int)player.armor[index].wingSlot > 0 || slot >= 10 && index >= 10 && ((int)item.wingSlot > 0 && (int)player.armor[index].wingSlot > 0)) || item.IsTheSameAs(player.armor[index]))
return true;
}
return false;
}
示例14: ItemSpace
public bool ItemSpace(Item newItem)
{
if (newItem.uniqueStack && this.HasItem(newItem.type))
{
return false;
}
if (newItem.type == 58 || newItem.type == 184 || newItem.type == 1734 || newItem.type == 1735 || newItem.type == 1867 || newItem.type == 1868)
{
return true;
}
int num = 50;
if (newItem.type == 71 || newItem.type == 72 || newItem.type == 73 || newItem.type == 74)
{
num = 54;
}
for (int i = 0; i < num; i++)
{
if (this.inventory[i].type == 0)
{
return true;
}
}
for (int j = 0; j < num; j++)
{
if (this.inventory[j].type > 0 && this.inventory[j].stack < this.inventory[j].maxStack && newItem.IsTheSameAs(this.inventory[j]))
{
return true;
}
}
if (newItem.ammo > 0 && !newItem.notAmmo)
{
if (newItem.type != 75 && newItem.type != 169 && newItem.type != 23 && newItem.type != 408 && newItem.type != 370 && newItem.type != 1246)
{
for (int k = 54; k < 58; k++)
{
if (this.inventory[k].type == 0)
{
return true;
}
}
}
for (int l = 54; l < 58; l++)
{
if (this.inventory[l].type > 0 && this.inventory[l].stack < this.inventory[l].maxStack && newItem.IsTheSameAs(this.inventory[l]))
{
return true;
}
}
}
return false;
}
示例15: ItemSpace
public bool ItemSpace(Item newItem)
{
if (newItem.uniqueStack && this.HasItem(newItem.type))
{
return false;
}
if (newItem.type == ItemID.Heart || newItem.type == ItemID.Star || newItem.type == ItemID.CandyApple || newItem.type == ItemID.SoulCake || newItem.type == ItemID.CandyCane || newItem.type == ItemID.SugarPlum)
{
return true;
}
if (ItemID.Sets.NebulaPickup[newItem.type])
{
return true;
}
int num = 50;
if (newItem.type == ItemID.CopperCoin || newItem.type == ItemID.SilverCoin || newItem.type == ItemID.GoldCoin || newItem.type == ItemID.PlatinumCoin)
{
num = 54;
}
for (int i = 0; i < num; i++)
{
if (this.inventory[i].type == 0)
{
return true;
}
}
for (int j = 0; j < num; j++)
{
if (this.inventory[j].type > 0 && this.inventory[j].stack < this.inventory[j].maxStack && newItem.IsTheSameAs(this.inventory[j]))
{
return true;
}
}
if (newItem.ammo > 0 && !newItem.notAmmo)
{
if (newItem.type != ItemID.FallenStar && newItem.type != ItemID.SandBlock && newItem.type != ItemID.Gel && newItem.type != ItemID.PearlsandBlock && newItem.type != ItemID.EbonsandBlock && newItem.type != ItemID.CrimsandBlock)
{
for (int k = 54; k < 58; k++)
{
if (this.inventory[k].type == 0)
{
return true;
}
}
}
for (int l = 54; l < 58; l++)
{
if (this.inventory[l].type > 0 && this.inventory[l].stack < this.inventory[l].maxStack && newItem.IsTheSameAs(this.inventory[l]))
{
return true;
}
}
}
return false;
}