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(); } }
public void Test_EnemyStatsHasDeclaredOwnShowDodgeFunction() { EnemyStatsClass stats = new EnemyStatsClass(); stats.ShowDodge(); LogAssert.NoUnexpectedReceived(); }
public bool TakesPartInCurrentBattle(EnemyStatsClass enemy) { foreach (Enemy e in GetCurrentEnemies()) { if (e.stats == enemy) { return(true); } } return(false); }
public void Test_ItemCanDamageEnemies() { EnemyStatsClass stats = new EnemyStatsClass(); IGameController gameCtr = Substitute.For <IGameController>(); gameCtr.When(x => x.PlayerThrowBomb()).Do(x => stats.ReceiveDamage(10)); Item item = ScriptableObject.CreateInstance <Item>(); item.type = ItemType.DealDamage; item.Use(stats, gameCtr); int damagedHealth = stats.GetCurrentHealth(); Assert.Less(damagedHealth, stats.GetMaxHealth(), "Using a bomb item did not decrease the enemies health!"); }
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!"); }
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!"); }