示例#1
0
    private Vector3 GetKnockbackDirection()
    {
        PolarCoordinate polarDirection = new PolarCoordinate(1, this.gameObject.transform.eulerAngles.z * Mathf.Deg2Rad);

        Debug.LogError("Polar Coordinate: " + polarDirection.ToString());
        Debug.LogError("KnockbackDirection: " + polarDirection.PolarToCartesian().ToString());

        return(polarDirection.PolarToCartesian());
    }
示例#2
0
    IEnumerator GenerateTrail(PolarCoordinate direction)
    {
        //Determine direction of trail
        PolarCoordinate shootDirection = direction;

        shootDirection.angle += Random.Range(-coneOfFiring, coneOfFiring);

        //Keep track of the previously fired bullet
        Bullet prevBullet;

        //Fire the leading bullet that will home in on the target
        TrailBullet leadingBullet = bulletPrefab.GetPooledInstance <TrailBullet>();

        leadingBullet.owningPlayer = owningPlayer;
        if (!GameManager.S.inGame)
        {
            leadingBullet.thisPlayer = thisPlayer;
            leadingBullet.SetColor(thisPlayer.playerColor);
        }
        leadingBullet.transform.position = gameObject.transform.position;
        leadingBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * shootDirection.PolarToCartesian().normalized;
        leadingBullet.target        = target;
        leadingBullet.leadingBullet = null;
        prevBullet = leadingBullet;
        leadingBullet.BeginHoming();
        yield return(new WaitForSeconds(bulletDelay));

        //Fire the rest of the bullets that will follow the leading bullet
        for (int i = 1; i < bulletsPerTrail; i++)
        {
            TrailBullet curBullet = bulletPrefab.GetPooledInstance <TrailBullet>();
            curBullet.owningPlayer = owningPlayer;
            if (!GameManager.S.inGame)
            {
                curBullet.thisPlayer = thisPlayer;
                curBullet.SetColor(thisPlayer.playerColor);
            }
            curBullet.transform.position = gameObject.transform.position;
            curBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * shootDirection.PolarToCartesian().normalized;

            curBullet.target        = target;
            curBullet.leadingBullet = prevBullet;
            prevBullet = curBullet;
            curBullet.BeginHoming();

            yield return(new WaitForSeconds(bulletDelay));
        }
    }
示例#3
0
    void GenerateBullet(PolarCoordinate direction, int waveDirection)
    {
        SineBullet curBullet = bulletPrefab.GetPooledInstance <SineBullet>();

        curBullet.owningPlayer = owningPlayer;
        if (!GameManager.S.inGame)
        {
            curBullet.SetColor(thisPlayer.playerColor);
            curBullet.thisPlayer = thisPlayer;
        }
        curBullet.transform.position = gameObject.transform.position;
        curBullet.GetComponent <PhysicsObj>().velocity = baseVelocity * direction.PolarToCartesian().normalized;

        //Make amplitude wider during aura mode
        if (masochistPlayer != null && masochistPlayer.masochistShip.damageMultiplier > 1)
        {
            curBullet.amplitude = amplitudeScalar;
        }
        else
        {
            curBullet.amplitude = 10f;
        }

        curBullet.ApplySineWave(waveDirection);
    }
    IEnumerator Start()
    {
        //Fire burst
        for (int i = 0; i < numBurstsPerWave; i++)
        {
            float radDelta = (2f * Mathf.PI) / numBulletsPerBurst;

            //Fire bullet
            float curAngle = 0;
            while (curAngle < 2 * Mathf.PI)
            {
                PolarCoordinate direction = new PolarCoordinate(1, curAngle);
                ParentedBullet  newBullet = Instantiate(bulletPrefab, transform.position, new Quaternion()) as ParentedBullet;
                newBullet.damage       = bulletDamage;
                newBullet.owningPlayer = owningPlayer;
                if (!GameManager.S.inGame)
                {
                    newBullet.thisPlayer = thisPlayer;
                    newBullet.SetColor(thisPlayer.playerColor);
                }
                newBullet.transform.SetParent(transform);
                newBullet.transform.position      = gameObject.transform.position;
                newBullet.physics.actOnLocalSpace = true;
                newBullet.curState         = BulletState.parented;
                newBullet.physics.velocity = bulletVelocity * direction.PolarToCartesian().normalized;

                curAngle += radDelta;
            }

            yield return(new WaitForSeconds(timeBetweenBursts));
        }
    }
