Пример #1
0
    IEnumerator SpawnWaves()
    {
        yield return(new WaitForSeconds(startWait));

        while (true)
        {
            for (int i = 0; i < hazardCount; i++)
            {
                // Reallocation = Array[Random.Range(0, 10)];

                BouncyEnemy enemyScript = Hazards.GetComponent <BouncyEnemy>();
                enemyScript.moveSpeed = Random.Range(moveSpeedMin, moveSpeedMax);
                enemyScript.delta     = Random.Range(bouncinessmin, bouncinessmax);
                enemyScript.speed     = Random.Range(bobSpeedmin, bobSpeedMax);
                float spawnWait = Random.Range(spawnWaitMin, spawnWaitMax);
                while (spawnWait == spawnWaitbefore)
                {
                    for (int a = 0; a < hazardCount; a++)
                    {
                        spawnWait = Random.Range(spawnWaitMin, spawnWaitMax);
                    }
                }


                Vector3 spawnPosition = new Vector3(SpawnLocation1.transform.position.x, Random.Range(MinSpawnYvalue, MaxSpawnYvalue)
                                                    , 0f);
                Quaternion spawnRotation = Quaternion.identity;
                Instantiate(Hazards, spawnPosition, spawnRotation);
                yield return(new WaitForSeconds(spawnWait));

                spawnWaitbefore = spawnWait;
            }
            yield return(new WaitForSeconds(waveWait));
        }
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (hp <= 0)
     {
         if (Key == false)
         {
             canvasController.addScore(scoreValue);
         }
         Key = true;
         BouncyEnemy enemyScript = GetComponent <BouncyEnemy>();
         enemyScript.Fall         += -0.005f;
         enemyScript.rotationSpeed = 40;
         enemyScript.moveSpeed    -= 0.0005f;
         //      enemyScript.moveSpeed = Random.Range(moveSpeedMin, moveSpeedMax);
         enemyScript.delta = 0f;
         enemyScript.speed = 0f;
     }
 }
Пример #3
0
 void Awake()
 {
     LC = FindObjectOfType<LevelController>();
     isDead = false;
     bouncyEnemy = gameObject.transform.parent.gameObject.GetComponent<BouncyEnemy>();
 }