本文整理汇总了C#中Terraria.Item.SetDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# Item.SetDefaults方法的具体用法?C# Item.SetDefaults怎么用?C# Item.SetDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria.Item
的用法示例。
在下文中一共展示了Item.SetDefaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupStartInventory
public override void SetupStartInventory(IList<Item> items)
{
Item item = new Item();
item.SetDefaults(mod.ItemType("ExampleItem"));
item.stack = 5;
items.Add(item);
}
示例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: PostSetupContent
public override void PostSetupContent()
{
LoadReferences();
Item ccoutfit = new Item();
ccoutfit.SetDefaults(ItemType("CandyCopterOutfit"));
Mounts.CandyCopter._outfit = ccoutfit.legSlot;
}
示例4: FillPrefixEntries
private void FillPrefixEntries()
{
_scrollView.Content.RemoveAllChildren();
if (_itemSlot.Item != null && _itemSlot.Item.type != 0)
{
var baseItem = new Item();
baseItem.SetDefaults(_itemSlot.Item.type);
var items = GetItemsPrefixes(_itemSlot.Item);
float yPos = 5;
for(int i = 0;i < items.Length; i++)
{
var item = items[i];
var entry = new PrefixEntry(item);
entry.Top.Set(yPos, 0f);
entry.Width.Set(0, 0.5f);
entry.OnClick += entry_OnClick;
if (i % 2 == 1)
{
entry.Left.Set(0, 0.5f);
yPos += entry.Height.Pixels + 5;
}
_scrollView.Content.Append(entry);
}
_scrollView.SetContentHeight(yPos);
}
else
_scrollView.SetContentHeight(0);
}
示例5: Changeinv
public static void Changeinv(int index = 0)
{
if (LazyInventory.InuseCategory == null) { return; }
if (index != 0)
{
index *= 40;
}
Main.playerInventory = true;
ONclearinv(Save());
int SlotCount = 0;
for (int i = index; i < InuseCategory.invetory.Count; i++)
{
if (SlotCount <= 40)
{
Item T = new Item();
T.SetDefaults(InuseCategory.invetory[i]);
T.stack = T.maxStack;
Main.player[Main.myPlayer].inventory[SlotCount] = T;
SlotCount++;
}
else { break; }
}
}
示例6: SetupStartInventory
public override void SetupStartInventory(IList<Item> items)
{
Item item = new Item();
item.SetDefaults(mod.ItemType("QuestBook"));
items.Add(item);
}
示例7: 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;
}
示例8: entry_OnClick
void entry_OnClick(Terraria.UI.UIMouseEvent evt, Terraria.UI.UIElement listeningElement)
{
var entry = (PrefixEntry)listeningElement;
var baseItem = new Item();
baseItem.SetDefaults(entry.Item.type);
baseItem.Prefix(entry.Item.prefix);
_itemSlot.Item = baseItem;
}
示例9: 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;
}
示例10: ItemLoader
static ItemLoader()
{
for (int k = 0; k < ItemID.Count; k++)
{
Item item = new Item();
item.SetDefaults(k);
if (item.wingSlot > 0)
{
vanillaWings[item.wingSlot] = k;
}
}
}
示例11: UpdateAccessory
public override void UpdateAccessory(Item item, Player player)
{
if (Main.myPlayer == player.whoAmI)
{
if (item.type == ItemID.MusicBox && Main.rand.Next(10800) == 0 && Main.curMusic >= Main.maxMusic && Main.curMusic < Main.music.Length)
{
if (Main.curMusic == mod.GetSoundSlot(SoundType.Music, "Sounds/Music/DriveMusic"))
{
item.SetDefaults(mod.ItemType("ExampleMusicBox"), false);
}
}
}
}
示例12: AnglerQuestReward
public override void AnglerQuestReward(float quality, List<Item> rewardItems)
{
if (voidMonolith > 0)
{
Item sticky = new Item();
sticky.SetDefaults(ItemID.StickyDynamite);
sticky.stack = 4;
rewardItems.Add(sticky);
}
foreach (Item item in rewardItems)
{
if (item.type == ItemID.GoldCoin)
{
int stack = item.stack;
item.SetDefaults(ItemID.PlatinumCoin);
item.stack = stack;
}
}
}
示例13: SetStartInventory
internal static void SetStartInventory(Player player, IList<Item> items)
{
if (items.Count <= 50)
{
for (int k = 0; k < items.Count; k++)
{
player.inventory[k] = items[k];
}
}
else
{
for (int k = 0; k < 49; k++)
{
player.inventory[k] = items[k];
}
Item bag = new Item();
bag.SetDefaults(ModLoader.GetMod("ModLoader").ItemType("StartBag"));
for (int k = 49; k < items.Count; k++)
{
((StartBag)bag.modItem).AddItem(items[k]);
}
player.inventory[49] = bag;
}
}
示例14: PutItemInInventory
public void PutItemInInventory(int type, int selItem = -1)
{
for (int i = 0; i < 58; i++)
{
Item item = this.inventory[i];
if (item.stack > 0 && item.type == type && item.stack < item.maxStack)
{
item.stack++;
return;
}
}
if (selItem >= 0 && (this.inventory[selItem].type == 0 || this.inventory[selItem].stack <= 0))
{
this.inventory[selItem].SetDefaults(type, false);
return;
}
Item item2 = new Item();
item2.SetDefaults(type, false);
Item item3 = this.GetItem(this.whoAmi, item2, false);
if (item3.stack > 0)
{
int number = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, type, 1, false, 0, true);
if (Main.netMode == 1)
{
NetMessage.SendData(21, -1, -1, "", number, 1f, 0f, 0f, 0);
return;
}
}
else
{
item2.position.X = this.center().X - (float)(item2.width / 2);
item2.position.Y = this.center().Y - (float)(item2.height / 2);
item2.active = true;
}
}
示例15: AI
//.........这里部分代码省略.........
{
this.ai[0] += 1f;
}
if (this.localAI[0] < 100f)
{
this.localAI[0] += 1f;
}
this.tileCollide = false;
float num590 = 15.9f;
int num591 = 10;
Vector2 vector51 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
float num592 = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - vector51.X;
float num593 = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - vector51.Y;
float num594 = (float)Math.Sqrt((double)(num592 * num592 + num593 * num593));
if (num594 > 3000f)
{
this.Kill();
}
num594 = num590 / num594;
num592 *= num594;
num593 *= num594;
this.velocity.X = (this.velocity.X * (float)(num591 - 1) + num592) / (float)num591;
this.velocity.Y = (this.velocity.Y * (float)(num591 - 1) + num593) / (float)num591;
if (Main.myPlayer == this.owner)
{
Rectangle rectangle10 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
Rectangle rectangle11 = new Rectangle((int)Main.player[this.owner].position.X, (int)Main.player[this.owner].position.Y, Main.player[this.owner].width, Main.player[this.owner].height);
if (rectangle10.Intersects(rectangle11))
{
if (this.ai[1] > 0f && this.ai[1] < 3602f)
{
int num595 = (int)this.ai[1];
Item item = new Item();
item.SetDefaults(num595, false);
if (num595 == 3196)
{
int num596 = Main.player[this.owner].FishingLevel();
int minValue = (num596 / 20 + 3) / 2;
int num597 = (num596 / 10 + 6) / 2;
if (Main.rand.Next(50) < num596)
{
num597++;
}
if (Main.rand.Next(100) < num596)
{
num597++;
}
if (Main.rand.Next(150) < num596)
{
num597++;
}
if (Main.rand.Next(200) < num596)
{
num597++;
}
int stack = Main.rand.Next(minValue, num597 + 1);
item.stack = stack;
}
if (num595 == 3197)
{
int num598 = Main.player[this.owner].FishingLevel();
int minValue2 = (num598 / 4 + 15) / 2;
int num599 = (num598 / 2 + 30) / 2;
if (Main.rand.Next(50) < num598)
{
num599 += 4;