示例#5
0
    IEnumerator FireBurstCoroutine()
    {
        if (owningPlayer == PlayerEnum.none)
        {
            Debug.LogError("Weave shot does not have owning player set");
            yield break;
        }

        PolarCoordinate direction = new PolarCoordinate(1, target.position - gameObject.transform.position);
        PolarCoordinate shootDir1 = new PolarCoordinate(1, direction.angle + 90 * Mathf.Deg2Rad);
        PolarCoordinate shootDir2 = new PolarCoordinate(1, direction.angle - 90 * Mathf.Deg2Rad);

        //Weaves will span the 180 degree area that is perpendicular to the target
        float bulletSeparation = 180 / bulletsPerWeave * Mathf.Deg2Rad;

        int curDirection = 1;

        for (int i = 0; i < bulletsPerBurst; i++)
        {
            //Fire bullet from first weave
            Bullet curBullet = bulletPrefab.GetPooledInstance <Bullet>();
            curBullet.owningPlayer = owningPlayer;
            if (!GameManager.S.inGame)
            {
                curBullet.SetColor(thisPlayer.playerColor);
                curBullet.thisPlayer = thisPlayer;
            }
            curBullet.transform.position = gameObject.transform.position;
            curBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * shootDir1.PolarToCartesian().normalized;

            //Fire bullet from second weave
            curBullet = bulletPrefab.GetPooledInstance <Bullet>();
            curBullet.owningPlayer = owningPlayer;
            if (!GameManager.S.inGame)
            {
                curBullet.SetColor(thisPlayer.playerColor);
                curBullet.thisPlayer = thisPlayer;
            }
            curBullet.transform.position = gameObject.transform.position;
            curBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * shootDir2.PolarToCartesian().normalized;

            //Adjust the angles for the next bullets
            shootDir1.angle += bulletSeparation * curDirection;
            shootDir2.angle -= bulletSeparation * curDirection;

            //Reverse direction
            if (i % bulletsPerWeave == 0)
            {
                curDirection *= -1;
            }

            yield return(new WaitForSeconds(bulletDelay));
        }

        //Destroy this gameObject after the burst has been fired
        Destroy(gameObject);
    }
示例#6
0
        private void UpdateWallPosition(UnityEngine.Transform wallTransform, float radsOffset)
        {
            PolarCoordinate cameraPolar    = CameraToPillar();
            float           colliderLength = wallTransform.lossyScale.z;
            PolarCoordinate oppositePolar  = new PolarCoordinate(colliderLength / 2f, Angle.Radians(cameraPolar.angle.radians + radsOffset));

            oppositePolar.y        = wallTransform.position.y;
            wallTransform.position = oppositePolar.PolarToCartesian() + new Vector3(bottomOfPillar.x, 0, bottomOfPillar.z);
        }
    public IEnumerator LaunchGrabbableEquipment()
    {
        PolarCoordinate instantiationDirection = new PolarCoordinate(1.0f, Random.Range(0f, 360f));
        float           currentLaunchMagnitude = this.instantiationLaunchMagnitude;

        while (currentLaunchMagnitude > 0.01)
        {
            this.gameObject.transform.Translate(instantiationDirection.PolarToCartesian() * Time.deltaTime * currentLaunchMagnitude);
            currentLaunchMagnitude -= 0.1f;
            yield return(null);
        }
    }
示例#8
0
    IEnumerator FireBurstCoroutine()
    {
        float radDelta = (2f * Mathf.PI) / numBulletsPerBurst;

        for (int i = 0; i < numBursts; i++)
        {
            float curAngle = ((i % 2) * radDelta) / 2f;
            while (curAngle < 2 * Mathf.PI)
            {
                PolarCoordinate direction = new PolarCoordinate(1, curAngle);
                Bullet          curBullet = bulletPrefab.GetPooledInstance <Bullet>();
                curBullet.damage       = bulletDamage;
                curBullet.owningPlayer = owningPlayer;
                if (!GameManager.S.inGame)
                {
                    curBullet.SetColor(thisPlayer.playerColor);
                    curBullet.thisPlayer = thisPlayer;
                }
                curBullet.transform.position    = gameObject.transform.position;
                curBullet.physics.velocity      = bulletVelocity * direction.PolarToCartesian().normalized;
                curBullet.physics.acceleration  = accelerationFactor * bulletVelocity * direction.PolarToCartesian().normalized;
                curBullet.physics.acceleration += (i % 2 == 0 ? 1 : -1) * 0.1f * Vector3.Cross(curBullet.physics.acceleration, Vector3.forward);

                curAngle += radDelta;
            }
            ////Fire burst of bullets
            //for (float curAngle = 0; curAngle < startingAngle + (2 * Mathf.PI); curAngle += firingSeparation) {
            //	PolarCoordinate direction = new PolarCoordinate(1, curAngle);
            //	Bullet curBullet = bulletPrefab.GetPooledInstance<Bullet>();
            //	curBullet.damage = 1.5f;
            //	curBullet.owningPlayer = owningPlayer;
            //	curBullet.transform.position = gameObject.transform.position;
            //	curBullet.GetComponent<PhysicsObj>().velocity = bulletVelocity * direction.PolarToCartesian().normalized;
            //}

            ////Change direction if needed
            //if ((i != 0) && (i % (numBursts / numDirectionFlips) == 0)) {
            //	directionScalar *= -1;
            //}

            ////Update starting angle with the offset
            //startingAngle += angleOffset * Mathf.Deg2Rad * directionScalar;

            yield return(new WaitForSeconds(bulletDelay));
        }

        Destroy(gameObject);
    }
