public void CookTest()
    {
        // Arrange
        BaseItem fleshItem = createTestItem();

        FleshCategory fleshCategory = (FleshCategory)fleshItem.GetItemCategoryByClass(typeof(FleshCategory));

        float expectedHealthEffect1 = fleshCategory.HealthEffect + 0.25f;
        float expectedHungerGain1   = fleshCategory.HungerGain * 1.25f;
        float expectedHealthEffect2 = expectedHealthEffect1 - 0.25f;
        float expectedHungerGain2   = expectedHungerGain1 * 0.5f;

        // Act
        fleshCategory.Cook();

        // Check
        Assert.AreEqual(expectedHealthEffect1, fleshCategory.HealthEffect);
        Assert.AreEqual(expectedHungerGain1, fleshCategory.HungerGain);
        Assert.AreEqual("Cooked Sample Flesh", fleshItem.ItemName);
        Assert.True(fleshItem.Types.Contains(ItemTypes.Edible));
        Assert.AreEqual(1, fleshItem.Types.Count);
        Assert.AreEqual("modifiedFlesh.png", fleshItem.InventorySprite);
        Assert.AreEqual("modifiedFleshModel.png", fleshItem.WorldModel);

        // Check the second time it cooks that it becomes burnt
        fleshCategory.Cook();

        Assert.AreEqual(expectedHealthEffect2, fleshCategory.HealthEffect);
        Assert.AreEqual(expectedHungerGain2, fleshCategory.HungerGain);
        Assert.AreEqual("Burnt Sample Flesh", fleshItem.ItemName);
        Assert.True(fleshItem.Types.Contains(ItemTypes.Fuel));
        Assert.AreEqual(1, fleshItem.Types.Count);
    }
    public void EatTest()
    {
        BaseItem neutralFlesh = createTestItem();
        BaseItem spoiledFlesh = createTestItem();

        FleshCategory neutralFleshCategory = (FleshCategory)neutralFlesh.GetItemCategoryByClass(typeof(FleshCategory));
        FleshCategory spoiledFleshCategory = (FleshCategory)spoiledFlesh.GetItemCategoryByClass(typeof(FleshCategory));

        spoiledFleshCategory.HealthEffect = -0.1f;

        //Act
        neutralFleshCategory.Eat();
        spoiledFleshCategory.Eat();
    }
    private BaseItem createTestItem()
    {
        PlayerInventory mockPlayerInventory = new PlayerInventory("player", 20);

        PlayerController controller = new GameObject().AddComponent <PlayerController>();

        controller.PlayerStatManager = new PlayerStatManager();

        Game.Instance.PlayerInstance               = new Player(mockPlayerInventory);
        Game.Instance.PlayerInstance.Controller    = controller;
        GuiInstanceManager.ItemAmountPanelInstance = new GameObject().AddComponent <ChooseItemAmountPanelBehavior>();
        GuiInstanceManager.ItemAmountPanelInstance.CurrentAmount = 1;

        BaseItem fleshItem = new BaseItem("Sample Flesh");

        fleshItem.FlavorText      = "This is a test flesh";
        fleshItem.InventorySprite = "flesh.png";
        fleshItem.WorldModel      = "fleshModel.png";
        fleshItem.Types           = new List <string>();
        fleshItem.Types.Add(ItemTypes.Edible);
        fleshItem.ModifyingActionNames = new List <string> {
            "Cook"
        };
        fleshItem.ActionModifiedSprites = new List <string> {
            "modifiedFlesh.png"
        };
        fleshItem.ActionModifiedModels = new List <string> {
            "modifiedFleshModel.png"
        };

        FleshCategory flesh = new FleshCategory();

        flesh.HealthEffect = 0.1f;
        flesh.HungerGain   = 0.2f;

        fleshItem.AddItemCategory(flesh);

        return(fleshItem);
    }
Пример #4
0
    private BaseItem createTestItem()
    {
        PlayerInventory  mockPlayerInventory = new PlayerInventory("player", 20);
        PlayerController controller          = new GameObject().AddComponent <PlayerController>();

        Game.Instance.PlayerInstance            = new Player(mockPlayerInventory);
        Game.Instance.PlayerInstance.Controller = controller;
        BaseItem item = new BaseItem("Sample Item");

        item.FlavorText      = "This is a test item";
        item.InventorySprite = "item.png";
        item.WorldModel      = "itemWorld.png";
        item.Types           = new List <string>();
        item.Types.Add(ItemTypes.BaseSolid);
        item.Types.Add(ItemTypes.Rod);

        SolidCategory solid = new SolidCategory();

        solid.Durability  = 0.1f;
        solid.Elasticity  = 0.2f;
        solid.Flexibility = 0.3f;
        solid.Sharpness   = 0.4f;
        solid.Stickiness  = 0.5f;
        solid.Thickness   = 0.6f;

        PlantCategory plant = new PlantCategory();

        plant.PneumoniaEffect = 0.1f;
        plant.StomachEffect   = 0.2f;
        plant.Toughness       = 0.3f;
        plant.WaterContent    = 0.4f;

        FleshCategory flesh = new FleshCategory();

        flesh.HealthEffect = 0.1f;
        flesh.HungerGain   = 0.2f;

        ContainerCategory container = new ContainerCategory();

        container.Size = 1;

        MedicineCategory medicine = new MedicineCategory();

        medicine.HealthGain = 5f;
        medicine.Sickness   = "all";

        ClothCategory cloth = new ClothCategory();

        cloth.FabricThickness = 0.5f;
        cloth.Impermiability  = 1f;
        cloth.ThreadDensity   = 0.3f;
        cloth.OnPlayer        = 0f;

        FuelCategory fuel = new FuelCategory();

        fuel.BurnTime = 5f;

        FireBaseCategory fire = new FireBaseCategory();

        fire.BurnRateMultiplier = 1f;
        fire.FuelRemaining      = 10f;
        fire.StartingFuel       = 10f;

        ShelterCategory shelter = new ShelterCategory();

        shelter.WarmthRate = 2;

        RaftCategory raft = new RaftCategory();

        raft.Speed         = 1f;
        raft.InventorySize = 5;

        WarmthIdolCategory warmthIdol = new WarmthIdolCategory();

        warmthIdol.Equiped       = 0f;
        warmthIdol.WarmthBenefit = 1;

        LightCategory light = new LightCategory();

        light.Brightness       = 2f;
        light.BurnRate         = 0.75f;
        light.CurrentFuelLevel = 3f;
        light.MaxFuel          = 5f;

        EquipableCategory equipable = new EquipableCategory();

        equipable.Equiped = 0f;

        item.AddItemCategory(solid);
        item.AddItemCategory(plant);
        item.AddItemCategory(flesh);
        item.AddItemCategory(container);
        item.AddItemCategory(medicine);
        item.AddItemCategory(cloth);
        item.AddItemCategory(fuel);
        item.AddItemCategory(fire);
        item.AddItemCategory(shelter);
        item.AddItemCategory(raft);
        item.AddItemCategory(warmthIdol);
        item.AddItemCategory(light);
        item.AddItemCategory(equipable);

        return(item);
    }