本文整理汇总了C#中Terraria.Item类的典型用法代码示例。如果您正苦于以下问题:C# Item类的具体用法?C# Item怎么用?C# Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Item类属于Terraria命名空间,在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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];
}
}
}
示例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;
}
示例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();
}
示例4: PUIItemSlot
public PUIItemSlot()
{
ShowTooltip = true;
Width.Set(_texture.Width * SCALE, 0);
Height.Set(_texture.Height * SCALE, 0);
Item = new Item();
}
示例5: SetDefaults
public override void SetDefaults(Item item)
{
if (item.type == ItemID.CopperShortsword)
{
item.damage = 50;
}
}
示例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;
}
示例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();
}
示例8: UIController
static UIController()
{
_userInterface = new UserInterface();
_state = new UIState();
_userInterface.SetState(_state);
TooltipText = string.Empty;
TooltipItem = new Item();
}
示例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);
}
}
示例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;
}
示例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 + "]";
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}