public IEnumerator _11RangedEnemyProjectileHasCorrectLocalScaleRight() { necromancerObject = Spawner.SpawnNecromancer(0, 0.3f); necromancer = necromancerObject.GetComponent <RangedEnemyController>(); yield return(null); necromancer.FireProjectile(); yield return(null); var necromancerProjectile = GameObject.Find("NecromancerProjectile(Clone)"); Assert.AreEqual(necromancerProjectile.transform.localScale.x, necromancerObject.transform.localScale.x); }
public IEnumerator _10RangedEnemyShootProjectile() { necromancerObject = Spawner.SpawnNecromancer(0, 0.5f); necromancer = necromancerObject.GetComponent <RangedEnemyController>(); yield return(null); necromancer.FireProjectile(); yield return(null); var necromancerProjectile = GameObject.Find("NecromancerProjectile(Clone)"); Assert.IsNotNull(necromancerProjectile); }
private void Start() { if (meleeEnemy) { melee = gameObject.GetComponentInParent <MeleeEnemyController>(); } if (rangedEnemy) { ranged = gameObject.GetComponentInParent <RangedEnemyController>(); } if (kultist) { kk = gameObject.GetComponentInParent <KultistController>(); } }
public IEnumerator _13RangedEnemyProjectileDisappearsWhenFar() { necromancerObject = Spawner.SpawnNecromancer(0, 0.5f); necromancer = necromancerObject.GetComponent <RangedEnemyController>(); yield return(null); necromancer.FireProjectile(); yield return(null); var necromancerProjectile = GameObject.Find("NecromancerProjectile(Clone)"); Assert.IsNotNull(necromancerProjectile); necromancerProjectile.transform.position = new Vector3(101, 0, 0); yield return(null); //for update() to run Assert.IsTrue(necromancerProjectile == null); }
public IEnumerator _09RangedMoveAwayFromPlayerAtCorrectSpeed() { playerObject = Spawner.SpawnPlayer(-1, 0.5f); necromancerObject = Spawner.SpawnNecromancer(0, 0.5f); necromancer = necromancerObject.GetComponent <RangedEnemyController>(); var originalNecromancerXPos = necromancer.GetPosition().x; Assert.AreEqual(originalNecromancerXPos, 0); Debug.Log("First assert passed"); yield return(new WaitForSeconds(1.0f)); //It should move towards (24,?) where the player is var newNecromancerXPos = necromancer.GetPosition().x; Debug.Log(newNecromancerXPos); var expectedXPos = originalNecromancerXPos + necromancer.baseSpeed * necromancer.backwardsSpeedMod; Assert.IsTrue(newNecromancerXPos > expectedXPos - 0.1 && newNecromancerXPos < expectedXPos + 0.1); //speed should be slower than the original speed so the plaeyr can ctach up more easily }
//if the projectile collides with something private void OnCollisionEnter2D(Collision2D collision) { EnemyController enemy = collision.gameObject.GetComponent <EnemyController>(); RangedEnemyController rangedEnemy = collision.gameObject.GetComponent <RangedEnemyController>(); BossController boss = collision.gameObject.GetComponent <BossController>(); if (enemy != null) { enemy.TakeDamage(-projectileDamage); } if (rangedEnemy != null) { rangedEnemy.TakeDamage(-projectileDamage); } if (boss != null) { boss.TakeDamage(-projectileDamage); } //destory the game objects after they collided Destroy(gameObject); }
//OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { RangedEnemyController enemy = animator.gameObject.GetComponent <RangedEnemyController>(); enemy.StartChasing(); }
// Use this for initialization void Start() { rangedController = this.GetComponentInParent <RangedEnemyController>(); }
private void Start() { parentController = GetComponentInParent <RangedEnemyController>(); }