Example #1
0
    public void Spawn(float power)
    {
        if (_spawns.Length <= 0)
        {
            return;
        }

        // 1 + power = increased stats

        List <ActorSpawnSettings> possible = new List <ActorSpawnSettings>();

        bool shouldRollIfSameType = Random.value <= _sameTypeRerollChance;

        for (int i = 0; i < _spawns.Length; i++)
        {
            if (_spawns[i].PowerLevelGate <= power + 1)
            {
                possible.Add(_spawns[i]);
            }
        }

        ActorSpawnSettings newSpawn = possible[Random.Range(0, possible.Count)];
        // if (_lastSpawned != null &&
        //     newSpawn.Type == _lastSpawned.Type && newSpawn.Attack == _lastSpawned.Attack)
        // {
        //     if (Random.value < _sameTypeRerollChance)
        //     {
        //         ActorSpawnSettings first = newSpawn;

        //         while(newSpawn == first)
        //             newSpawn = _spawns[Random.Range(0, _spawns.Length)];
        //     }
        // }

        EnemyActor spawned = Create(newSpawn);

        spawned.SetPower(power);

        _lastSpawned = newSpawn;
    }
Example #2
0
    public void SpawnBoss(float power)
    {
        if (_bosses == null || _bosses.Length == 0)
        {
            return;
        }

        EnemyActor spawned = Create(_bosses[_nextBossIndex]);

        spawned.SetPower(power);

        if (_bossHealthReference != null && _bossMaxHealthReference != null)
        {
            spawned.SetHealthReference(_bossHealthReference, _bossMaxHealthReference);
            bossSpawnEvent?.Invoke();
        }

        if (_nextBossIndex + 1 < _bosses.Length)
        {
            _nextBossIndex++;
        }
    }