示例#1
0
	public void EquipTest()
	{
		// Arrange
		BaseItem equipableItem = createTestItem();

		EquipableCategory equipableCategory = (EquipableCategory) equipableItem.GetItemCategoryByClass(typeof(EquipableCategory));

		equipableCategory.Equip();

		Assert.AreEqual(Game.Instance.PlayerInstance.Inventory.EquipedItem, equipableItem);
		Assert.AreEqual(equipableItem.GetItemAttribute("equiped").Value, 1f);

		equipableCategory.UnEquip();

		Assert.AreEqual(Game.Instance.PlayerInstance.Inventory.EquipedItem, null);
		Assert.AreEqual(equipableItem.GetItemAttribute("equiped").Value, 0);
	}
示例#2
0
	private BaseItem createTestItem()
	{
		PlayerInventory mockPlayerInventory = new PlayerInventory("player", 20);
		Game.Instance.PlayerInstance = new Player(mockPlayerInventory);

		BaseItem equipableItem = new BaseItem("Sample Equipable");
		equipableItem.FlavorText = "This is a test equipable";
		equipableItem.InventorySprite = "equipable.png";
		equipableItem.WorldModel = "equipableModel.png";
		equipableItem.Types = new List<string>();
		equipableItem.Types.Add(ItemTypes.Equipable);

		EquipableCategory equipable = new EquipableCategory ();
		equipable.Equiped = 0f;

		equipableItem.AddItemCategory(equipable);

		return equipableItem;
	}
    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);
    }