public IEnumerator PlayerCombat_MeleePlayerCanDamageEnemyWithPrimaryAndSecondaryAttacks() { GameObject meleePlayer = Object.Instantiate(TestResourceManager.Instance.GetResource("Melee Player"), Vector3.zero, Quaternion.identity); PlayerStatsController meleePlayerStats = meleePlayer.GetComponent <PlayerStatsController>(); GameObject enemy = Object.Instantiate(TestResourceManager.Instance.GetResource("Enemy"), Vector3.zero, Quaternion.identity); EnemyStatsController enemyStats = enemy.GetComponent <EnemyStatsController>(); Vector3 attackPos = new Vector3(0, 0, -2.5f); meleePlayer.SetActive(true); enemy.SetActive(true); var input = meleePlayer.GetComponent <PlayerInput>(); input.enabled = true; _inputMock.SetInputToMockGamepad(input); meleePlayer.transform.position = attackPos; float initialHealth = enemyStats.health.CurrentValue; enemyStats.characterColour = meleePlayerStats.characterColour; yield return(new WaitForSeconds(0.5f)); // Player attacks with primary attack _inputMock.Press(_inputMock.Gamepad.rightShoulder); yield return(new WaitForSeconds(1f)); _inputMock.Release(_inputMock.Gamepad.rightShoulder); yield return(new WaitForSeconds(1f)); Assert.Less(enemyStats.health.CurrentValue, initialHealth, "Melee player was unable to damage the enemy with primary attack!"); initialHealth = enemyStats.health.CurrentValue; // Player attacks with secondary attack _inputMock.Press(_inputMock.Gamepad.rightTrigger); yield return(new WaitForSeconds(1f)); _inputMock.Release(_inputMock.Gamepad.rightTrigger); yield return(new WaitForSeconds(1f)); Assert.Less(enemyStats.health.CurrentValue, initialHealth, "Melee player was unable to damage the enemy with secondary attack!"); }
public IEnumerator PlayerCharacter_MoveToTheRightWithLeftJoystick() { GameObject player = Object.Instantiate(TestResourceManager.Instance.GetResource("Mage Player"), Vector3.zero, Quaternion.identity); Vector3 initialPos = player.transform.position; PlayerInput input = player.GetComponent <PlayerInput>(); _inputMock.SetInputToMockGamepad(input); _inputMock.Press(_inputMock.Gamepad.leftStick, Vector2.right); yield return(new WaitForSeconds(1f)); _inputMock.Release(_inputMock.Gamepad.leftStick, Vector2.zero); Assert.Greater(player.transform.position.x, initialPos.x, "Player did not move to the right on input"); Assert.AreEqual(player.transform.rotation.eulerAngles.y, 90f, 1f, "Player did not look in the direction of travel"); }