Beispiel #1
0
        void Shoot()
        {
            if (++poolIndex >= bulletPool.Length)
            {
                poolIndex = 0;
            }
            GameObject bullet = bulletPool[poolIndex];

            if (bulletPool[poolIndex] == null)
            {
                GameObject bulletPrefab = bulletPrefabs[Random.Range(0, bulletPrefabs.Length)];
                bullet = Instantiate <GameObject>(bulletPrefab);
                bulletPool[poolIndex] = bullet;
            }
            Vector3 cannonTip = transform.TransformPoint(new Vector3(0, 1.1f, 0));
            Vector3 direction = (cannonTip - transform.position).normalized;

            transform.position       -= direction * 0.05f;
            bullet.transform.position = cannonTip;
            bullet.GetComponent <Rigidbody>().velocity = direction * (2f + Random.value);
            bullet.GetComponent <Renderer>().enabled   = true;

            TrailEffect trail = bullet.GetComponent <TrailEffect>();

            trail.Clear();
            trail.duration = 0.5f + Random.value * 2f;
        }
Beispiel #2
0
    void FixedUpdate()
    {
        if (Input.GetMouseButtonDown(0) && Time.timeScale != 0)
        {
            trailNum++;

            GameObject  newBullet   = Instantiate(bullet);
            GameObject  newTrail    = Instantiate(trail);
            TrailEffect trailEffect = newTrail.GetComponent <TrailEffect>();
            trailEffect.player = newBullet;


            Rigidbody rb = newBullet.GetComponent <Rigidbody>();
            rb.velocity = new Vector3(8.0f, -8.0f, 8.0f);
        }
    }
 public virtual void endTrail()
 {
     currentTrail.DieTrail();
     currentTrail = null;
 }
 public virtual void startTrail()
 {
     currentTrail = trailEffect.Spawn(transform.position);
     currentTrail.StartTrail(this);
 }
Beispiel #5
0
 static ScrollingTrailSection()
 {
     _sharedTrailEffect = new TrailEffect(GameService.Content.ContentManager.Load <Effect>("effects\\trail"));
     _fadeTexture       = GameService.Content.GetTexture("uniformclouds_blur30");
 }
Beispiel #6
0
 // Start is called before the first frame update
 void Start()
 {
     _rb   = this.GetComponent <Rigidbody>();
     _ih   = this.GetComponent <InputHandler>();
     trail = GetComponent <TrailEffect>();
 }