Esempio n. 1
0
    public IEnumerator Test_ItemDropCannotBeCollectedIfNotYetInInventoryAndNoFreeSlot()
    {
        Player   player = CreatePlayer();
        ItemDrop drop   = CreateItemDrop();

        drop.droppedItem.type = ItemType.AttackBoost;
        ItemDrop drop1 = CreateItemDrop();

        drop1.droppedItem.type        = ItemType.Healing;
        player.inventory.MaxItemSlots = 1;

        yield return(new WaitForEndOfFrame());

        drop.PlayerCollectItem();

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(player.inventory.PlayerHasItem(drop.droppedItem), "Player did not collect the first item!");

        drop1.PlayerCollectItem();

        yield return(new WaitForEndOfFrame());

        Assert.IsFalse(player.inventory.PlayerHasItem(drop1.droppedItem), "Player was able to collect the second item even though there was no space!");
    }
Esempio n. 2
0
    public IEnumerator Test_ItemDropGetsRemovedAfterBeingCollected()
    {
        Player   player = CreatePlayer();
        ItemDrop drop   = CreateItemDrop();

        drop.player = player;

        yield return(new WaitForEndOfFrame());

        drop.PlayerCollectItem();

        yield return(new WaitForEndOfFrame());

        ItemDrop[] foundDrops = GameObject.FindObjectsOfType <ItemDrop>();

        Assert.Zero(foundDrops.Length, "Item drop was not deleted after collecting it!");
    }
Esempio n. 3
0
    public IEnumerator Test_ItemDropIncreasesUsesIfItemAlreadyInInventory()
    {
        Player   player = CreatePlayer();
        ItemDrop drop   = CreateItemDrop();

        player.inventory.CollectItem(drop.droppedItem);

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(player.inventory.PlayerHasItem(drop.droppedItem), "Player did not collect the item the first time!");
        Assert.AreEqual(drop.droppedItem.GetMaxUses(), player.inventory.items[0].GetUsesLeft(), "Item uses were not correct even though nothing happened!");

        drop.PlayerCollectItem();

        yield return(new WaitForEndOfFrame());

        Assert.AreEqual(1, player.inventory.items.Count, "Item was collected a second time instead of increasing uses of existing item!");
        Assert.AreEqual(drop.droppedItem.GetMaxUses() * 2, player.inventory.items[0].GetUsesLeft(), "Item uses of existing item were increased by the right amount!");
    }
    public IEnumerator Test_SoundWhenCollectingKey()
    {
        SoundEffectControl sfx     = CreateSFXControl(EffectToTest.keyPickUp);
        Player             player  = CreatePlayer();
        GameController     gameCtr = CreateGameController(player);

        gameCtr.sfxControl = sfx;
        ItemDrop drop = CreateItemDrop(true);

        drop.player = player;

        yield return(new WaitForEndOfFrame());

        drop.PlayerCollectItem();

        yield return(new WaitForEndOfFrame());

        Assert.IsTrue(sfx.playerSource.isPlaying, "Player audio source did not play anything!");
        Assert.AreEqual(sfx.keyPickUp, sfx.playerSource.clip, "Player audio source did not play the right track!");
    }
Esempio n. 5
0
    public void OnTriggerEnter(Collider other)
    {
        Enemy enemy = other.gameObject.GetComponent <Enemy>();

        if (enemy != null)
        {
            GameCtr.StartBattle(enemy);
        }

        ItemDrop itemDrop = other.gameObject.GetComponent <ItemDrop>();

        if (itemDrop != null)
        {
            itemDrop.PlayerCollectItem();
        }

        TeleportToPosition teleport = other.gameObject.GetComponent <TeleportToPosition>();

        if (teleport != null)
        {
            teleport.PlayerTeleport();
        }
    }