Example #1
0
    private void InstantiateBullet()
    {
        gameManager.DecreaseAmmo();

        animator.SetTrigger("throw");

        Minion newBullet = MinionsPool.Instance.Get(true);

        newBullet.DisableHarvestingForSeconds(1.0f);

        newBullet.transform.SetPositionAndRotation(spawnPoint.position, spawnPoint.rotation);

        Vector3 direction;

        if (playerController.FreeCamera)
        {
            direction = absorbParticleSystem.transform.parent.forward;
        }
        else
        {
            direction = (tps.FocalPoint - spawnPoint.position).normalized;
        }

        newBullet.AddForce(direction * pushForce, ForceMode.Impulse);
        newBullet.AddTorque(torque * Random.insideUnitSphere, ForceMode.Impulse);

        gameManager.audioManager.PlayOneShot(gameManager.audioManager.absorberPush, transform.position);
        gameManager.audioManager.PlayOneShot(gameManager.audioManager.thrownMinion[Random.Range(0, 3)], transform.position);

        pushParticleSystem.Play();
    }
Example #2
0
    public void SpawnMinions()
    {
        float t = Time.deltaTime;

        minionsSpawned += m_AmmoPerSecond * t;

        if (Mathf.Ceil(minionsSpawned) > totalMinionsSpawned)
        {
            int spawnAmmount = (int)Mathf.Ceil(minionsSpawned) - totalMinionsSpawned;

            for (int i = 0; i < spawnAmmount; i++)
            {
                Minion m = MinionsPool.Instance.Get(true);
                gm.AddMinionCounterToPauseMenu(m.minionID);
                m.explosive = true;
                m.DisableHarvestingForSeconds(1.0f);

                if (lastJetPack)
                {
                    m.transform.position = jetpackL.spawnPoint.position;
                }
                else
                {
                    m.transform.position = jetpackR.spawnPoint.position;
                }

                m.transform.localScale = 0.5f * Vector3.one;
                m.transform.rotation   = Random.rotation;
                m.AddForce(m_PushForce * Vector3.down, ForceMode.Impulse);
                m.AddTorque(m_PushTorque * Random.insideUnitSphere, ForceMode.Impulse);

                lastJetPack = !lastJetPack;
            }
        }

        totalMinionsSpawned = (int)Mathf.Ceil(minionsSpawned);
    }