Exemplo n.º 1
0
    void Start()
    {
        if (GameCtr == null)
        {
            GameCtr = FindObjectOfType <GameController>();
        }

        if (stats == null)
        {
            stats = new EnemyStatsClass();
        }
        stats.SetUpEnemyStats(GameCtr);

        if (healthBar != null)
        {
            healthBar.transform.parent.gameObject.SetActive(false);
        }
        if (turnTimeBar != null)
        {
            turnTimeBar.transform.parent.gameObject.SetActive(false);
        }
        if (stats.dodged != null)
        {
            stats.dodged.SetActive(false);
        }
        if (staticService == null)  // only setup staticServe anew if it's not there already (a playmode test might have set a substitute object here that we don't want to replace)
        {
            staticService = new UnityStaticService();
        }
    }
Exemplo n.º 2
0
    public void Test_PlayerGainsPointsAfterKillingAnEnemy()
    {
        PlayerStatsClass player = new PlayerStatsClass();

        player.AttackDamage = 500;
        IGameController mockController = Substitute.For <IGameController>();

        mockController.GetPlayerStats().Returns(player);
        EnemyStatsClass enemy = new EnemyStatsClass();

        enemy.SetUpEnemyStats(mockController);


        int pointsBefore = player.GetCurrentPoints();

        player.AttackOpponent(enemy, false, true);
        int pointsAfter = player.GetCurrentPoints();

        Assert.Greater(pointsAfter, pointsBefore, "Player did not receive any points after killing an enemy!");
    }
Exemplo n.º 3
0
    public void Test_PlayerGainsNoPointsAfterTryingToKillADeadEnemy()
    {
        PlayerStatsClass player = new PlayerStatsClass();

        player.AttackDamage = 500;
        IGameController mockController = Substitute.For <IGameController>();

        mockController.GetPlayerStats().Returns(player);
        EnemyStatsClass enemy = new EnemyStatsClass();

        enemy.SetUpEnemyStats(mockController);


        player.AttackOpponent(enemy, false, true);
        int pointsAfterFirstKill = player.GetCurrentPoints();

        player.AttackOpponent(enemy, false, true);
        int pointsAfterSecondKill = player.GetCurrentPoints();

        Assert.AreEqual(pointsAfterFirstKill, pointsAfterSecondKill, "Player received points after trying to kill an enemy that's already dead!");
        LogAssert.Expect(LogType.Warning, "Fighter tried to attack an opponent that already died. Can't attack dead opponents!");
    }