public void Check_Combine_Method_In_HeroInventory() { var inventory = new HeroInventory(); var item1 = new CommonItem("a", 1, 1, 1, 1, 1); var item2 = new CommonItem("b", 1, 1, 1, 1, 1); var item3 = new CommonItem("c", 1, 1, 1, 1, 1); var item4 = new CommonItem("d", 1, 1, 1, 1, 1); var combine = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b" }); inventory.AddCommonItem(item1); inventory.AddCommonItem(item2); inventory.AddCommonItem(item3); inventory.AddCommonItem(item4); inventory.AddRecipeItem(combine); Type type = inventory.GetType(); FieldInfo[] fieldInfo = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo commonItemsStorage = fieldInfo.First(f => f.GetCustomAttributes <ItemAttribute>() != null); Dictionary <string, IItem> items = (Dictionary <string, IItem>)commonItemsStorage.GetValue(inventory); Assert.AreEqual(3, items.Values.Count); }
public void Chech_Return_Type_Of_Method_TotalDamageBonus() { var inventory = new HeroInventory(); var result = inventory.TotalDamageBonus; Assert.That(result, Is.TypeOf <long>()); }
public void InsertWeapon() { h = GameObject.Find("Explore").GetComponent <HeroInventory> (); if (Wquip.Title == "Man") { h.hW[0].GetComponent <Image>().sprite = recipe.Sprite; PlayerPrefs.SetString("ManW", recipe.Title); if (MW == 0) { int power = PlayerPrefs.GetInt("ManPower"); PlayerPrefs.SetInt("ManOPower", power); MW = 1; } PlayerPrefs.SetInt("ManPower", PlayerPrefs.GetInt("ManOPower") + recipe.Power); h.texture[0].transform.GetChild(1).GetComponent <Text>().text = "power : " + PlayerPrefs.GetInt("ManPower") + "\n" + "defence : " + PlayerPrefs.GetInt("ManDefen") + "\n"; } else if (Wquip.Title == "Woman") { h.hW[1].GetComponent <Image>().sprite = recipe.Sprite; PlayerPrefs.SetString("WomW", recipe.Title); if (WW == 0) { int power = PlayerPrefs.GetInt("WomanPower"); PlayerPrefs.SetInt("WomanOPower", power); WW = 1; } PlayerPrefs.SetInt("WomanPower", PlayerPrefs.GetInt("WomanOPower") + recipe.Power); h.texture[1].transform.GetChild(1).GetComponent <Text>().text = "power : " + PlayerPrefs.GetInt("WomanPower") + "\n" + "defence : " + PlayerPrefs.GetInt("WomanDefen") + "\n"; } }
public void Chech_Add_Recipe_To_Inventory_Without_Making_Item() { HeroInventory heroInventory = new HeroInventory(); var item1 = new CommonItem("a", 1, 1, 1, 1, 1); var item2 = new CommonItem("b", 1, 1, 1, 1, 1); heroInventory.AddCommonItem(item1); heroInventory.AddCommonItem(item2); var combine = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b", "c" }); heroInventory.AddRecipeItem(combine); Type type = heroInventory.GetType(); FieldInfo[] fieldInfo = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo commonItemsStorage = fieldInfo.First(f => f.GetCustomAttributes <ItemAttribute>() != null); Dictionary <string, IItem> items = (Dictionary <string, IItem>)commonItemsStorage.GetValue(heroInventory); Assert.AreEqual(2, items.Count); var item3 = new CommonItem("c", 1, 1, 1, 1, 1); heroInventory.AddCommonItem(item3); Assert.AreEqual(1, items.Values.Count); }
public static void TriggerInitHeroInv(HeroInventory heroInv) { if (InitHeroInv != null) { InitHeroInv(heroInv); } }
public void Init() { this.heroInventory = new HeroInventory(); this.commonItems = heroInventory.GetType().GetField("commonItems", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this.heroInventory) as Dictionary <string, IItem>; this.recipeItems = heroInventory.GetType().GetField("recipeItems", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this.heroInventory) as Dictionary <string, IRecipe>; }
void Start() { hero = PantheonPanelManagerSCR.heroGameObject; heroInventorySCR = hero.GetComponent<HeroInventory> (); spriteManagerSCR = GameObject.FindGameObjectWithTag("SpriteManager").GetComponent<SpriteManager>(); myIndex = transform.GetSiblingIndex (); }
public string AddHero(List <String> arguments) { string result = String.Empty; string heroName = arguments[0]; string heroType = arguments[1]; try { Type typeOfHero = Type.GetType(heroType); var constructors = typeOfHero.GetConstructors(); var inventory = new HeroInventory(); AbstractHero hero = (AbstractHero)constructors[0].Invoke(new object[] { heroName }); this.heroes.Add(heroName, hero); result = string.Format($"Created {heroType} - {hero.Name}"); } catch (Exception e) { return(e.Message); } return(result); }
public void Throw_Exeption_If_AddRecipeItem_Not_Send_Null() { var inventory = new HeroInventory(); Assert.That( () => inventory.AddRecipeItem(null), Throws.InstanceOf <NullReferenceException>()); }
public HeroInventory CreateHeroInventory() { var heroInventory = new HeroInventory( new Dictionary <string, IItem>(), new Dictionary <string, IRecipe>()); return(heroInventory); }
public void NullCommonItemThrowsNullException() { //Arrange var inventory = new HeroInventory(); IItem item = null; //Assert Assert.Throws <NullReferenceException>(() => inventory.AddCommonItem(item)); }
public void WhenCommonItemsCall_ShouldReturnAllCommonItems() { IInventory inv = new HeroInventory(); inv.AddCommonItem(new CommonItem("Item1", 1, 2, 4, 4, 5)); inv.AddCommonItem(new CommonItem("Item2", 5, 4, 3, 2, 1)); Assert.That(inv.CommonItems.Count, Is.EqualTo(2)); }
public void NullRecipeThrowsNullException() { //Arrange var inventory = new HeroInventory(); IRecipe recipe = null; //Assert Assert.Throws <NullReferenceException>(() => inventory.AddRecipeItem(recipe)); }
void Awake() { this.heroInventory = Players.playersList[Players.selectedPlayer].heroInventory; heroSlotContainer = transform.Find("heroSlotContainer"); heroSlotTemplate = heroSlotContainer.Find("heroSlotTemplate"); refreshHeroInventory(); }
public static void TriggerInventoryUIHeroPeak(HeroInventory heroInventory) { if (InventoryUIHeroPeak != null) { InventoryUIHeroPeak(heroInventory); Hero hero = GameManager.instance.findHero(heroInventory.parentHero); TriggerCompleteHeroBoardUpdate(hero); } }
public void WhenAddRecipeItemCall_ShouldCombineCommonItemsInRecipeItem() { IInventory inv = new HeroInventory(); inv.AddCommonItem(new CommonItem("Orb", 1, 2, 4, 4, 5)); inv.AddCommonItem(new CommonItem("Staff", 5, 4, 3, 2, 1)); inv.AddRecipeItem(new RecipeItem("Ring", 10, 10, 10, 10, 10, "Orb", "Staff")); Assert.That(inv.CommonItems.Count, Is.EqualTo(1)); }
public void InitializeInventory() { this.inventory = new HeroInventory(); this.itemForTests = new CommonItem("Knife", 1, 2, 3, 4, 5); this.itemForTests2 = new CommonItem("Gun", 5, 4, 3, 2, 1); this.recipeForTest1 = new RecipeItem("Res", 1, 2, 3, 4, 5, new List <string>() { "Knife", "Gun" }); }
public void AddItem_ShouldChangeStrengthBonus() { var inventory = new HeroInventory(); var item1 = new CommonItem("Staff", 20, 10, 50, 100, 2000); var expected = 20; inventory.AddCommonItem(item1); Assert.AreEqual(expected, inventory.TotalStrengthBonus); }
public void Chech_If_Recipe_Name_Is_Set_Correct() { var inventory = new HeroInventory(); var itemA = new RecipeItem("A", 1, 2, 3, 4, 5, new List <string>()); inventory.AddRecipeItem(itemA); Assert.AreEqual("A", itemA.Name); }
public void Throll_Exeption_On_Adding_Items_With_Same_Name() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 1, 1, 1); var itemB = new CommonItem("A", 1, 1, 1, 1, 1); inventory.AddCommonItem(itemA); Assert.Throws <ArgumentException>(() => inventory.AddCommonItem(itemB)); }
public void Totall_Agility_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 13, 2, 1); var itemB = new CommonItem("B", 1, 1, 2, 3, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(2, inventory.TotalAgilityBonus); }
public void Totall_Damage_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 2, 3, 4, 5); var itemB = new CommonItem("B", 6, 7, 8, 9, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(6, inventory.TotalDamageBonus); }
private void Awake() { DontDestroyOnLoad(gameObject); if (instance != null) { Destroy(gameObject); return; } instance = this; }
public void Totall_HitPoints_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 1, 1, 1); var itemB = new CommonItem("B", 1, 1, 1, 1, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(2, inventory.TotalHitPointsBonus); }
public void Chech_If_Item_Name_Is_Set_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 2, 3, 4, 5); inventory.AddCommonItem(itemA); Assert.AreEqual("A", itemA.Name); }
public void Totall_Strenth_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 2, 3, 4, 5); var itemB = new CommonItem("B", 6, 7, 8, 9, 0); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(7, inventory.TotalStrengthBonus); }
public void Totall_Intelligence_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 2, 2, 1); var itemB = new CommonItem("B", 1, 1, 13, 13, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(15, inventory.TotalIntelligenceBonus); }
public void NewInventoryStatsEqualsZero() { sut = new HeroInventory(); long totalStatsValue = sut.TotalAgilityBonus + sut.TotalStrengthBonus + sut.TotalIntelligenceBonus + sut.TotalHitPointsBonus + sut.TotalDamageBonus; Assert.IsTrue(totalStatsValue == 0); }
// public Animator buttonMenuAnimator; void Start() { instance = this; heroInventory = HeroInventory.instance; slots = slotHolder.GetComponentsInChildren <HeroSlot>(); heroInventory.onHeroSlotCountChange += slotChange; heroInventory.onChangeHeroData += redrawSlotUI; heroIllust = heroSet.transform.GetChild(1).gameObject.GetComponent <Image>(); heroName = heroSet.transform.GetChild(2).GetChild(0).gameObject.GetComponent <TMPro.TextMeshProUGUI>(); heroSet.SetActive(false); }
public void InitialTest() { inventory = new HeroInventory(); item = new CommonItem("Knife", 1, 1, 1, 1, 1); item2 = new CommonItem("Stick", 2, 2, 2, 2, 2); recipe = new RecipeItem("Spear", 10, 10, 10, 10, 10, new List <string> { "Knife", "Stick" }); recipe = new RecipeItem("Oculus", 10, 10, 10, 10, 10, new List <string> { "Knife", "Stick" }); }
public void NewInventoryStatsAreZero() { this.sut = new HeroInventory(); long totalStatsBonus = this.sut.TotalAgilityBonus + this.sut.TotalStrengthBonus + this.sut.TotalIntelligenceBonus + this.sut.TotalHitPointsBonus + this.sut.TotalDamageBonus; Assert.AreEqual(0, totalStatsBonus); }