コード例 #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 Awake()
    {
        S = this;

        _line         = GetComponent <LineRenderer>();
        _line.enabled = false;
        _points       = new List <Vector3>();
    }
コード例 #3
0
 public void CreateBullet(Vector3 target, Vector3 source)
 {
     bulletIndex = bulletManager.GetBulletIndex();
     if (bulletIndex == -1)
     {
         return;
     }
     bullet = bulletManager.bullets[bulletIndex].GetComponent <BulletLine>();
     bulletManager.freeBullets[bulletIndex]    = false;
     bullet.GetComponent <Renderer>().material = shooterObject.GetComponent <Renderer>().sharedMaterial;
     bullet.Show(target, source);
     StartCoroutine(BulletShowTimer());
 }
コード例 #4
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;
            }
        }
    }
コード例 #5
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();
        }
    }