Exemplo n.º 1
0
    public void shoot()
    {
        if (timestamp > Time.time)
        {
            return;
        }
        timestamp = Time.time + cooldown_seconds;

        Vector2 vel = Camera.main.ScreenToWorldPoint(Input.mousePosition) - this.transform.position;

        if (vel.magnitude < 0.05)
        {
            return;
        }

        vel = vel.normalized;

        GameObject obj = BulletPoolManager.getBulletPoolManager().getNewBullet();

        obj.transform.position = bulletSpawn.position;
        obj.transform.rotation = bulletSpawn.rotation;
        obj.SetActive(true);

        BulletDeluxe bullet = obj.GetComponent <BulletDeluxe>();

        bullet.setData(bulletData, this.transform);
        bullet.setVelocity(this.transform.up);

        current_bullet_ID++;
        // StartCoroutine(end_cooldown());
    }
Exemplo n.º 2
0
    BulletDeluxe create_bullet(ShotPatternData shot_data, BulletData bullet_data, Vector3 position, float angle_grad)
    {
        BulletDeluxe bullet = pool.getNewBullet().GetComponent <BulletDeluxe>();

        bullet.activate();

        bullet.setData(bullet_data, player);

        if (!bullet_data.faceVelocity)
        {
            bullet.GetComponentInChildren <ComponentFixRotation>().enabled = true;
        }

        bullet.setRotation(angle_grad);
        bullet.setPosition(position + bullet.transform.up * shot_data.radialOffset);
        bullet.setSpeed(shot_data.bulletSpeed);
        bullet.setAngularVelocity(shot_data.bulletAngularVelocity);

        event_manager.addBullet(bullet);

        return(bullet);
    }