本文整理汇总了C#中Terraria.Item类的典型用法代码示例。如果您正苦于以下问题:C# Item类的具体用法?C# Item怎么用?C# Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Item类属于Terraria命名空间,在下文中一共展示了Item类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Swap
public static void Swap(bool cycle)
{
Player p = Main.player[Main.myPlayer];
if (Main.gameMenu) return;
Item[] temp = new Item[10];
if (cycle)
{
for (int i = 0; i < 10; i++)
{
temp[i] = p.inventory[i];
p.inventory[i] = p.inventory[i + 10];
p.inventory[i + 10] = p.inventory[i + 20];
p.inventory[i + 20] = p.inventory[i + 30];
p.inventory[i + 30] = p.inventory[i + 40];
p.inventory[i + 40] = temp[i];
}
}
else
{
for (int i = 0; i < 10; i++)
{
temp[i] = p.inventory[i];
p.inventory[i] = p.inventory[i + 40];
p.inventory[i + 40] = temp[i];
}
}
}
开发者ID:dougbenham,项目名称:TerrariaPatcher,代码行数:27,代码来源:HotbarSwap.cs
示例2: GetItem
//new[]
// {
// new ItemId(1, "Gold Pickaxe"),
// new ItemId(4, "Gold Broadsword"),
// new ItemId(6, "Gold Shortsword"),
// new ItemId(10, "Gold Axe"),
// new ItemId(7, "Gold Hammer"),
// new ItemId(99, "Gold Bow"),
// new ItemId(1, "Silver Pickaxe"),
// new ItemId(4, "Silver Broadsword"),
// new ItemId(6, "Silver Shortsword"),
// new ItemId(10, "Silver Axe"),
// new ItemId(7, "Silver Hammer"),
// new ItemId(99, "Silver Bow"),
// new ItemId(1, "Copper Pickaxe"),
// new ItemId(4, "Copper Broadsword"),
// new ItemId(6, "Copper Shortsword"),
// new ItemId(10, "Copper Axe"),
// new ItemId(7, "Copper Hammer"),
// new ItemId(198, "Blue Phasesaber"),
// new ItemId(199, "Red Phasesaber"),
// new ItemId(200, "Green Phasesaber"),
// new ItemId(201, "Purple Phasesaber"),
// new ItemId(202, "White Phasesaber"),
// new ItemId(203, "Yellow Phasesaber"),
// };
public Terraria.Item GetItem(int id)
{
var curitem = new Terraria.Item();
curitem.SetDefaults(id);
return curitem;
}
开发者ID:KeviinSkyline,项目名称:Terraria-Map-Editor,代码行数:34,代码来源:TerrariaWrapper.cs
示例3: Handle
public static void Handle(ref Item inv, int context = 0)
{
ItemSlot.singleSlotArray[0] = inv;
ItemSlot.Handle(ItemSlot.singleSlotArray, context, 0);
inv = ItemSlot.singleSlotArray[0];
Recipe.FindRecipes();
}
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:7,代码来源:ItemSlot.cs
示例4: PUIItemSlot
public PUIItemSlot()
{
ShowTooltip = true;
Width.Set(_texture.Width * SCALE, 0);
Height.Set(_texture.Height * SCALE, 0);
Item = new Item();
}
开发者ID:chatrat12,项目名称:Prism,代码行数:7,代码来源:PUIItemSlot.cs
示例5: SetDefaults
public override void SetDefaults(Item item)
{
if (item.type == ItemID.CopperShortsword)
{
item.damage = 50;
}
}
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:7,代码来源:CopperShortsword.cs
示例6: CreateItem
public static Item CreateItem(string itemName, int stack = 0)
{
Item item = new Item();
item.RealSetDefaults(itemName);
if (stack > 0) item.stack = stack;
return item;
}
开发者ID:Jaex,项目名称:Terraria-API,代码行数:7,代码来源:ItemHelper.cs
示例7: ReadExtraData
public override void ReadExtraData(BinaryReader reader)
{
item = new Item();
item.netDefaults((int)reader.ReadInt16());
item.Prefix((int)reader.ReadByte());
item.stack = (int)reader.ReadInt16();
}
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:7,代码来源:TEItemFrame.cs
示例8: UIController
static UIController()
{
_userInterface = new UserInterface();
_state = new UIState();
_userInterface.SetState(_state);
TooltipText = string.Empty;
TooltipItem = new Item();
}
开发者ID:chatrat12,项目名称:Prism,代码行数:8,代码来源:UIController.cs
示例9: AddItem
private void AddItem(Item item)
{
if (!string.IsNullOrEmpty(item.name))
{
ItemType itemType = new ItemType(item.type, item.name, item.color);
Items.Add(itemType);
LoadIcon(itemType);
}
}
开发者ID:Jaex,项目名称:Terraria-API,代码行数:9,代码来源:ItemManager.cs
示例10: Item
TextSnippet ITagHandler.Parse(string text, Color baseColor, string options)
{
Item obj = new Item();
int result1;
if (int.TryParse(text, out result1))
obj.netDefaults(result1);
else
obj.SetDefaults(text);
if (obj.itemId <= 0)
return new TextSnippet(text);
obj.stack = 1;
if (options != null)
{
string[] strArray = options.Split(',');
for (int index = 0; index < strArray.Length; ++index)
{
if (strArray[index].Length != 0)
{
switch (strArray[index][0])
{
case 'p':
int result2;
if (int.TryParse(strArray[index].Substring(1), out result2))
{
obj.Prefix(Utils.Clamp<int>(result2, 0, 84));
continue;
}
continue;
case 's':
case 'x':
int result3;
if (int.TryParse(strArray[index].Substring(1), out result3))
{
obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
continue;
}
continue;
default:
continue;
}
}
}
}
string str = "";
if (obj.stack > 1)
str = " (" + obj.stack + ")";
ItemSnippet itemSnippet = new ItemSnippet(obj);
itemSnippet.Text = "[" + obj.AffixName() + str + "]";
itemSnippet.CheckForHover = true;
itemSnippet.DeleteWhole = true;
return itemSnippet;
}
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:56,代码来源:ItemTagHandler.cs
示例11: GenerateTag
public static string GenerateTag(Item I)
{
string str = "[i";
if (I.prefix != 0)
str = str + "/p" + I.prefix;
if (I.stack != 1)
str = str + "/s" + I.stack;
return str + ":" + I.netID + "]";
}
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:10,代码来源:ItemTagHandler.cs
示例12: OnSetDefaultsString
public static void OnSetDefaultsString(ref string itemname, Item item)
{
if (SetDefaultsString == null)
return;
var args = new SetDefaultsEventArgs<Item, string>()
{
Object = item,
Info = itemname,
};
SetDefaultsString(args);
itemname = args.Info;
}
开发者ID:Jaex,项目名称:Terraria-API,代码行数:14,代码来源:ItemHooks.cs
示例13: OnSetDefaultsInt
public static void OnSetDefaultsInt(ref int itemtype, Item item)
{
if (SetDefaultsInt == null)
return;
var args = new SetDefaultsEventArgs<Item, int>()
{
Object = item,
Info = itemtype,
};
SetDefaultsInt(args);
itemtype = args.Info;
}
开发者ID:Jaex,项目名称:Terraria-API,代码行数:15,代码来源:ItemHooks.cs
示例14: RemoveItem
public static bool RemoveItem(Item item)
{
if (item != null && item.active)
{
item.active = false;
for (int i = 0; i < me.inventory.Length; i++)
{
if (me.inventory[i] == item)
{
me.inventory[i] = new Item();
Main.PlaySound(7, (int)me.position.X, (int)me.position.Y, 1);
return true;
}
}
}
return false;
}
开发者ID:Jaex,项目名称:Terraria-API,代码行数:19,代码来源:ItemHelper.cs
示例15: UseItem
public override bool UseItem(Item item, Player player)
{
if (item.healLife > 0)
{
if (player.GetModPlayer<ExamplePlayer>(mod).badHeal)
{
int heal = item.healLife;
int damage = player.statLifeMax2 - player.statLife;
if (heal > damage)
{
heal = damage;
}
if (heal > 0)
{
player.AddBuff(mod.BuffType("Undead2"), 2 * heal, false);
}
}
}
return base.UseItem(item, player);
}
开发者ID:bluemagic123,项目名称:tModLoader,代码行数:20,代码来源:Potion.cs
示例16: SetRefillItems
public void SetRefillItems(string raw)
{
string[] array = raw.Split(',');
for (int i = 0; i < array.Length && i < 20; i++)
{
var item = new Item();
item.SetDefaults(array[i]);
RefillItems[i] = item;
}
//if (set)
// setChestItems(RefillItems);
}
开发者ID:Deathmax,项目名称:Chest-Control,代码行数:12,代码来源:Chest.cs
示例17: MoveCoins
public static void MoveCoins(Item[] pInv, Item[] cInv)
{
int[] numArray1 = new int[4];
List<int> list1 = new List<int>();
List<int> list2 = new List<int>();
bool flag = false;
int[] numArray2 = new int[40];
for (int index = 0; index < cInv.Length; ++index)
{
numArray2[index] = -1;
if (cInv[index].stack < 1 || cInv[index].itemId < 1)
{
list2.Add(index);
cInv[index] = new Item();
}
if (cInv[index] != null && cInv[index].stack > 0)
{
int num = 0;
if (cInv[index].itemId == 71)
num = 1;
if (cInv[index].itemId == 72)
num = 2;
if (cInv[index].itemId == 73)
num = 3;
if (cInv[index].itemId == 74)
num = 4;
numArray2[index] = num - 1;
if (num > 0)
{
numArray1[num - 1] += cInv[index].stack;
list2.Add(index);
cInv[index] = new Item();
flag = true;
}
}
}
if (!flag)
return;
Main.PlaySound(7, -1, -1, 1);
for (int index = 0; index < pInv.Length; ++index)
{
if (index != 58 && pInv[index] != null && pInv[index].stack > 0)
{
int num = 0;
if (pInv[index].itemId == 71)
num = 1;
if (pInv[index].itemId == 72)
num = 2;
if (pInv[index].itemId == 73)
num = 3;
if (pInv[index].itemId == 74)
num = 4;
if (num > 0)
{
numArray1[num - 1] += pInv[index].stack;
list1.Add(index);
pInv[index] = new Item();
}
}
}
for (int index = 0; index < 3; ++index)
{
while (numArray1[index] >= 100)
{
numArray1[index] -= 100;
++numArray1[index + 1];
}
}
for (int index1 = 0; index1 < 40; ++index1)
{
if (numArray2[index1] >= 0 && cInv[index1].itemId == 0)
{
int index2 = index1;
int index3 = numArray2[index1];
if (numArray1[index3] > 0)
{
cInv[index2].SetDefaults(71 + index3, false);
cInv[index2].stack = numArray1[index3];
if (cInv[index2].stack > cInv[index2].maxStack)
cInv[index2].stack = cInv[index2].maxStack;
numArray1[index3] -= cInv[index2].stack;
numArray2[index1] = -1;
}
if (Main.netMode == 1 && Main.player[Main.myPlayer].chest > -1)
NetMessage.SendData(32, -1, -1, "", Main.player[Main.myPlayer].chest, (float)index2, 0.0f, 0.0f, 0, 0, 0);
list2.Remove(index2);
}
}
for (int index1 = 0; index1 < 40; ++index1)
{
if (numArray2[index1] >= 0 && cInv[index1].itemId == 0)
{
int index2 = index1;
int index3 = 3;
while (index3 >= 0)
{
if (numArray1[index3] > 0)
{
cInv[index2].SetDefaults(71 + index3, false);
cInv[index2].stack = numArray1[index3];
//.........这里部分代码省略.........
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:101,代码来源:ChestUI.cs
示例18: 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;
}
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:77,代码来源:ChestUI.cs
示例19: Inventory
public Inventory(Item[] items, string name)
{
Default();
Items = ItemArrayToIIArray(items);
Name = name;
}
开发者ID:Nationator,项目名称:Buildaria,代码行数:6,代码来源:Inventory.cs
示例20: Restock
public static void Restock()
{
Player player = Main.player[Main.myPlayer];
Item[] inv = player.inventory;
Item[] objArray = player.bank.item;
if (player.chest > -1)
objArray = Main.chest[player.chest].item;
else if (player.chest == -2)
objArray = player.bank.item;
else if (player.chest == -3)
objArray = player.bank2.item;
HashSet<int> hashSet = new HashSet<int>();
List<int> list1 = new List<int>();
List<int> list2 = new List<int>();
for (int index = 57; index >= 0; --index)
{
if ((index < 50 || index >= 54) && (inv[index].itemId < 71 || inv[index].itemId > 74))
{
if (inv[index].stack > 0 && inv[index].maxStack > 1 && (int)inv[index].prefix == 0)
{
hashSet.Add(inv[index].netID);
if (inv[index].stack < inv[index].maxStack)
list1.Add(index);
}
else if (inv[index].stack == 0 || inv[index].netID == 0 || inv[index].itemId == 0)
list2.Add(index);
}
}
bool flag1 = false;
for (int index1 = 0; index1 < objArray.Length; ++index1)
{
if (objArray[index1].stack >= 1 && (int)objArray[index1].prefix == 0 && hashSet.Contains(objArray[index1].netID))
{
bool flag2 = false;
for (int index2 = 0; index2 < list1.Count; ++index2)
{
int slot = list1[index2];
int context = 0;
if (slot >= 50)
context = 2;
if (inv[slot].netID == objArray[index1].netID && ItemSlot.PickItemMovementAction(inv, context, slot, objArray[index1]) != -1)
{
int num = objArray[index1].stack;
if (inv[slot].maxStack - inv[slot].stack < num)
num = inv[slot].maxStack - inv[slot].stack;
inv[slot].stack += num;
objArray[index1].stack -= num;
flag1 = true;
if (inv[slot].stack == inv[slot].maxStack)
{
if (Main.netMode == 1 && Main.player[Main.myPlayer].chest > -1)
NetMessage.SendData(32, -1, -1, "", Main.player[Main.myPlayer].chest, (float)index1, 0.0f, 0.0f, 0, 0, 0);
list1.RemoveAt(index2);
--index2;
}
if (objArray[index1].stack == 0)
{
objArray[index1] = new Item();
flag2 = true;
if (Main.netMode == 1 && Main.player[Main.myPlayer].chest > -1)
{
NetMessage.SendData(32, -1, -1, "", Main.player[Main.myPlayer].chest, (float)index1, 0.0f, 0.0f, 0, 0, 0);
break;
}
break;
}
}
}
if (!flag2 && list2.Count > 0 && objArray[index1].ammo != 0)
{
for (int index2 = 0; index2 < list2.Count; ++index2)
{
int context = 0;
if (list2[index2] >= 50)
context = 2;
if (ItemSlot.PickItemMovementAction(inv, context, list2[index2], objArray[index1]) != -1)
{
Utils.Swap<Item>(ref inv[list2[index2]], ref objArray[index1]);
list1.Add(list2[index2]);
list2.RemoveAt(index2);
flag1 = true;
break;
}
}
}
}
}
if (!flag1)
return;
Main.PlaySound(7, -1, -1, 1);
}
开发者ID:EmuDevs,项目名称:EDTerraria,代码行数:91,代码来源:ChestUI.cs
注:本文中的Terraria.Item类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论