Esempio n. 1
0
    public void Test_PlayerStartsWithEmptyInventory()
    {
        PlayerInventoryClass inventory = new PlayerInventoryClass();

        Assert.IsEmpty(inventory.GetCollectedItems(), "Player didn't start with an empty inventory!");
        Assert.IsNull(inventory.GetEquippedWeapon(), "Player didn't start without a weapon!");
    }
Esempio n. 2
0
    public void Test_PlayerCanEquipWeapon()
    {
        Weapon weapon = ScriptableObject.CreateInstance <Weapon>();
        PlayerInventoryClass inventory = new PlayerInventoryClass();

        inventory.EquipWeapon(weapon);

        Assert.IsNotNull(inventory.GetEquippedWeapon(), "Player didn't equip a weapon!");
    }
Esempio n. 3
0
    public void Test_PlayerReceivesDamageIncreaseFromEquippedWeapon()
    {
        Weapon               weapon    = ScriptableObject.CreateInstance <Weapon>();
        PlayerStatsClass     stats     = new PlayerStatsClass();
        PlayerInventoryClass inventory = new PlayerInventoryClass();

        int damageWithoutWeapon = stats.GetCurrentAttackDamage();

        inventory.EquipWeapon(weapon);

        IPlayer mockPlayer = Substitute.For <IPlayer>();

        mockPlayer.GetAllDamageBonus().Returns(inventory.GetEquippedWeapon().damage);
        stats.SetPlayerAddition(mockPlayer);

        int damageAfterEquip = stats.GetCurrentAttackDamage();

        Assert.IsNotNull(inventory.GetEquippedWeapon(), "Player didn't equip the weapon!");
        Assert.Greater(damageAfterEquip, damageWithoutWeapon, "Player damage did not increase after equipping a weapon!");
    }
Esempio n. 4
0
    public int GetAllDamageBonus()
    {
        int bonus = 0;

        if (inventory != null)
        {
            Weapon wpn = inventory.GetEquippedWeapon();
            if (wpn != null)
            {
                bonus += wpn.damage;
            }
        }

        return(bonus);
    }