示例#1
0
    protected override IEnumerator AttackCicle()
    {
        yield return(new WaitForSeconds(startingDelay + .8f));

        while (true)
        {
            GameObject bulletObject = pool.Get();
            BulletLine bullet       = bulletObject.GetComponent <BulletLine>();
            if (bullet)
            {
                bulletObject.SetActive(true);
                Vector2 direction;
                if (player)
                {
                    direction = (player.GetTarget().position - transform.position).normalized;
                }
                else
                {
                    direction = Vector2.left;
                }

                bullet.Launch(direction * bulletSpeed);
                bulletObject.transform.position = transform.position;

                m_animator.SetTrigger("Attack");
                shootSFX.Play();
            }

            yield return(new WaitForSeconds(shotsDelay));
        }
    }
示例#2
0
    private void SuicideShots()
    {
        int max = 8;

        for (int i = 0; i < max; i++)
        {
            GameObject bulletObject = pool.Get();
            BulletLine bullet       = bulletObject.GetComponent <BulletLine>();
            if (bullet)
            {
                bulletObject.SetActive(true);
                Vector2 direction = RaposUtil.RotateVector(Vector2.up, (360 / max) * i);

                bullet.Launch(direction * bulletSpeed);
                bulletObject.transform.position = transform.position;
            }
        }
    }
示例#3
0
    private void Shoot(BulletLine bullet, float offsetY = 0)
    {
        GameObject bulletObject = bullet.gameObject;

        bulletObject.SetActive(true);
        Vector2 direction;

        if (target == null)
        {
            direction = (facingRight ? Vector2.right : Vector2.left) * bulletSpeed;
        }
        else
        {
            direction = (target.position - transform.position).normalized * bulletSpeed;
        }

        bullet.Launch(direction);
        bulletObject.transform.position = aimStar.position + (Vector3.up * offsetY);

        if (offsetY >= 0)
        {
            shotSFX.Play();
        }
    }