Ejemplo n.º 1
0
    IEnumerator SpawnWaves()
    {
        while (!gameOver)
        {
            Vector3    spawnPosition;
            GameObject toSpawn;
            Quaternion spawnRotation = Quaternion.identity;

            if (spawnGunLevelUp && gunSetupCounter < numGunSetups)
            {
                spawnPosition = GetPowerupSpawnPos();
                toSpawn       = gunLevelUp;
                GameObject clone = Instantiate(toSpawn, spawnPosition, spawnRotation) as GameObject;

                GunLevelUpController powerup = clone.GetComponent <GunLevelUpController>();
                powerup.gunType = gunSetupCounter++;
                spawnGunLevelUp = false;
            }
            else
            {
                spawnPosition = GetHazardSpawnPos();
                toSpawn       = hazards[Random.Range(0, hazards.Length)];
                Instantiate(toSpawn, spawnPosition, spawnRotation);
            }

            yield return(new WaitForSeconds(Random.Range(spawnWaitMin, spawnWaitMax)));
        }
    }
Ejemplo n.º 2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         if (gameObject.CompareTag("Enemy"))
         {
             gameController.BroadcastGameOver();
             Debug.Log("Broadcasted");
         }
         else if (gameObject.CompareTag("GunLevelUp"))
         {
             GunLevelUpController powerup = gameObject.GetComponent <GunLevelUpController>();
             playerController.SetGuns(powerup.numGuns[powerup.gunType], powerup.angles[powerup.gunType]);
             Destroy(gameObject);
         }
         else if (gameObject.CompareTag("FireRateBoost"))
         {
             FireRateBoostController powerup = gameObject.GetComponent <FireRateBoostController>();
             powerup.IncreaseFireRate();
             Destroy(gameObject);
         }
     }
     else if (other.gameObject.CompareTag("Enemy") && other.isTrigger)
     {
         if (gameObject.CompareTag("PlayerShot"))
         {
             Destroy(other.gameObject);
             Destroy(gameObject);
             gameController.AddScore();
         }
     }
     else if (other.gameObject.CompareTag("PlayerShot") && gameObject.CompareTag("Obstacle"))
     {
         Destroy(other.gameObject);
     }
 }