コード例 #1
0
    void Update()
    {
        if (UnactiveHazards.Count > 0 && WaveControl.GetInstance().IsWaveActive())
        {
            if (currentTimer >= currentHazardsSpawnTime)
            {
                currentTimer = 0f;
                float randomNumber = Random.Range(0f, 100f);
                if (randomNumber <= currentChanceOfSpawn)
                {
                    currentChanceOfSpawn    = startingChanceOfSpawn;
                    currentHazardsSpawnTime = startingHazardsSpawnTime;

                    int          randomIndex = Random.Range(0, UnactiveHazards.Count);
                    HazardSquare hazard      = UnactiveHazards[randomIndex];
                    hazard.SetActive(true);
                    ActiveHazards.Add(hazard);
                    UnactiveHazards.Remove(hazard);
                }
                else
                {
                    currentChanceOfSpawn    += plusChancePerCheck;
                    currentHazardsSpawnTime -= minusTimePerCheck;
                }
            }
            else
            {
                currentTimer += Time.deltaTime;
            }
        }
    }
コード例 #2
0
 void RemoveHazardFromList(HazardSquare hazard)
 {
     hazard.SetActive(false);
     ActiveHazards.Remove(hazard);
     UnactiveHazards.Add(hazard);
 }