Example #1
0
        private bool HasValidTarget(EnemyEntity enemy)
        {
            var aimLeft = new Vector3(enemy.ProjectileSpawnPosition.x - enemiesConfiguration.AimingDelta,
                                      enemy.ProjectileSpawnPosition.y, enemy.ProjectileSpawnPosition.z);
            var aimRight = new Vector3(enemy.ProjectileSpawnPosition.x + enemiesConfiguration.AimingDelta,
                                       enemy.ProjectileSpawnPosition.y, enemy.ProjectileSpawnPosition.z);
            var aimLeftResult  = Aim(aimLeft);
            var aimRightResult = Aim(aimRight);

            return(!(aimLeftResult.enemyInFront || aimRightResult.enemyInFront) &&
                   (aimLeftResult.playerInFront || aimRightResult.playerInFront));
        }
Example #2
0
        public void Add(EnemyEntity entity)
        {
            enemies.Add(entity);
            if (leftmostEntity == null || entity.transform.position.x < leftmostEntity.transform.position.x)
            {
                leftmostEntity = entity;
            }

            if (rightmostEntity == null || entity.transform.position.x > rightmostEntity.transform.position.x)
            {
                rightmostEntity = entity;
            }
        }
Example #3
0
        public void Remove(EnemyEntity entity)
        {
            enemies.Remove(entity);
            if (entity == leftmostEntity)
            {
                leftmostEntity = FindLeftmostEntity(enemies);
            }

            if (entity == rightmostEntity)
            {
                rightmostEntity = FindRightmostEntity(enemies);
            }
        }