Example #1
0
    // ------------------------------------------------------- //
    //  Game Round Begin
    //      1. Spawn Random Enemies
    // ------------------------------------------------------- //
    void SpawnNewRound()
    {
        ClearOldRoundData();

        _roundNumber++;

        _difficultyScale = DifficultyCurve.Evaluate(_roundNumber / MaxRound);
        Debug.Log(_difficultyScale);

        // Round Paramaters
        int   numEnemies  = 2 + (int)Mathf.Round((_difficultyScale) * 1);
        float minSize     = 1;
        float maxSize     = _randomRange - _difficultyScale * 1;
        float minAreaSize = (_randomRange + minSize) + _difficultyScale * 2;
        float roundTime   = 5 * _difficultyScale;

        Vector2 center = GetLevelStartPos();

        for (int i = 0; i < numEnemies; i++)
        {
            Vector2 randUnit = Random.insideUnitCircle;
            Vector2 offset   = randUnit * (maxSize - minSize + 1) + randUnit * minSize;

            CircleController obj = SpawnCircle(offset + center);
            obj.color = Color.red;
            Enemies.Add(obj);
        }

        roundPlaying = true;

        // Start Area
        AreaController.StopScaleDown();
        AreaController.SyncPosition(MC.transform.position);
        AreaController.BeginScaleDown(minAreaSize, roundTime, () =>
        {
            roundPlaying = false;
            GameOver();
        });
    }