Ejemplo n.º 1
0
    public CSequenceData RequestSequence(int aLane)
    {
        List <Runes> sequence = new List <Runes>();

        for (int i = 0; i < _currentSequenceCount; i++)
        {
            int random = CMath.randomIntBetween(0, 3);
            switch (random)
            {
            case 0:
                sequence.Add(Runes.FIRE);
                break;

            case 1:
                sequence.Add(Runes.OCCULT);
                break;

            case 2:
                sequence.Add(Runes.ENERGY);
                break;

            case 3:
            default:
                sequence.Add(Runes.STRENGTH);
                break;
            }
        }
        CSequenceData data = new CSequenceData(_currentSequenceWaitTime, sequence);

        _openSequences[aLane] = data;
        return(data);
    }
    public void SpawnEnemy()
    {
        float randSpawn = Random.value;

        if (randSpawn < .02f)
        {
            GameObject heart = Instantiate(CLevelManager.Inst._heart, transform);
            _currentHeart            = heart.GetComponent <CHeart>();
            heart.transform.position = _enemySpawnPonint.position;
        }
        else
        {
            float            maxProbab    = 0;
            int              maxProbIndex = 0;
            float            highestProb  = 0;
            List <EnemyData> enemies      = CLevelManager.Inst._enemies;
            for (int i = 0; i < enemies.Count; i++)
            {
                if (enemies[i].IsValidEnemy(CSequenceManager.Inst.GetCurrentRuneCount()))
                {
                    maxProbab += enemies[i].spawnProbability;
                    if (highestProb < enemies[i].spawnProbability)
                    {
                        highestProb  = enemies[i].spawnProbability;
                        maxProbIndex = i;
                    }
                }
            }
            float rand       = Random.value;
            int   spawnIndex = -1;
            float spawnProb  = 1;
            for (int i = 0; i < enemies.Count; i++)
            {
                float prob = enemies[i].spawnProbability / maxProbab;
                if (rand <= prob && spawnProb > prob)
                {
                    spawnIndex = i;
                    spawnProb  = prob;
                }
            }
            if (spawnIndex < 0)
            {
                CreateEnemy(maxProbIndex);
            }
            else
            {
                CreateEnemy(spawnIndex);
            }
            if (_currentEnemy == null)
            {
                return;
            }
        }
        CSequenceData data = CSequenceManager.Inst.RequestSequence(_laneIndex);

        data.ui = _ui;
        _ui.SetSequence(data.sequence);
        _mercenary.SetState(CMercenary.STATE_REQUEST);
    }