本文整理汇总了C#中Inventory.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.Add方法的具体用法?C# Inventory.Add怎么用?C# Inventory.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanEquipItemIntoTakenSlotIfAutoUnequip
public void CanEquipItemIntoTakenSlotIfAutoUnequip()
{
var inventory = new Inventory();
var item1 = new WeightedItem { Weight = Weight.Heavy, Name = "hello1" };
var item2 = new WeightedItem { Weight = Weight.Heavy, Name = "hello2" };
inventory.Add(item1);
inventory.Add(item2);
Assert.True(inventory.Equip(item1));
Assert.Same(inventory.HeavySlotItem, item1);
Assert.True(inventory.Equip(item2));
Assert.Same(inventory.HeavySlotItem, item2);
}
示例2: Start
void Start(){
party = new PokeParty(this);
inventory = new Inventory(this);
//kanto starters, why not
party.AddPokemon(new Pokemon(1, true));
party.AddPokemon(new Pokemon(4, true));
party.AddPokemon(new Pokemon(7, true));
Pokedex.states [1] = Pokedex.State.Captured;
Pokedex.states [4] = Pokedex.State.Captured;
Pokedex.states [7] = Pokedex.State.Captured;
inventory.Add(1, 5); //New inventory code references shared item data. (id, quantity)
inventory.Add(4, 2);
}
示例3: Player
public Player(Map map)
: base('@', TCODColor.green)
{
CurrentMap = map;
Light = new Light(0, 0, 0);
_inventory = new Inventory(this);
_inventory.Add(new ItemsData.TorchLight());
Equip(Inventory.GetAtLetter('a'));
for (int i = 0; i < 5; i++)
{
_inventory.Add(new ItemsData.WeakTorch());
}
_inventory.Add(new ItemsData.FlashScroll());
_inventory.Add(new ItemsData.FlashScroll());
_inventory.Add(new ItemsData.FlashScroll());
}
示例4: CanEquipItemIntoEmptySlot
public void CanEquipItemIntoEmptySlot()
{
var inventory = new Inventory();
var item = new WeightedItem { Weight = Weight.Heavy, Name = "hello" };
inventory.Add(item);
Assert.True(inventory.Equip(item));
Assert.Same(inventory.HeavySlotItem, item);
}
示例5: CanAddNonWeightedItem
public void CanAddNonWeightedItem()
{
var inventory = new Inventory();
var item = new Item { Name = "hello" };
inventory.Add(item);
Assert.Contains(item, inventory.AllItems);
Assert.Contains(item, inventory.UnequippedItems);
Assert.DoesNotContain(item, inventory.EquippedItems);
}
示例6: Trainer
public Trainer(string name)
: base()
{
//Will give to both the player and the npc (just like in multiplayer)
this.name = name;
party = new PokeParty(this);
inventory = new Inventory(this);
//kanto starters, why not
party.AddPokemon(new Pokemon(1, null, true));
party.AddPokemon(new Pokemon(4, null, true));
party.AddPokemon(new Pokemon(7, null, true));
Pokedex.states [1] = Pokedex.State.Captured;
Pokedex.states [4] = Pokedex.State.Captured;
Pokedex.states [7] = Pokedex.State.Captured;
inventory.Add(1, 5); //New inventory code references shared item data. (id, quantity)
inventory.Add(4, 2);
}
示例7: CanEquipArmor
public void CanEquipArmor()
{
var inventory = new Inventory();
var armor = new Armor { Name = "hello" };
inventory.Add(armor);
Assert.Contains(armor, inventory.AllItems);
Assert.Contains(armor, inventory.UnequippedItems);
Assert.DoesNotContain(armor, inventory.EquippedItems);
Assert.Null(inventory.ArmorItem);
inventory.Equip(armor);
Assert.Contains(armor, inventory.AllItems);
Assert.DoesNotContain(armor, inventory.UnequippedItems);
Assert.Contains(armor, inventory.EquippedItems);
Assert.Same(armor, inventory.ArmorItem);
}
示例8: CanEquipSpellBook
public void CanEquipSpellBook()
{
var inventory = new Inventory();
var spellBook = new SpellBook { Name = "hello" };
inventory.Add(spellBook);
Assert.Contains(spellBook, inventory.AllItems);
Assert.Contains(spellBook, inventory.UnequippedItems);
Assert.DoesNotContain(spellBook, inventory.EquippedItems);
Assert.Null(inventory.SpellBookItem);
inventory.Equip(spellBook);
Assert.Contains(spellBook, inventory.AllItems);
Assert.DoesNotContain(spellBook, inventory.UnequippedItems);
Assert.Contains(spellBook, inventory.EquippedItems);
Assert.Same(spellBook, inventory.SpellBookItem);
}
示例9: CopyTo
public void CopyTo(Inventory inventory)
{
int counter = 0;
for (int i = 0; i < Size && counter < inventory.Size; i++)
{
if (data[i] != null)
{
inventory.Add(data[i]);
//RemoveStack(i);
counter++;
}
}
}
示例10: Start
private void Start()
{
_inventory = GetComponent<Inventory>();
_inventory.Add(ResourceType, ResourceAmount);
}
示例11: Start
private int use_opt; //3 = use, 4 = examine, 5 = quit
#endregion Fields
#region Methods
//Ang.invent; //USE GLOBALIZED INVENTORY
// Use this for initialization
void Start()
{
itemss = new Inventory ();
Item0 = new HealingItem ("Cherry.", "This is a Cherry.", 30, "Heals 30% of \nyour Health.", 1);
Item1 = new QuestItem ("Sword.", "This is a Sword.", "It has a cute \ntattoo on its hilt.", 2);
Item2 = new QuestItem ("Boob.", "It's a boob.", "Still a boob.", 1);
Item3 = new HealingItem ("Cherry.", "This is a\nCherry.", 30, "Heals 30% of \nyour Health.", 1);
Item4 = new HealingItem ("Cherry.", "This is a\nCherry.", 30, "Heals 30% of \nyour Health.", 1);
itemss.Add (Item0);
itemss.Add (Item1);
itemss.Add (Item2);
itemss.Add (Item0);
itemss.Add (Item1);
//(string name, string description, string examineText = "A quest item.",
//int quantity = 1)
//(string name, string description, string examineText = "A healing item.",
//int healingAmt, int quantity = 1)
inventory = GameObject.Find ("Inventory_BG");
theCanvas = inventory.transform.GetChild (6).gameObject; //theCanvas is the Canvas at index(6), child of Inventory_BG; do not change this variable
usePrompt = GameObject.Find ("Use_Prompt");
for (iter = 0; iter < 25; iter++) {
if (iter < 6) {
inventory.transform.GetChild (iter).gameObject.SetActive(false); //Deactivating everything under Inventory_BG
}
theCanvas.transform.GetChild (iter).gameObject.SetActive (false); //children of index(6) deactivated
}
//Making text objects manipulable in script.
//example usage: Item0_Deselected_Text.text = Item0_Selected_Text.text = "Item_Name0"
Item0_Deselected_Text = theCanvas.transform.GetChild (0).GetComponent<Text>();
Item1_Deselected_Text = theCanvas.transform.GetChild (1).GetComponent<Text>();
Item2_Deselected_Text = theCanvas.transform.GetChild (2).GetComponent<Text>();
Item3_Deselected_Text = theCanvas.transform.GetChild (3).GetComponent<Text>();
Item4_Deselected_Text = theCanvas.transform.GetChild (4).GetComponent<Text>();
Item5_Deselected_Text = theCanvas.transform.GetChild (5).GetComponent<Text>();
Item6_Deselected_Text = theCanvas.transform.GetChild (6).GetComponent<Text>();
Item7_Deselected_Text = theCanvas.transform.GetChild (7).GetComponent<Text>();
Item8_Deselected_Text = theCanvas.transform.GetChild (8).GetComponent<Text>();
Item9_Deselected_Text = theCanvas.transform.GetChild (9).GetComponent<Text>();
Item10_Deselected_Text = theCanvas.transform.GetChild (10).GetComponent<Text>();
Item11_Deselected_Text = theCanvas.transform.GetChild (11).GetComponent<Text>();
Item0_Selected_Text = theCanvas.transform.GetChild (12).GetComponent<Text>();
Item1_Selected_Text = theCanvas.transform.GetChild (13).GetComponent<Text>();
Item2_Selected_Text = theCanvas.transform.GetChild (14).GetComponent<Text>();
Item3_Selected_Text = theCanvas.transform.GetChild (15).GetComponent<Text>();
Item4_Selected_Text = theCanvas.transform.GetChild (16).GetComponent<Text>();
Item5_Selected_Text = theCanvas.transform.GetChild (17).GetComponent<Text>();
Item6_Selected_Text = theCanvas.transform.GetChild (18).GetComponent<Text>();
Item7_Selected_Text = theCanvas.transform.GetChild (19).GetComponent<Text>();
Item8_Selected_Text = theCanvas.transform.GetChild (20).GetComponent<Text>();
Item9_Selected_Text = theCanvas.transform.GetChild (21).GetComponent<Text>();
Item10_Selected_Text = theCanvas.transform.GetChild (22).GetComponent<Text>();
Item11_Selected_Text = theCanvas.transform.GetChild (23).GetComponent<Text>();
Description_Text = theCanvas.transform.GetChild (24).GetComponent<Text>();
usePrompt.SetActive(false);
inventory.SetActive (false);
InventOpened = false;
inventory_focus = true;
itemUse_focus = false;
usePrompt_focus = false;
}
示例12: FindRootInventoryItems
private static Inventory FindRootInventoryItems(int positionOfSubItems)
{
Inventory inventory = new Inventory();
int depth = 0;
int maxPosition = FindMatchingTagIndex(positionOfSubItems);
for (int position = 0; position < maxPosition; position++)
{
int fullPosition = positionOfSubItems + position;
string lookFor = "[InventoryItem";
if (fullPosition + lookFor.Length > maxPosition)
{
break;
}
string maybeFind = fileBuffer.Substring(fullPosition, lookFor.Length);
if (maybeFind == lookFor)
{
if (depth == 1)
{
inventory.Add(MakeItem(positionOfSubItems + position));
}
}
if (fileBuffer.Substring(fullPosition, 1) == "[")
{
depth++;
}
if (fileBuffer.Substring(fullPosition, 1) == "]")
{
depth--;
}
}
return inventory;
}
示例13: InitWavesTreeView
/// <summary>
/// Initializes the tree view for waves.
/// </summary>
private void InitWavesTreeView()
{
skirmishWavesInventoryInternal = null;
skirmishWavesTreeView.ItemsSource = null;
Inventory waves = skirmishWavesScanner.GetAllWaves();
InventoryItem newItem = new InventoryItem();
newItem.CopyOf = "All Waves";
newItem.SubItems = waves;
Inventory mainInventory = new Inventory();
mainInventory.Add(newItem);
skirmishWavesInventoryInternal = mainInventory;
RefreshTreeView();
}
示例14: CanNotEquipItemIntoTakenSlotIfNoAutoUnequip
public void CanNotEquipItemIntoTakenSlotIfNoAutoUnequip()
{
var inventory = new Inventory();
var item1 = new WeightedItem { Weight = Weight.Heavy, Name = "hello1" };
var item2 = new WeightedItem { Weight = Weight.Heavy, Name = "hello2" };
inventory.Add(item1);
inventory.Add(item2);
Assert.True(inventory.Equip(item1, false));
Assert.Same(inventory.HeavySlotItem, item1);
Assert.False(inventory.Equip(item2, false));
Assert.Same(inventory.HeavySlotItem, item1);
Assert.NotSame(inventory.HeavySlotItem, item2);
Assert.NotNull(inventory.HeavySlotItem);
}
示例15: LoadNewActivity
private void LoadNewActivity(Activity activity)
{
actTitleBox.Text = activity.Name;
actDescriptionBox.Text = activity.Description;
skirmishWavesInventoryInternal = new Inventory();
skirmishWavesInventoryInternal.Add(activity.Root);
MarkSaved();
SaveSkirmishWaves();
RefreshTreeView();
}