예제 #1
0
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
 }
예제 #2
0
 public static VultureEnemy Instance()
 {
     if (_instance == null)
     {
         _instance = new VultureEnemy();
     }
     return(_instance);
 }
예제 #3
0
    private void FireWebProjectile()
    {
        float directionMultiplier = 0.0f;

        //Right = 1 || Left = -1
        if (!isInBossScene)
        {
            AudioManager.Instance.PlaySpecificClip(webShootAudio, gameObject.transform);

            directionMultiplier = playerSingleton.PlayerMovement.PlayerMovementDirection == PlayerMovement.MovementDirection.RIGHT ? 1 : -1;

            WebProjectile projectile = Instantiate(webProjectile, attackTransform.position, Quaternion.identity).GetComponent <WebProjectile>();
            projectile.SpawnProjectile(new Vector2(projectileSpeed * 10 * directionMultiplier, 0), projectileLifetime, projectileDamage);

            attackCooldownTimer = attackCooldownDuration;
        }
        else
        {
            AudioManager.Instance.PlaySpecificClip(webShootAudio, gameObject.transform);
            directionMultiplier = playerSingleton.PlayerMovement.PlayerMovementDirection == PlayerMovement.MovementDirection.RIGHT ? 1 : -1;

            GameObject bossEnemy   = VultureEnemy.Instance().gameObject;
            Vector2    relativePos = bossEnemy.transform.position - gameObject.transform.position;


            if (relativePos.x <= 0 && relativePos.y < 25 && directionMultiplier <= 0.5f)
            {
                WebProjectile projectile = Instantiate(webProjectile, attackTransform.position, Quaternion.identity).GetComponent <WebProjectile>();
                projectile.SpawnProjectile(new Vector2(relativePos.x, relativePos.y), 10, 1);
            }
            else if (relativePos.x >= 0 && relativePos.y < 25 && directionMultiplier >= 0.5f)
            {
                WebProjectile projectile = Instantiate(webProjectile, attackTransform.position, Quaternion.identity).GetComponent <WebProjectile>();
                projectile.SpawnProjectile(new Vector2(relativePos.x, relativePos.y), 10, 1);
            }
            else
            {
                directionMultiplier = playerSingleton.PlayerMovement.PlayerMovementDirection == PlayerMovement.MovementDirection.RIGHT ? 1 : -1;

                WebProjectile projectile = Instantiate(webProjectile, attackTransform.position, Quaternion.identity).GetComponent <WebProjectile>();
                projectile.SpawnProjectile(new Vector2(projectileSpeed * 10 * directionMultiplier, 0), projectileLifetime, projectileDamage);

                attackCooldownTimer = attackCooldownDuration;
            }
        }
    }