Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        shotTimer += Time.deltaTime;
        if (shotTimer > shotTimerMax)
        {
            PlayerMovement player = FindObjectOfType <PlayerMovement>();

            Vector2 direction = player.transform.position - transform.position;
            direction.Normalize();
            BossBullet  proj            = Instantiate(projectilePrefab, direction, Quaternion.identity).GetComponent <BossBullet>();
            Rigidbody2D rigidBodyBullet = proj.GetComponent <Rigidbody2D>();
            proj.transform.position  = transform.position;
            rigidBodyBullet.velocity = direction * projectileSpeed * 2;
            shotTimer = 0;
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        healthText.text = "Boss Health: " + health.ToString();
        if (health <= 0)
        {
            healthText.text = "Boss Health: 0";

            _particles.transform.position = gameObject.transform.position;
            _particles.Play();
            GameManager end = FindObjectOfType <GameManager>();
            end.OpenWin();
            Destroy(gameObject);
        }
        if (health <= 70 && health >= 31)
        {
            Boss3BulletSpawner[] weapons = FindObjectsOfType <Boss3BulletSpawner>();
            for (int i = 0; i < weapons.Length; i++)
            {
                Destroy(weapons[i]);
            }
            shotTimer += Time.deltaTime;
            if (shotTimer > shotTimerMax)
            {
                PlayerMovement player = FindObjectOfType <PlayerMovement>();

                Vector2 direction = player.transform.position - transform.position;
                direction.Normalize();
                BossBullet  proj            = Instantiate(projectilePrefab, direction, Quaternion.identity).GetComponent <BossBullet>();
                Rigidbody2D rigidBodyBullet = proj.GetComponent <Rigidbody2D>();
                proj.transform.position   = new Vector2(transform.position.x, transform.position.y + 7.0f);
                proj.transform.localScale = proj.transform.localScale * 2;
                rigidBodyBullet.velocity  = direction * projectileSpeed * 2;
                shotTimer = 0;
            }
        }
        if (health <= 30)
        {
            transform.position = new Vector2(transform.position.x, transform.position.y - 0.001f);
            if (transform.position.y <= -4)
            {
                PlayerMovement player = FindObjectOfType <PlayerMovement>();
                Destroy(player);
            }
        }
    }