示例#9
0
 private Vector3 GetRandomMoveDirection()
 {
     if (this.currentMoveDirection == null)
     {
         float randomXValue = Random.Range(-1.0f, 1.0f);
         float randomZValue = Random.Range(-1.0f, 1.0f);
         return(new Vector3(randomXValue, 0, randomZValue).normalized);
     }
     else //Pick a new vector that is significantly different from the original direction vector
     {
         PolarCoordinate polarDirectionVector = new PolarCoordinate(this.currentMoveDirection, Orientation.XZ);
         float           randomAngle          = Random.Range((Mathf.PI / 6.0f), ((Mathf.PI * 11.0f) / 6.0f));
         PolarCoordinate newDirectionVector   = new PolarCoordinate(1.0f, randomAngle + polarDirectionVector.angleInRadians);
         return(newDirectionVector.PolarToCartesian(Orientation.XZ).normalized);
     }
 }
示例#10
0
    IEnumerator OrbitBullet(Bullet thisBullet)
    {
        if (shooting)
        {
            yield break;
        }

        float radius     = transform.localScale.y;
        float lerpSpeed  = 0.5f;
        float orbitSpeed = Random.Range(-10 * Mathf.Deg2Rad, 10 * Mathf.Deg2Rad);

        //Add the bullet to the list
        absorbedBullets.Add(thisBullet.GetComponent <PhysicsObj>());

        //Change ownership of the bullet and halt its velocity
        thisBullet.owningPlayer = owningPlayer;
        if (!GameManager.S.inGame)
        {
            thisBullet.thisPlayer = thisPlayer;
            thisBullet.SetColor(thisPlayer.playerColor);
        }
        thisBullet.curState = BulletState.absorbedByMasochist;
        thisBullet.GetComponent <PhysicsObj>().velocity = Vector3.zero;

        //Lerp to a position inside the shield
        //Vector3 targetPosition = new PolarCoordinate(radius, thisBullet.transform.position).PolarToCartesian() + transform.position;

        //while ((targetPosition - thisBullet.transform.position).magnitude >= 0.01f) {
        //	thisBullet.transform.position = Vector3.Lerp(thisBullet.transform.position, targetPosition, lerpSpeed);
        //	yield return new WaitForFixedUpdate();
        //}

        //Orbit the bullets around the player
        PolarCoordinate bulletPos = new PolarCoordinate(radius, thisBullet.transform.position);

        while (thisBullet.curState == BulletState.absorbedByMasochist)
        {
            bulletPos.angle += orbitSpeed;
            thisBullet.transform.position = transform.position + bulletPos.PolarToCartesian();
            yield return(new WaitForSeconds(0.02f));
        }
    }
示例#11
0
    IEnumerator FireBurstCoroutine()
    {
        float firingSeparation = 60 * Mathf.Deg2Rad;
        float startingAngle    = 0;
        int   directionScalar  = 1;
        float angleOffset      = 4;
        float bulletVelocity   = 4;

        for (int i = 0; i < numBursts; i++)
        {
            //Fire burst of bullets
            for (float curAngle = startingAngle; curAngle < startingAngle + (2 * Mathf.PI); curAngle += firingSeparation)
            {
                PolarCoordinate direction = new PolarCoordinate(1, curAngle);
                Bullet          curBullet = bulletPrefab.GetPooledInstance <Bullet>();
                if (!GameManager.S.inGame)
                {
                    curBullet.SetColor(thisPlayer.playerColor);
                    curBullet.thisPlayer = thisPlayer;
                }
                curBullet.damage             = 1.5f;
                curBullet.owningPlayer       = owningPlayer;
                curBullet.transform.position = gameObject.transform.position;
                curBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * direction.PolarToCartesian().normalized;
            }

            //Change direction if needed
            if ((i != 0) && (i % (numBursts / numDirectionFlips) == 0))
            {
                directionScalar *= -1;
            }

            //Update starting angle with the offset
            startingAngle += angleOffset * Mathf.Deg2Rad * directionScalar;

            yield return(new WaitForSeconds(bulletDelay));
        }

        Destroy(gameObject);
    }
