Esempio n. 1
0
 // function called when an item button on the items panel is pressed
 void selectItem(InventoryItems.itemTypes itemType)
 {
     selectAbility(InventoryItems.itemAbility(itemType));
     if (InventoryItems.itemConsumedOnUse(itemType))
     {
         state.changeItem(itemType, -1);
     }
 }
Esempio n. 2
0
    public IEnumerator InventoryTestSimplePasses()
    {
        // A simple test to check that inventory items return the correct attack when used
        //Based on Evil Geese's preexisting combat test and GameStateTest
        setupGameStateManagerForTests();
        yield return(null);

        GameStateManager state = GameStateManager.getGameStateManager();

        state.state = new GameState();         //reset the gamestate

        InventoryItems.itemTypes[] items = (InventoryItems.itemTypes[])Enum.GetValues(typeof(InventoryItems.itemTypes));


        CombatCharacter c1 = new CombatCharacter(100, 100, 100, 100, new SimpleAttack(20, 20, "melee"));
        CombatCharacter c2 = new CombatCharacter(100, 100, 100, 100, InventoryItems.itemAbility(items[0]));

        Assert.AreEqual(100, c1.health);
        List <CombatCharacter> l = new List <CombatCharacter> ();

        l.Add(c1);
        c2.basicAttack.doAbility(l, c2);
        Assert.AreEqual(85, c1.health);
    }