public IEnumerator Test_DoorControlKnowsItsEnemies() { GameObject enemies = CreateEnemiesToWaitFor(2); DoorControl door = CreateDoorControl(enemies, new Vector3(1, 1, 1)); yield return(new WaitForEndOfFrame()); Assert.IsNotNull(door.GetEnemies(), "Enemies to wait for were not correctly initialized!"); Assert.NotZero(door.GetEnemies().Count, "Door Control did not find any enemies!"); Assert.IsTrue(door.GetEnemies().Count == 2, "Door Control did not know all of the enemies it should!"); }
public IEnumerator Test_LastDyingEnemySpawnsKeyDrop() { GameObject enemies = CreateEnemiesToWaitFor(2); DoorControl door = CreateDoorControl(enemies, new Vector3(1, 1, 1)); Player player = CreatePlayer(); GameController gameCtr = CreateGameController(player); yield return(new WaitForEndOfFrame()); Enemy firstEnemy = door.GetEnemies()[0]; Enemy secondEnemy = door.GetEnemies()[1]; gameCtr.StartBattle(firstEnemy); firstEnemy.stats.ReceiveDamage(firstEnemy.stats.GetMaxHealth()); yield return(new WaitForEndOfFrame()); ItemDrop[] foundDrops1 = GameObject.FindObjectsOfType <ItemDrop>(); Assert.IsTrue(foundDrops1.Length == 1, "Key Drop was spawned by wrong enemy!"); gameCtr.StartBattle(secondEnemy); secondEnemy.stats.ReceiveDamage(secondEnemy.stats.GetMaxHealth()); yield return(new WaitForEndOfFrame()); ItemDrop[] foundDrops2 = GameObject.FindObjectsOfType <ItemDrop>(); ItemDrop found = null; foreach (ItemDrop drop in foundDrops2) { if (drop.name.Contains("(Clone)")) { found = drop; } } Assert.IsTrue(foundDrops2.Length == 2, "Key Drop was not spawned by right enemy!"); Assert.IsNotNull(found, "No Key Drop clone was found!"); }
public IEnumerator Test_DoorControlInformsDyingEnemyWetherTheyAreTheLast() { GameObject enemies = CreateEnemiesToWaitFor(2); DoorControl door = CreateDoorControl(enemies, new Vector3(1, 1, 1)); Player player = CreatePlayer(); GameController gameCtr = CreateGameController(player); yield return(new WaitForEndOfFrame()); Enemy firstEnemy = door.GetEnemies()[0]; Enemy secondEnemy = door.GetEnemies()[1]; gameCtr.StartBattle(firstEnemy); firstEnemy.stats.ReceiveDamage(firstEnemy.stats.GetMaxHealth()); Assert.IsFalse(door.CheckIfLastEnemy(), "Door Control told the wrong enemy that they are the last!"); yield return(new WaitForEndOfFrame()); gameCtr.StartBattle(secondEnemy); secondEnemy.stats.ReceiveDamage(secondEnemy.stats.GetMaxHealth()); Assert.IsTrue(door.CheckIfLastEnemy(), "Door Control did not tell the right enemy that they are the last!"); }