Esempio n. 1
0
        private void WaveCompleted(WaveHandler handler)
        {
            RemoveWave(handler);

            OnWaveFinished?.Invoke(handler.Wave, handler);

            if (_activeWaves.Count == 0)
            {
                ChangeState(RoundState.Ready);
            }
        }
Esempio n. 2
0
    private void Update()
    {
        if (hasWaveFinished)
        {
            return;
        }

        if (order >= maxOrder)
        {
            return;
        }
        bool allNull = true;

        for (int i = 0; i < spawningCoroutines.Length; i++)
        {
            if (spawningCoroutines[i] != null)
            {
                allNull = false;
            }
        }


        if (allNull)
        {
            order++;
            if (order == maxOrder)
            {
                //OnAllUfosSpawned?.Invoke();
                //print("wave finished");

                hasWaveFinished = true;
                OnWaveFinished?.Invoke();
            }


            StartWaveParts(order);
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Routine for handling spawning
    /// </summary>
    /// <param name="info"></param>
    /// <returns></returns>
    private IEnumerator spawnRoutine(WaveSpawnInfo info)
    {
        BoardManager board = getLocalBoardManager();

        if (!board)
        {
            // Be sure to null this (see isWaveInProgress)
            m_spawnRoutine = null;
            yield break;
        }

        int remainingSpawns = info.m_count;

        while (remainingSpawns > 0)
        {
            spawnMonster(board);

            // We want to call onWaveFinished as
            // soon as the last monster is spawned
            --remainingSpawns;
            if (remainingSpawns <= 0)
            {
                break;
            }

            yield return(new WaitForSeconds(info.m_spawnInterval));
        }

        // This may call initWave (it shouldn't), so we null out
        // spawnRoutine after so any call to initWave falls out
        if (onWaveFinished != null)
        {
            onWaveFinished.Invoke();
        }

        m_spawnRoutine = null;
    }