示例#1
0
        /// <summary>
        /// Fires projectiles in a pattern determined by the firemode at the player.
        /// </summary>
        private IEnumerator Shoot()
        {
            canShoot = false;

            //for (int x = 0; x < 25; x++)
            //{
            //    if (projectileArray[x])
            //    {
            //        GameObject projectile =
            //            objectPoolManager.Spawn(gameObject, projectileTypeIdentifier, shootPoint[x].position,
            //                                    shootPoint[x].rotation);

            //        projectile.GetComponent<Transform>().Rotate(Random.Range(-spread, spread),
            //                                                    Random.Range(-spread, spread),
            //                                                    Random.Range(-spread, spread));
            //        projectile.GetComponent<Projectile>()
            //                  .SetColors(projectileAlbedoColor, projectileEmissionColor);
            //        Projectile projectileScript = projectile.GetComponent<Projectile>();
            //        projectileScript.Launch(0);
            //        //projectile.GetComponent<Rigidbody>().velocity =
            //        //    projectile.transform.forward * projectileSpeed;

            //        if (canRotate)
            //        {
            //            StartCoroutine(rotateProjectile(projectile));
            //        }
            //    }
            //}

            GameObject projectile =
                objectPoolManager.Spawn(gameObject, patternId, shootPoint.position,
                                        shootPoint.rotation);

            ProjectilePattern projectileScript = projectile.GetComponent <ProjectilePattern>();

            projectileScript.Launch(0);

            yield return(new WaitForSeconds(fireRate));

            canShoot = true;
        }
示例#2
0
        /// <summary>
        /// Fires projectiles in a pattern determined by the firemode at the player.
        /// </summary>
        private IEnumerator Shoot()
        {
            canShoot = false;

            GameObject projectile;

            if (usePattern)
            {
                projectile = objectPoolManager.Spawn(
                    gameObject, patternId, shootPoint.position,
                    shootPoint.rotation);
                ProjectilePattern projectileScript = projectile.GetComponent <ProjectilePattern>();
                projectileScript.Launch(0);
            }
            else
            {
                projectile = objectPoolManager.Spawn(
                    gameObject, projectileTypeIdentifier, shootPoint.position,
                    shootPoint.rotation);

                projectile.GetComponent <Transform>().Rotate(Random.Range(-spread, spread),
                                                             Random.Range(-spread, spread),
                                                             Random.Range(-spread, spread));
                Projectile projectileScript = projectile.GetComponent <Projectile>();
                projectileScript.Launch(0);
            }

            if (canRotate)
            {
                StartCoroutine(rotateProjectile(projectile));
            }

            yield return(new WaitForSeconds(fireRate));

            canShoot = true;
        }