public void CreateItemInInventory(Item.ItemType itemType) { if (itemCount > itemCap - 1) { return; } if (itemType == Item.ItemType.FirstAidKit) { items[itemCount] = new FirstAidKit(0, 0); itemCount = itemCount + 1; } if (itemType == Item.ItemType.Shield) { items[itemCount] = new Shield(0, 0); itemCount = itemCount + 1; } if (itemType == Item.ItemType.BrassKnuckles) { items[itemCount] = new Weapon(0, 0, itemType); itemCount = itemCount + 1; } if (itemType == Item.ItemType.BaseballBat) { items[itemCount] = new Weapon(0, 0, itemType); itemCount = itemCount + 1; } if (itemType == Item.ItemType.Knife) { items[itemCount] = new Weapon(0, 0, itemType); itemCount = itemCount + 1; } if (itemType == Item.ItemType.Machete) { items[itemCount] = new Weapon(0, 0, itemType); itemCount = itemCount + 1; } if (itemType == Item.ItemType.Chainsaw) { items[itemCount] = new Weapon(0, 0, itemType); itemCount = itemCount + 1; } }
private void GiveItem() { Item newItem; switch (itemType) { case ItemType.Shield: newItem = new Shield(0, 0); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; case ItemType.FirstAidKit: newItem = new FirstAidKit(0, 0); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; case ItemType.BaseballBat: newItem = new Weapon(0, 0, ItemType.BaseballBat); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; case ItemType.BrassKnuckles: newItem = new Weapon(0, 0, ItemType.BrassKnuckles); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; case ItemType.Chainsaw: newItem = new Weapon(0, 0, ItemType.Chainsaw); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; case ItemType.Knife: newItem = new Weapon(0, 0, ItemType.Knife); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; case ItemType.Machete: newItem = new Weapon(0, 0, ItemType.Machete); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; default: newItem = new FirstAidKit(0, 0); itemManager.AddBoughtItem(newItem); newItem.pickedUp = true; break; } newItem.Bought(); }
public void InitItemFromWorldLoc(char[,] world, int X, int Y) { if (itemCount > itemCap - 1) { return; } if (world[X, Y] == Global.firstAidAppearance) { items[itemCount] = new FirstAidKit(X, Y); itemCount = itemCount + 1; } if (world[X, Y] == Global.keyAppearance) { items[itemCount] = new Key(X, Y); itemCount = itemCount + 1; } if (world[X, Y] == Global.shieldAppearance) { items[itemCount] = new Shield(X, Y); itemCount = itemCount + 1; } if (world[X, Y] == Global.valuableAppearance) { items[itemCount] = new Valuable(X, Y); itemCount = itemCount + 1; valuableCount++; } //for Different weapon types if (world[X, Y] == '1') { items[itemCount] = new Weapon(X, Y, Item.ItemType.BrassKnuckles); itemCount = itemCount + 1; } if (world[X, Y] == '2') { items[itemCount] = new Weapon(X, Y, Item.ItemType.BaseballBat); itemCount = itemCount + 1; } if (world[X, Y] == '3') { items[itemCount] = new Weapon(X, Y, Item.ItemType.Knife); itemCount = itemCount + 1; } if (world[X, Y] == '4') { items[itemCount] = new Weapon(X, Y, Item.ItemType.Machete); itemCount = itemCount + 1; } if (world[X, Y] == '5') { items[itemCount] = new Weapon(X, Y, Item.ItemType.Chainsaw); itemCount = itemCount + 1; } }