本文整理汇总了C#中Inventory.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.AddItem方法的具体用法?C# Inventory.AddItem怎么用?C# Inventory.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory.AddItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start ()
{
state = ShopState.NONE;
shopInventory = GetComponent<Inventory> ();
itemDB = (ItemDatabase)GameObject.Find ("ItemDatabase").GetComponent<ItemDatabase> ();
shopInventory.AddItem (ItemIDs.RADISH_SEEDS, INFINITE);
shopInventory.AddItem (ItemIDs.ONION_SEEDS, INFINITE);
shopInventory.AddItem (ItemIDs.POTATO_SEEDS, INFINITE);
shopInventory.AddItem (ItemIDs.TOMATO_SEEDS, INFINITE);
shopInventory.AddItem (ItemIDs.BEAN_SEEDS, INFINITE);
scrollPos = Vector2.zero;
ResetItemData ();
}
示例2: buyPotion1
public void buyPotion1 () {
MyResources=GameData.MyPlayer.Resources;
if(MyResources[Constants.GOLD_RES]>250){
_inventory= GameObject.Find("Inventory").GetComponent<Inventory>();
_inventory.AddItem(3,1);
_inventory.UseResources(Constants.GOLD_RES,250);
print (MyResources[Constants.GOLD_RES]);
}
}
示例3: Craft
public bool Craft(Inventory inventory)
{
if (inventory.HasItem(m_RequiredItems))
{
inventory.AddItem(m_ItemType);
return true;
}
return false; //not all mats are owned
}
示例4: buyPotion1
public void buyPotion1 () {
print ("Button 1 pressed");
MyResources=GameData.MyPlayer.Resources;
if(MyResources[Constants.GOLD_RES]>=500){
_inventory= GameObject.Find("Inventory").GetComponent<Inventory>();
_inventory.AddItem(7,1);
_inventory.UseResources(Constants.GOLD_RES,500);
print (MyResources[Constants.GOLD_RES]);
}
}
示例5: LuoAseValikko
void LuoAseValikko()
{
// Asevalikko
Inventory inventory = new Inventory();
inventory.Y = Screen.Top - 20;
Add(inventory);
Weapon rynkky = new AssaultRifle(20, 10);
Weapon plasma = new PlasmaCannon(20, 10);
Weapon kanuuna = new Cannon(20,10);
kanuuna.Image = Inventory.ScaleImageDown(kanuuna.Image, 4);
inventory.AddItem(rynkky, rynkky.Image);
inventory.AddItem(plasma, plasma.Image);
inventory.AddItem(kanuuna, kanuuna.Image);
inventory.ItemSelected += AseValittu;
// Valitse pelin aluksi rynkky
inventory.SelectItem(rynkky);
}
示例6: Init
public void Init()
{
emptyInventory = new Inventory (10);
JsonDataHandler json = new JsonDataHandler ();
rubbishItems = json.GetInventoryItemArray ("Rubbish");
fullInventory = new Inventory (rubbishItems.Length);
emptyObserver = new ObserverImpl(emptyInventory);
fullObserver = new ObserverImpl(fullInventory);
((Subject) emptyInventory).AddObserver(emptyObserver);
((Subject) fullInventory).AddObserver(fullObserver);
foreach (InventoryItem item in rubbishItems) {
fullInventory.AddItem(item);
}
}
示例7: OnMouseDown
void OnMouseDown()
{
// itemType = item.Item.ItemType.ToString();
// itemID = item.Item.ItemID;
// Debug.Log (itemID.ToString());
// Debug.Log (itemType);
if(photonView.isMine)
{
inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
if(inventory.AddItem (GetComponent<ItemScript>()))
{
//PhotonNetwork.Destroy (this.gameObject);
//DestroyItem ();
GetComponent<PhotonView>().RPC ("DestroyItem", PhotonTargets.All, null);
}
}
else
{
inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
//item = this.GetComponent<ItemScript>();
ItemScript newItem = tmp.GetComponent<ItemScript>();
//newItem.Item = InventoryManager.Instance.ItemContainer.Consumables[itemID];
//newItem.Item = InventoryManager.Instance.ItemContainer.Weapons[itemID];
newItem.Item = InventoryManager.Instance.ItemContainer.Weapons[itemID];
//newItem.Item = InventoryManager.Instance.ItemContainer.Consumables[findItem];
inventory.AddItem(newItem);
GetComponent<PhotonView>().RPC ("DestroyItem", PhotonTargets.All, null);
Debug.Log (itemID.ToString());
}
}
示例8: DrawModelInEditor
/// <summary>
/// Display the Model in the Editor.</summary>
void DrawModelInEditor(Inventory inventory)
{
for (int i = 0; i < inventory._items.Count; i++)
{
EditorGUILayout.BeginHorizontal("box");
string displayRow = inventory._items[i]._name + "\tx " + inventory._quantities[i];
EditorGUILayout.LabelField(displayRow);
if (GUILayout.Button("+"))
{
inventory.AddItem(inventory._items[i], 1);
EditorUtility.SetDirty(inventory);
EditorGUILayout.EndHorizontal();
break;
}
if (GUILayout.Button("-"))
{
inventory.RemoveItem(inventory._items[i], 1);
EditorUtility.SetDirty(inventory);
EditorGUILayout.EndHorizontal();
break;
}
if (GUILayout.Button("X"))
{
inventory.RemoveItem(inventory._items[i], inventory._quantities[i]);
EditorUtility.SetDirty(inventory);
EditorGUILayout.EndHorizontal();
break;
}
EditorGUILayout.EndHorizontal();
}
if (GUILayout.Button("Reset"))
{
inventory.Reset();
EditorUtility.SetDirty(inventory);
}
}
示例9: InterpretParseInventoryList
public void InterpretParseInventoryList(Inventory inventory, byte[] data)
{
List<ParseInventoryItem> items = new List<ParseInventoryItem>();
BinaryFormatter bb = new BinaryFormatter();
MemoryStream mm = new MemoryStream(data);
items = (List<ParseInventoryItem>)bb.Deserialize(mm);
for (int i = 0; i < items.Count; i++)
{
if(items[i].UniqueItemId.IndexOf("ARMOR") != -1)
{
inventory.AddItem(Storage.LoadbyUniqueId<RPGArmor>(items[i].UniqueItemId, new RPGArmor()), items[i].ItemLevel, items[i].Amount, items[i].isItemViewed);
if(items[i].IsItemEquipped)
{
inventory.EquipItem(items[i].UniqueItemId, items[i].ItemLevel);
}
}
else if(items[i].UniqueItemId.IndexOf("ITEM") != -1)
{
inventory.AddItem(Storage.LoadbyUniqueId<RPGItem>(items[i].UniqueItemId, new RPGItem()), items[i].ItemLevel, items[i].Amount, items[i].isItemViewed);
}
}
}
示例10: MakePotion
// Make a potion out of the ingredients in the cauldron,
// add it into player's inventory and empty the cauldron
void MakePotion()
{
database = GameObject.FindGameObjectWithTag("Item Database").GetComponent<ItemDatabase>();
inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
int redMushrooms = 0;
int greenMushrooms = 0;
int blueMushrooms = 0;
potionCreated = 5; //number based on which potion is created
for (int i=0; i < potionIngredients.Count; i++) {
if (potionIngredients[i].itemID == 0) { // Red mushrooms
redMushrooms += 1;
}
if (potionIngredients[i].itemID == 1){
greenMushrooms += 1;
}
if (potionIngredients[i].itemID == 2){
blueMushrooms += 1;
}
}
print (" Red: "+ redMushrooms + " Green: "+greenMushrooms + " Blue: "+blueMushrooms);
// Health potion
if (redMushrooms == 1 && greenMushrooms == 1 && blueMushrooms == 1) {
potionCreated = 3;
potion = database.items [3];
print ("Health potion");
} else {
// Super Jump potion
if (redMushrooms == 1 && blueMushrooms == 2) {
potionCreated = 4;
potion = database.items [4];
print ("Jump potion");
}
else {
//Fireball potion
if(redMushrooms == 3){
potionCreated = 6;
potion = database.items[5];
print ("Fireball potion");
}
else{
// Useless Potion
potionCreated = 5;
potion = database.items [5];
print ("No potion");
}
}
}
inventory.AddItem(potion.itemID);
//Empty the cauldron
this.potionIngredients.Clear();
//Play animation
playerModel.GetComponent<AnimationController>().CastSpell();
//Play Cauldron bubbling sound
cauldronBubblingSoundEffect = Instantiate (cauldronBubblingSound).gameObject;
Destroy (cauldronBubblingSoundEffect, 2);
//Save inventory
Save();
//Wait for the animation to finish before showing the message
StartCoroutine ("WaitThreeSeconds");
}
示例11: Start
void Start()
{
ef = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>().EquipmentFactory;
inventory = new Inventory();
//Debug.Log("count: " + inventory.Items.Count.ToString());
if (inventory.Items.Count <= 0)
{
int diceroll = Random.Range(1, 5);
if (diceroll <= 3)
{
for (int i = 0; i < diceroll; i++)
{
inventory.AddItem(ef.randomEquipment(2));
}
}
else if (diceroll > 3)
{
inventory.AddItem(ef.randomEquipment(3));
}
}
if(isActive)
{
Activate();
}
}
示例12: ShiftToInventory
public void ShiftToInventory(Item item, Inventory inventoryA, Inventory inventoryB)
{
inventoryB.RemoveItem (item);
inventoryA.AddItem (item);
}
示例13: Attach
public void Attach(Inventory inventory)
{
inventory.AddItem(this);
}
示例14: Start
// Use this for initialization
void Start()
{
mInventory = new Inventory();
mInventory.AddItem("Blooanium", "item_blooanium", (int)Random.Range(36,62), 10);
mInventory.AddItem("Waste", "item_waste", (int)Random.Range(30,50), 13);
mInventory.AddItem("Scrapmetal", "item_scrapmetal", (int)Random.Range(20,300), 5);
mInventory.AddItem("Fuelrods", "item_fuelrods", (int)Random.Range(36,44), 20);
mInventory.AddItem("Potatoes", "item_potatos", (int)Random.Range(128,256), 2);
mInventory.AddItem("Handhelds", "item_handhelds", (int)Random.Range(12,56), 64);
mInventory.AddItem("Pinklabel", "item_pinklabel", (int)Random.Range(2,8), 96);
mInventory.AddItem("Veggies", "item_veggies", (int)Random.Range(12,400), 2);
mNearbyShips = new List<GameObject>();
mLineRenderers = new List<GameObject>();
mCreatedMenuItemsToBeDestroyed = new Stack<GameObject>();
GO_Player = GameObject.Find("Player");
}
示例15: LuoUusiMaailma
void LuoUusiMaailma(InputWindow ikkuna)
{
kentanNimi = ikkuna.InputBox.Text;
Vedikartta = new List<PhysicsObject>();
Gravity = new Vector(0, -900);
LataaKentta(new ColorTileMap( generate(200, 60,kentanNimi) ) );
LisaaNappaimet();
Inventory inventory = new Inventory();
Add(inventory);
yu = new HorizontalLayout();
yu.Spacing = 5;
qq = new VerticalLayout();
foreach (PhysicsObject esine in esineet())
{
inventory.AddItem(esine, kivihakku);
inventory.SelectItem(esine);
}
inventory.Y = Screen.Top - 20;
int luku = RandomGen.NextInt(1, 200);
luopuu(luku);
//luopuu(new Vector kentanPiste = Level.GetRandomPosition());
Camera.Zoom(1.5);
//Camera.ZoomToLevel();
Camera.Follow(pelaaja1);
luojano();
esineet2 = new List<GameObject>();
esineslotit = new List<Widget>();
käsiselecteditem = 1;
GameObject banaanit = new GameObject(35, 35);
banaanit.Image = banaanikuva;
esineet2.Add(banaanit);
GameObject puuhakku = new GameObject(35, 35);
puuhakku.Image = kivihakku;
esineet2.Add(puuhakku);
käsitaso = new List<Widget>();
luoesinevalikko();
}