示例#12
0
    private IEnumerator EvadeAttacks()
    {
        while (this.currentAIState == AIState.Evasive)
        {
            TravelPath chosenPath = this.currentlyTravellingPath;

            PolarCoordinate oppositeDirection = new PolarCoordinate(this.sphereCastMagnitude, -this.currentlyTravellingPath.pathVector);
            this.startingAngle = oppositeDirection.angle + (Random.Range(-30f, 30f) * Mathf.Deg2Rad);
            this.endingAngle   = this.startingAngle + (360 * Mathf.Deg2Rad);

            Debug.DrawRay(this.comShipMovement.gameObject.transform.position, oppositeDirection.PolarToCartesian().normalized *this.sphereCastMagnitude, Color.green);

            //Scan from startAngle to endAngle
            for (float i = this.startingAngle; i < this.endingAngle; i += this.shipScanDegreeSeparation)
            {
                PolarCoordinate scanDirection   = new PolarCoordinate(this.sphereCastMagnitude, i);
                PolarCoordinate offsetPosition  = /*new PolarCoordinate(3 * this.sphereCastRadius, i);*/ new PolarCoordinate(this.sphereCastRadius, Vector3.zero);
                RaycastHit[]    detectedObjects = Physics.SphereCastAll(this.comShipMovement.gameObject.transform.position + offsetPosition.PolarToCartesian(),
                                                                        this.sphereCastRadius, scanDirection.PolarToCartesian().normalized, this.sphereCastMagnitude, this.shipScanLayerMask);
                TravelPath currentCheckedPath = new TravelPath();

                Debug.DrawRay(this.comShipMovement.gameObject.transform.position + offsetPosition.PolarToCartesian(), scanDirection.PolarToCartesian(), Color.red);

                currentCheckedPath.pathVector  = scanDirection.PolarToCartesian();
                currentCheckedPath.dangerScore = this.CompositeTotalDangerScore(detectedObjects);

                //Replace chosen direction if it's determined to be safer
                if (currentCheckedPath.dangerScore < this.currentlyTravellingPath.dangerScore)
                {
                    chosenPath.pathVector  = currentCheckedPath.pathVector;
                    chosenPath.dangerScore = currentCheckedPath.dangerScore;
                }
            }

            this.nextDirection = chosenPath.pathVector;

            yield return(new WaitForFixedUpdate());
        }
    }
示例#13
0
    IEnumerator FireBurstCoroutine()
    {
        if (owningPlayer == PlayerEnum.none)
        {
            Debug.LogError("Cone shot does not have owning player set");
            yield break;
        }

        //Set direction and separation between bullets
        PolarCoordinate direction        = new PolarCoordinate(1, target.position - gameObject.transform.position);
        float           bulletSeparation = coneSpread / numLines;

        for (int i = 0; i < bulletsPerBurst; i++)
        {
            //Start the new direction set at the edge of the cone
            PolarCoordinate newDirection = new PolarCoordinate(1, direction.angle - (Mathf.Floor(numLines / 2) * bulletSeparation));

            //Fire bullet wave
            for (int j = 0; j < numLines; j++)
            {
                Bullet curBullet = bulletPrefab.GetPooledInstance <Bullet>();
                curBullet.owningPlayer = owningPlayer;
                if (!GameManager.S.inGame)
                {
                    curBullet.SetColor(playerColor);
                    curBullet.thisPlayer = thisPlayer;
                }
                curBullet.transform.position = gameObject.transform.position;
                curBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * newDirection.PolarToCartesian().normalized;
                newDirection.angle += bulletSeparation;
            }

            yield return(new WaitForSeconds(bulletDelay));
        }

        //Destroy this gameObject after the burst has been fired
        Destroy(gameObject);
    }
