public void Attack()
    {
        bulletTimer += Time.deltaTime;



        Vector2 direction = target.transform.position - transform.position;

        direction.Normalize();


        GameObject BulletClone;

        BulletClone = Instantiate(bullet, shootPoint.transform.position, shootPoint.transform.rotation) as GameObject;
        BulletClone.GetComponent <Rigidbody2D>().velocity = direction * bulletSpeed;

        BulletClone = Instantiate(bullet, shootPoint2.transform.position, shootPoint.transform.rotation) as GameObject;
        BulletClone.GetComponent <Rigidbody2D>().velocity = direction * bulletSpeed;

        BulletClone = Instantiate(bullet, shootPoint3.transform.position, shootPoint.transform.rotation) as GameObject;
        BulletClone.GetComponent <Rigidbody2D>().velocity = direction * bulletSpeed;


        bulletTimer = 0;
    }
예제 #2
0
    public void Throw()
    {
        bulletTimer += Time.deltaTime;

        /*if(bulletTimer>=shootInterval)
         *      {*/
        Vector3 pos       = new Vector3(transform.position.x, attackTrigger.transform.position.y - 0.1f, 0);
        Vector2 direction = attackTrigger.transform.position - pos;

        direction.Normalize();


        GameObject BulletClone;

        if (actualPowerUp != 2)
        {
            BulletClone = Instantiate(bullets[actualPowerUp], attackTrigger.transform.position, attackTrigger.transform.rotation) as GameObject;
            BulletClone.GetComponent <Rigidbody2D>().velocity = rib2d.velocity + direction * bulletSpeed;
        }
        else
        {
            for (int i = 0; i < bulletDirections.Length; i++)
            {
                direction = bulletDirections[i].transform.position - transform.position;
                direction.Normalize();



                BulletClone = Instantiate(bullets[actualPowerUp], attackTrigger.transform.position, attackTrigger.transform.rotation) as GameObject;
                BulletClone.GetComponent <Rigidbody2D>().velocity = rib2d.velocity + direction * bulletSpeed / 2;
            }
        }
        bulletTimer = 0;



        //}
    }