Esempio n. 1
0
    IEnumerator ApplyKnightDamageIntervalTrial(float damageInterval)
    {
        // Get the GameManager template from test resources.
        GameManager gameManagerTemplate = TestResources.GetAssetByType <GameManager>();

        if (gameManagerTemplate == false)
        {
            Assert.Fail();
            yield break;
        }

        GameManager gameManager = Object.Instantiate(gameManagerTemplate);

        gameManager.damageInterval = damageInterval;

        Knight knight = new GameObject().AddComponent <Knight>();

        knight.Construct(100);
        int startingHitPoints = knight.currentHitPoints;

        if (gameManager.damageInterval > 0f)
        {
            // Wait for half way through the damage interval and test hit point equality
            yield return(new WaitForSeconds(gameManager.damageInterval * 0.5f));

            Assert.AreEqual(startingHitPoints, knight.currentHitPoints);
            // Wait for damage interval and test hit point equality
            // Damage should have been applied
            yield return(new WaitForSeconds(gameManager.damageInterval));

            Assert.AreEqual(startingHitPoints - gameManager.damageAmount, knight.currentHitPoints);
        }
        else
        {
            Assert.AreEqual(startingHitPoints, knight.currentHitPoints);
            yield return(null);

            yield return(null);

            Assert.AreEqual(startingHitPoints - gameManager.damageAmount, knight.currentHitPoints);
        }
    }
Esempio n. 2
0
    public void InstantiateKnight()
    {
        // Get the GameManager template from test resources.
        GameManager gameManagerTemplate = TestResources.GetAssetByType <GameManager>();

        if (gameManagerTemplate == false)
        {
            Assert.Fail();
            return;
        }

        GameManager gameManager = Object.Instantiate(gameManagerTemplate);
        Knight      knight      = null;

        if (gameManager.InstantiateKnightWithTouchInput(new Vector2()))
        {
            knight = Object.FindObjectOfType <Knight>();
        }

        Assert.NotNull(knight);
    }