示例#14
0
    private IEnumerator HandleAiming(Vector3 startingPosition)
    {
        float   normalizedMagnitude = 0;
        Vector3 finalAimDirection   = Vector3.zero;

        while (Input.GetMouseButton(0))
        {
            Vector3 currentMousePosition = Camera.main.ScreenToViewportPoint(Input.mousePosition);
            Vector3 positionDifference   = currentMousePosition - startingPosition;

            float currentRadius = this.maxSlingshotLaunchRadius;

            if (positionDifference.magnitude < this.maxSlingshotLaunchRadius)
            {
                currentRadius = positionDifference.magnitude;
            }

            PolarCoordinate polarPositionDifference = new PolarCoordinate(currentRadius, positionDifference);

            Vector3 endPosition = startingPosition + polarPositionDifference.PolarToCartesian();

            //These are reverse because the launch direction will be the opposite direction of the slingshot
            Vector3 aimDirection = startingPosition - endPosition;
            finalAimDirection   = new Vector3(aimDirection.x, 0, aimDirection.y);
            normalizedMagnitude = this.GetDistance(startingPosition, endPosition) / this.maxSlingshotLaunchRadius;

            this.aimingLine.SetPosition(1, this.aimingLine.GetPosition(0) + finalAimDirection * 30);

            yield return(null);
        }
        if (normalizedMagnitude > 0.1f)
        {
            this.aimingLine.SetPosition(1, this.aimingLine.GetPosition(0));
            this.LaunchLasso(finalAimDirection, normalizedMagnitude);
        }
    }
示例#15
0
 public void ToInitialPosition()
 {
     polarCoordinate    = new PolarCoordinate(initialPosition);
     transform.position = polarCoordinate.PolarToCartesian();
     transform.LookAt(center);
 }
示例#16
0
    IEnumerator FireBurstCoroutine()
    {
        if (owningPlayer == PlayerEnum.none)
        {
            Debug.LogError("Leading shot does not have owning player set");
            yield break;
        }
        inCoroutine = true;

        PolarCoordinate startDirection = new PolarCoordinate(1, targetShip.transform.position - gameObject.transform.position);
        PolarCoordinate curDirection   = new PolarCoordinate(startDirection.radius, startDirection.angle);

        float degreeOfSpread = spread * Mathf.Deg2Rad;

        float degreeIncrement = spreadIncrementPerBullet * Mathf.Deg2Rad;



        int   degreeScalar     = 1;
        float distanceToTarget = (targetShip.transform.position - transform.position).magnitude;
        //Leads more when the explosion happens closer to the player, less when exploded far away
        float leadingAmount = 0;        // Mathf.Lerp(0.1f, 0f, Mathf.InverseLerp(4, 20, distanceToPlayer));

        Vector3 targetPlayerVelocity = Vector3.zero;

        //Don't try to lead velocity on the title screen
        if (GameManager.S.gameState != GameStates.titleScreen)
        {
            targetPlayerVelocity = leadingAmount * targetShip.movement.GetVelocity();
        }

        for (int i = 0; i < bulletsPerBurst; i++)
        {
            if (Mathf.Abs(startDirection.angle - curDirection.angle) > degreeOfSpread)
            {
                degreeScalar *= -1;
            }

            float   sprayRange  = 0.45f;
            Vector3 sprayVector = new Vector3(Random.Range(-sprayRange, sprayRange), Random.Range(-sprayRange, sprayRange), 0);

            Bullet curBullet = bulletPrefab.GetPooledInstance <Bullet>();
            curBullet.owningPlayer = owningPlayer;
            if (!GameManager.S.inGame)
            {
                curBullet.SetColor(thisPlayer.playerColor);
                curBullet.thisPlayer = thisPlayer;
            }
            curBullet.transform.position = gameObject.transform.position;
            //GameObject curBullet = Instantiate(bulletPrefab, gameObject.transform.position, new Quaternion()) as GameObject;
            curBullet.GetComponent <PhysicsObj>().velocity = 10 * (curDirection.PolarToCartesian().normalized + targetPlayerVelocity + sprayVector).normalized;
            curDirection.angle += degreeIncrement * degreeScalar;

            yield return(new WaitForSeconds(0.02f));
        }

        inCoroutine = false;

        //Destroy this gameObject after the burst has been fired
        Destroy(gameObject);
    }
