Esempio n. 1
0
    void Fire()
    {
        GameObject       bulletObject = Instantiate(bulletPrefab, transform.position, transform.rotation) as GameObject;
        BulletProjectile bullet       = bulletObject.GetComponent <BulletProjectile>();

        bullet.owner = gameObject;
        bullet.GetComponent <Rigidbody2D>().velocity = truck.GetComponent <Rigidbody2D>().velocity;
        float bulletMagnitude = .5f;

        bullet.yVector = bulletMagnitude;
        Physics2D.IgnoreCollision(bullet.GetComponent <Collider2D>(), GetComponent <Collider2D>());
        Physics2D.IgnoreCollision(bullet.GetComponent <Collider2D>(), truck.GetComponent <Collider2D>());
        bullet.transform.parent = bullets.transform;
    }
Esempio n. 2
0
    public void CreateBullet(float xVelocity)
    {
        GameObject       bulletObject = Instantiate(bulletPrefab, transform.position, transform.rotation) as GameObject;
        BulletProjectile bullet       = bulletObject.GetComponent <BulletProjectile>();

        bullet.speed = bulletSpeed;
        bullet.owner = owner;
        bullet.GetComponent <Rigidbody2D>().velocity = owner.GetComponent <Rigidbody2D>().velocity;
        Physics2D.IgnoreCollision(bullet.GetComponent <Collider2D>(), owner.GetComponent <Collider2D>());
        float bulletMagnitude = .25f;

        bullet.yVector = bulletMagnitude;
        bullet.GetComponent <Rigidbody2D>().velocity = owner.GetComponent <Rigidbody2D>().velocity;
    }
Esempio n. 3
0
    private void CreateBullet(Vector3 origin)
    {
//		AudioSource.PlayClipAtPoint(soundClip, transform.position);
        BulletProjectile bullet = newProjectile();

        bullet.speed  = speed;
        bullet.weapon = this;
        bullet.GetComponent <Entity>().affinity = player.GetComponent <Entity>().affinity;
        float bulletMagnitude = .5f;

        bullet.yVector            = bulletMagnitude;
        bullet.transform.position = origin;
        bullet.GetComponent <Rigidbody2D>().velocity = player.GetComponent <Rigidbody2D>().velocity;
        Physics2D.IgnoreCollision(bullet.GetComponent <Collider2D>(), player.GetComponent <Collider2D>());
        RegisterBullet();
    }
Esempio n. 4
0
    private void CreateBullet(float angle, float yVector)
    {
        BulletProjectile bullet = newProjectile();

        bullet.speed   = speed;
        bullet.weapon  = this;
        bullet.yVector = yVector;
        bullet.GetComponent <Entity>().affinity = GetComponent <Entity>().affinity;
        float xMovement = player.GetComponent <Rigidbody2D>().velocity.magnitude;

        bullet.xVector = Mathf.Round(xMovement);
        OrientProjectile(bullet);
        bullet.RotateMe(angle);
    }