public void TestAddTemplate() { GameLivingInventory gameLivingInventory = new TestInventory(); ItemTemplate template = new ItemTemplate(); Random rand = new Random(); template.Id_nb = "blankItem" + rand.Next().ToString(); template.Name = "a blank item"; template.MaxCount = 10; if (template == null) Console.WriteLine("template null"); if (gameLivingInventory.AddTemplate(GameInventoryItem.Create<ItemTemplate>(template), 7, eInventorySlot.RightHandWeapon, eInventorySlot.FourthQuiver)) Console.WriteLine("addtemplate 7 blank item"); else Console.WriteLine("can not add 7 blank item"); Console.WriteLine("----PRINT AFTER FIRST ADD 7 TEMPLATE-----"); PrintInventory(gameLivingInventory); if (gameLivingInventory.AddTemplate(GameInventoryItem.Create<ItemTemplate>(template), 4, eInventorySlot.RightHandWeapon, eInventorySlot.FourthQuiver)) Console.WriteLine("addtemplate 4 blank item"); else Console.WriteLine("can not add 4 blank item"); Console.WriteLine("----PRINT AFTER SECOND ADD 4 TEMPLATE-----"); PrintInventory(gameLivingInventory); //here must have 10 item in a slot and 1 in another }
private void Awake() { if (instance != null) { return; } instance = this; }
// Use this for initialization void Start() { inventory = TestInventory.instance; inventory.OnItemChangedCallback += UpdateUI; inventory.OnitemRemoveCallback += ClearSlotUI; slots = itemsParent.GetComponentsInChildren <InventorySlot>(); }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); GM = GameObject.FindGameObjectWithTag("GM"); ti = GM.GetComponent <TestInventory>(); gameOverScript = GM.GetComponent <gameOverText> (); radarCamera.enabled = false; mainCamera.enabled = true; }
public void GetInventory_ShouldReturnInventoryWithSameID() { var context = new TestInventory(); context.InventoryList.Add(GetInventoryItem()); var controller = new InventoriesController(context); var result = controller.GetInventory(3) as OkNegotiatedContentResult <Inventory>; Assert.IsNotNull(result); Assert.AreEqual(3, result.Content.ID); }
private void Start() { inventory = TestInventory.instance; int numSlots = System.Enum.GetNames(typeof(EquipmentSlot)).Length; for (int i = 0; i < numSlots; i++) { currentEquipment.Add(new TestEquipment()); } }
public void DeleteInventory_ShouldReturnOK() { var context = new TestInventory(); var item = GetInventoryItem(); context.InventoryList.Add(item); var controller = new InventoriesController(context); var result = controller.DeleteInventory(3) as OkNegotiatedContentResult <Inventory>; Assert.IsNotNull(result); Assert.AreEqual(item.ID, result.Content.ID); }
public void GetInventoryList_ShouldReturnAllItems() { var context = new TestInventory(); context.InventoryList.Add(new Inventory { ID = 1, Name = "Demo1", Description = "desc1", Price = 20 }); context.InventoryList.Add(new Inventory { ID = 2, Name = "Demo2", Description = "desc2", Price = 30 }); context.InventoryList.Add(new Inventory { ID = 3, Name = "Demo3", Description = "desc3", Price = 40 }); var controller = new InventoriesController(context); var result = controller.GetInventoryList() as TestInventoryDbSet; Assert.IsNotNull(result); Assert.AreEqual(3, result.Local.Count); }
public void TestAddTemplate() { GameLivingInventory gameLivingInventory = new TestInventory(); ItemTemplate template = new ItemTemplate(); Random rand = new Random(); template.Id_nb = "blankItem" + rand.Next().ToString(); template.Name = "a blank item"; template.MaxCount = 10; if (template == null) { Console.WriteLine("template null"); } if (gameLivingInventory.AddTemplate(GameInventoryItem.Create(template), 7, eInventorySlot.RightHandWeapon, eInventorySlot.FourthQuiver)) { Console.WriteLine("addtemplate 7 blank item"); } else { Console.WriteLine("can not add 7 blank item"); } Console.WriteLine("----PRINT AFTER FIRST ADD 7 TEMPLATE-----"); PrintInventory(gameLivingInventory); if (gameLivingInventory.AddTemplate(GameInventoryItem.Create(template), 4, eInventorySlot.RightHandWeapon, eInventorySlot.FourthQuiver)) { Console.WriteLine("addtemplate 4 blank item"); } else { Console.WriteLine("can not add 4 blank item"); } Console.WriteLine("----PRINT AFTER SECOND ADD 4 TEMPLATE-----"); PrintInventory(gameLivingInventory); // here must have 10 item in a slot and 1 in another }
private void Start() { // inventory finds the object in the scene with the tag Player and gets the TestInventory component which is a script Inventory = GameObject.FindGameObjectWithTag("Player").GetComponent <TestInventory>(); }