示例#17
0
    IEnumerator FireBurstCoroutine()
    {
        //Separation of bullets is smaller when the m*******t has his aura up
        //Normal: 5 directions, Aura: 8 directions
        float firingSeparation;
        float startingAngle;

        if (masochistPlayer != null)
        {
            firingSeparation = masochistPlayer.masochistShip.damageMultiplier == 1 ? firingSeparationNoAura : firingSeparationWithAura;
            startingAngle    = masochistPlayer.masochistShip.damageMultiplier == 1 ? startingAngleNoAura : startingAngleWithAura;
        }
        else
        {
            firingSeparation = firingSeparationNoAura;
            startingAngle    = startingAngleNoAura;
        }

        float bulletOffset = 3f * Mathf.Deg2Rad;


        float bulletVelocity = 10f;

        for (int i = 0; i < numBursts; i++)
        {
            //Fire burst of bullets
            for (float curAngle = startingAngle; curAngle < startingAngle + (2 * Mathf.PI); curAngle += firingSeparation)
            {
                PolarCoordinate direction = new PolarCoordinate(1, curAngle);
                PolarCoordinate offset    = new PolarCoordinate(1, bulletOffset);
                PolarCoordinate offsetDirection;

                //Bullet 1
                offsetDirection = new PolarCoordinate(1, curAngle + bulletOffset);
                Bullet curBullet = bulletPrefab.GetPooledInstance <Bullet>();
                curBullet.owningPlayer = owningPlayer;
                if (!GameManager.S.inGame)
                {
                    curBullet.SetColor(thisPlayer.playerColor);
                    curBullet.thisPlayer = thisPlayer;
                }
                curBullet.transform.position = gameObject.transform.position;
                curBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * (offsetDirection.PolarToCartesian()).normalized;

                //Bullet 2
                offsetDirection        = new PolarCoordinate(1, curAngle - bulletOffset);
                curBullet              = bulletPrefab.GetPooledInstance <Bullet>();
                curBullet.owningPlayer = owningPlayer;
                if (!GameManager.S.inGame)
                {
                    curBullet.SetColor(thisPlayer.playerColor);
                    curBullet.thisPlayer = thisPlayer;
                }
                curBullet.transform.position = gameObject.transform.position;
                curBullet.GetComponent <PhysicsObj>().velocity = bulletVelocity * (offsetDirection.PolarToCartesian()).normalized;
            }

            yield return(new WaitForSeconds(bulletDelay));
        }

        Destroy(gameObject);
    }
示例#18
0
    IEnumerator CreateBullets()
    {
        //Each shell
        for (int i = 0; i < numShells; i++)
        {
            float timeInShell = 0;
            float radDelta    = (2f * Mathf.PI) / bulletsPerShell[i];

            float curAngle    = 0;
            float bulletSpeed = (i * distanceBetweenShells) / timeBetweenEachShellForm;
            //Instantiating each bullet
            while (curAngle < 2 * Mathf.PI - 0.01f)
            {
                PolarCoordinate direction = new PolarCoordinate(1, curAngle);
                ParentedBullet  curBullet = Instantiate(bulletPrefab, transform.position, new Quaternion()) as ParentedBullet;
                curBullet.curState     = BulletState.parented;
                curBullet.damage       = bulletDamage;
                curBullet.owningPlayer = owningPlayer;
                if (!GameManager.S.inGame)
                {
                    curBullet.SetColor(thisPlayer.playerColor);
                    curBullet.thisPlayer = thisPlayer;
                }
                curBullet.transform.SetParent(transform);
                curBullet.transform.position = gameObject.transform.position;
                curBullet.physics.velocity   = bulletSpeed * direction.PolarToCartesian().normalized;

                childrenBullets.Add(curBullet);

                curAngle += radDelta;
            }

            //Moving the bullets
            while (timeInShell < timeBetweenEachShellForm)
            {
                timeInShell += Time.deltaTime;
                float percent = timeInShell / timeBetweenEachShellForm;

                List <ParentedBullet> bulletsToRemoveFromGroup = new List <ParentedBullet>();
                foreach (var bullet in childrenBullets)
                {
                    if (bullet.curState == BulletState.parented)
                    {
                        bullet.physics.velocity = (bullet.physics.velocity.normalized) * Mathf.Lerp(bulletSpeed, 0, percent);
                    }
                    else
                    {
                        bulletsToRemoveFromGroup.Add(bullet);
                    }
                }
                foreach (var bullet in bulletsToRemoveFromGroup)
                {
                    childrenBullets.Remove(bullet);
                }

                transform.Rotate(new Vector3(0, 0, 180 * Time.deltaTime));
                yield return(null);
            }
        }

        StartCoroutine(FireTowardsTarget());
    }